0
import javax.swing.*;
public class CipherGUI{
public static void main(String args[]){
try {
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) {}
JFrame cipherGUIFrame = new CipherGUIFrame();
cipherGUIFrame.setVisible(true);
}
}
class CipherGUIFrame extends JFrame {
public CipherGUIFrame() {
super("Caesar Cipher GUI");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(400, 600);
JLabel inputLabel = new JLabel("Enter numbers below");
JPanel p1 = new JPanel();
p1.setLayout(new BoxLayout(p1, BoxLayout.Y_AXIS));
p1.add(inputLabel);
}
}
正如你所看到的,我試圖將p1添加到我的CipherGUIFrame()函數中,但我無法完全顯示它。這個功能是什麼,更重要的是,我應該將所有的面板添加到構造函數方法的外部,而不是在MAIN類中?看來我將它們添加到CipherGUIFrame()的構造函數中的正確位置,因爲它屬於那裏。無論哪種方式,請幫我找到一種方法讓我的面板出現!謝謝〜JAVA-試圖讓面板在框架中可見
凡你把你的面板是由你,有沒有正確或錯誤的答案。儘管您最終會想使用MVC方法... http://en.wikipedia.org/wiki/Model%E2%80%93view%E2%80%93controller – MarGar 2014-10-06 16:14:42