1. Type this following java programming code on your java programming IDE:
// Import the Java Swing Components package
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JFrame;
import javax.swing.SwingConstants;
import javax.swing.JTextArea;
import java.awt.BorderLayout;
public class JavaSwingComponentList {
/**
* Create the GUI and show it
*
*/
private static void initComponents() {
// Variables declaration for Java Swing and Define Java Swing Component
javax.swing.JButton jButton1 = new javax.swing.JButton("jButton1");
javax.swing.JLabel jLabel1;
javax.swing.JLabel jLabel2;
javax.swing.JTextField jTextField1;
javax.swing.JTextArea jTextArea1;
jLabel1 = new javax.swing.JLabel("jLabel1");
jLabel2 = new javax.swing.JLabel("jLabel2");
jTextField1 = new javax.swing.JTextField("jTextField1");
jTextArea1 = new javax.swing.JTextArea("jTextArea1");
// Create the window
JFrame frame = new JFrame("Java Swing Components List");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// add Component and configure the position
frame.getContentPane().add(jButton1, BorderLayout.NORTH);
frame.getContentPane().add(jLabel1, BorderLayout.WEST);
frame.getContentPane().add(jTextArea1, BorderLayout.CENTER);
frame.getContentPane().add(jLabel2, BorderLayout.EAST);
frame.getContentPane().add(jTextField1, BorderLayout.SOUTH);
// Display the window
frame.pack();
frame.setSize(300, 150);
frame.setVisible(true); }
public static void main(String[] args) {
//Schedule and job for the event-dispatching thread:
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
initComponents();
}
});
}
}
2. Save as JavaSwingComponentList.java.
3. Compile and run Java source code from above.
Result
<< back to Study About Java 1
Tidak ada komentar:
Posting Komentar