1

我已经指定了宽度和高度,f.setSize();但没有任何区别。

这是代码:

public class MTGSAMPServerReference extends JPanel{

    public static Toolkit tk = Toolkit.getDefaultToolkit(); 
    static int ScrnWidth = ((int) tk.getScreenSize().getWidth());
    static int ScrnHeight = ((int) tk.getScreenSize().getHeight());

    public static void main(String[] args) {
        MTGSAMPServerReference gui = new MTGSAMPServerReference();
        gui.launchFrame();
    }

    public void launchFrame() {
        String[]listContents={"Vehicles","Houses","Companies","Objects","Jobs"};
        JFrame f = new JFrame("MTG SAMP Server Reference");
        JList list1=new JList(listContents);
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.setVisible(true);
            f.setSize(1200, 800);
            f.setLocationRelativeTo(null);
            f.add(list1);
            list1.setSize(500, 500);
            Container contentPaneMain = f.getContentPane();
            contentPaneMain.add(new MTGSAMPServerReference());
            f.pack();
        }
}

我做错了什么或忘记了什么?

4

0 回答 0