我有一个小的java + swing应用程序。到目前为止,它在OS X和Windows上都运行良好。
但是,用户已经注意到,在他的OS X(版本未知,也不是Java版本)中,GUI中的所有文本都被向上移动并剪切(如截图所示)。
wrong look http://b3.s3.quickshareit.com/picture1ac6aa.png
HTML链接向下移动并切断。所有这些元素都是JLabel。
它应该是这样的样子
ok look 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);
}
}
很抱歉,此示例不可修改(您需要应用程序的一半),但会显示有问题的元素。
答案 0 :(得分:0)
我在想,问题可能与系统中安装的字体有关。
您是否可以将文本设置为某些已知的字体,您可以100%确定它将在系统中安装?