将JOptionPane选项对话框的大小设置为适合屏幕

时间:2012-10-04 06:31:55

标签: java joptionpane

import javax.swing.JOptionPane;

public class trial
{
    private static final String EXIT_ON_CLOSE = null;

    public static void main(String[] args)
    {
        String[] option = {
            "Adlawan", "Angeles", "Arreza", "Benenoso", "Bermas", "Brebante","Cabaylo", "C. Cainglet", "O. Cainglet", 
            "Calunsag", "Cameros", "Casanaan", "Catulong", "Chicote", "Dela Paz", "Ea", "Echavez", "Esquivel", 
            "Fudadera", "Gales", "Gentallan", "Gerodias", "A. Guadalupe", "S. Guadalupe",
            "Hanuyan", "Jamero", "Macana","Mangmang","Moncano", "Ocon", "Ortiz", "Oquendo", "Palma", "Paran",           
            "Simbajon", "Torcido", "C. Ylagan", "E. Ylagan",
        };  

        int choose =  JOptionPane.showOptionDialog(null,
            "                    WHICH EMPLOYEE'S BEGINNING BALANCE WOULD YOU LIKE TO UPDATE?", "Click to Choose Employee",
            JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, option, option[37]);

        setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    private static void setDefaultCloseOperation(String exitOnClose) {
        // TODO Auto-generated method stub
    }
}

这些是我上面的代码,问题是我的JOptionPane OptionDialog超出了我的屏幕。我的问题是,是否可以更改或设置JOptionPane OptionDialog的指定尺寸以使其适合我的屏幕?

我尝试使用JScrollPane并将其添加到JPanel,但我无法使其正常工作。

0 个答案:

没有答案