我很確定我之前是這樣做的,但由於某種原因,當我運行它時,JFrame不會顯示出來。爲什麼我的JFrame沒有顯示?
JLabel originalString = new JLabel("Original String: "
+ str.getMutator());
JLabel currentString = new JLabel("Current String: "
+ str.getMutator());
JLabel finalString = new JLabel("Final String: " + str.getTarget());
JPanel panel = new JPanel();
panel.add(originalString);
panel.add(currentString);
panel.add(finalString);
JFrame frame = new JFrame("Mutating String!");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(panel);
frame.pack();
frame.setVisible(true);
}
這段代碼包含什麼方法? – 2010-09-27 22:02:23