1

我有一个小的 java+swing 应用程序。到目前为止,它在 OS X 和 Windows 上运行良好。

但是最近有用户注意到在他的 OS X(版本未知,也不是 java 版本)上,GUI 中的所有文本都被向上移动和剪切(如您在屏幕截图中所见)。

看错了 http://b3.s3.quickshareit.com/picture1ac6aa.png

并且 HTML 链接被下移和剪切。所有这些元素都是 JLabel。

这就是它的样子

好的,看看 http://b1.s3.quickshareit.com/screenshot_45f5e29f947e59b81.png

有什么想法/帮助吗?以前有人遇到过这个问题吗?我不知道从哪里开始。谢谢你的帮助

我用谷歌搜索了“java jlabel crop/cut”等。

==========

代码片段

import java.awt.Insets;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import System.DnDList;
import System.QSTWindow;
import System.configuration.Configuration;


public class Test extends JFrame
{
    private static final long serialVersionUID = 8698865819017225558L;

    public static void main(String[] args)
    {
        Test main = new Test();
        main.setVisible(true);
    }

    private JPanel down_panel;
    private JButton b_Preferences;
    private JButton b_AddFile;
    private JButton b_Send2;
    private JButton b_Cancel;
    private JButton b_Cancel2;
    private DnDList dndList;
    private JLabel filesToSendLabel;
    private JLabel browseFilesLabel;
    private JPanel selectedFilesPanel;
    private JPanel gPanel;    

    public Test()
    {
        this.setLayout(null);
        this.setBackground(new java.awt.Color(255, 255, 255)); // XXX move color to configuration class
        this.setDefaultCloseOperation(EXIT_ON_CLOSE);

        this.setSize(360, 525); // whole window

        gPanel = new JPanel();
        gPanel.setLayout(null);
        gPanel.setBackground(new java.awt.Color(255, 255, 255));
        gPanel.setBounds(0, 0, 365, 525); // whole window panel


        selectedFilesPanel = new JPanel();
        selectedFilesPanel.setLayout(null);
        selectedFilesPanel.setBounds(0, 333, 440, 122);
        selectedFilesPanel.setBackground(new java.awt.Color(255, 255, 255));

        down_panel = new JPanel(); // panel with info button and upload button
        down_panel.setLayout(null);
        down_panel.setBackground(new java.awt.Color(255, 255, 255));
        down_panel.setBounds(0, 430, 365, 80);

        // icon taken from http://en.wikibooks.org/wiki/Image:Information_icon.svg
        b_Preferences = new JButton("PREF");
        b_Preferences.setFocusPainted(false);
        b_Preferences.setToolTipText("Settings");
        b_Preferences.setBackground(Configuration.getBACKGROUND_COLOR());
        b_Preferences.setBounds(11, 25, 32, 32);
        b_Preferences.setMargin(new Insets(0, 0, 0, 0));
        b_Preferences.setBorderPainted(false);

        b_AddFile = new JButton("Browse");
        b_Send2 = new JButton(new ImageIcon(QSTWindow.class.getResource("upload.png")));
        b_Cancel = new JButton("Cancel");
        b_Cancel2 = new JButton("Cancel");

        dndList = new DnDList(selectedFilesPanel, 8, 10, 364, 97, this);

        filesToSendLabel = new JLabel("Media to send");
        filesToSendLabel.setFont(Configuration.getDEFAULT_LABEL_FONT());
        filesToSendLabel.setBounds(10, 325, 150, 14);
        browseFilesLabel = new JLabel("<HTML><U>Browse</U></HTML>");
        browseFilesLabel.setForeground(Configuration.getLINK_COLOR());
        browseFilesLabel.setFont(Configuration.getLINK_FONT());
        browseFilesLabel.setBounds(90, 325, 50, 14);

        b_Send2.setBounds(272, 25, 72, 26);
        b_Send2.setMargin(new Insets(3, 0, 3, 0));

        down_panel.add(b_Preferences);
        down_panel.add(b_Send2);

        gPanel.add(filesToSendLabel);
        gPanel.add(browseFilesLabel);
        gPanel.add(selectedFilesPanel);
        gPanel.add(down_panel);

        this.add(gPanel);
        this.setResizable(false);
    }
}

抱歉,此示例不可编译(您需要一半的应用程序),但显示了有问题的元素。

4

1 回答 1

0

我在想这个问题可能与系统中安装的字体有关。

您能否将文本设置为您 100% 确定它会安装在系统中的某个已知字体?

于 2009-10-14T11:58:14.983 回答