我已使用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();
}
}
我做错了什么或遗忘了什么?