1

私は小さなJava + Swingアプリを持っています。今までは、OS X と Windows で問題なく動作していました。

しかし最近、あるユーザーが、OS X (バージョンはまだ不明で、Java バージョンも不明) で、GUI のすべてのテキストが上に移動して切り取られていることに気付きました (スクリーンショットでわかるように)。

見間違い http://b3.s3.quickshareit.com/picture1ac6aa.png

そしてHTMLリンクは下にずらしてカット。これらの要素はすべて JLabels です。

これは、それがどのように見えるべきかです

わかりました 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 に答える