我即將開始學習編碼GUI。現在我知道,如果你第一次手工編寫代碼來掌握概念,那麼它就是最好的選擇。手工編碼GUI和Netbeans
我的問題是:我需要禁用Netbeans中的GUI buidler來做到這一點嗎?查看Netbeans論壇,但找不到明確的答案。看來大多數程序員仍然更喜歡手動編碼選項。
感謝您的關注
我即將開始學習編碼GUI。現在我知道,如果你第一次手工編寫代碼來掌握概念,那麼它就是最好的選擇。手工編碼GUI和Netbeans
我的問題是:我需要禁用Netbeans中的GUI buidler來做到這一點嗎?查看Netbeans論壇,但找不到明確的答案。看來大多數程序員仍然更喜歡手動編碼選項。
感謝您的關注
不,您不必禁用任何東西。您可以立即開始編寫Swing代碼。
通過粘貼HelloWorldSwing
程序的源代碼並運行它自己嘗試一下。這裏有一個縮寫版本:
import javax.swing.*;
public class HelloWorldSwing {
private static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("HelloWorldSwing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Add the ubiquitous "Hello World" label.
JLabel label = new JLabel("Hello World");
frame.getContentPane().add(label);
//Display the window.
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
//Schedule a job for the event-dispatching thread:
//creating and showing this application's GUI.
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
對....感謝您的回答。 – 2012-08-01 09:32:34
擺動可以開始沒有任何額外的繼承人的例子。
import javax.swing.JFrame;
import javax.swing.JLabel;
public class HelloWorldFrame extends JFrame {
//Programs entry point
public static void main(String args[]) {
new HelloWorldFrame();
}
//Class Constructor to create components
HelloWorldFrame() {
JLabel jlbHelloWorld = new JLabel("Hello World");
add(jlbHelloWorld); //Add the label to the frame
this.setSize(100, 100); //set the frame size
setVisible(true); //Show the frame
}
}
注:這是最小的得到它運行一個極其簡單的版本... @aioobe是更標準的做法,但需要了解更多的概念:)
謝謝你的幫助。 – 2012-08-01 09:34:27
+1作出努力瞭解處理! – MadProgrammer 2012-08-01 10:14:21