I am struggling with correctly building a GUI form with Swing. I am using Sun One Forte Update 1 to build the form. I have a JFrame and a GridLayout. I have set up the Grid to support 2 Columns and 5 Rows. The problem is that all components are being added to the first column only?? Should I be adding panels or passing arguments when adding components to specify the column. If so, where do you find this in Sun One?
I have seen some variables in the
IDE like alignmentx and alignmenty, but they seem to make no impact. I would appreciate any advice or suggestions, thanks. I have attached code.
Dave
/*
* HELP.java
*
* Created on February 4, 2003, 7:24 PM
*/
/**
*
* @author
*/
public class HELP extends javax.swing.JFrame {
/** Creates new form HELP */
public HELP() {
initComponents();
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox();
jSeparator1 = new javax.swing.JSeparator();
jLabel2 = new javax.swing.JLabel();
jComboBox2 = new javax.swing.JComboBox();
getContentPane().setLayout(new java.awt.GridLayout(5, 2));
setTitle("This is a test");
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
exitForm(evt);
}
});
jLabel1.setText("Please make selection:");
getContentPane().add(jLabel1);
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new
String[] { "Test", "Test2", "Test3" }));
getContentPane().add(jComboBox1);
getContentPane().add(jSeparator1);
jLabel2.setText("Please make second selection:");
getContentPane().add(jLabel2);
jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Test1", "Test2", "Test3" }));
getContentPane().add(jComboBox2);
pack();
}
/** Exit the Application */
private void exitForm(java.awt.event.WindowEvent evt) {
System.exit(0);
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
new HELP().show();
}
// Variables declaration - do not modify
private javax.swing.JSeparator jSeparator1;
private javax.swing.JComboBox jComboBox2;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel1;
// End of variables declaration
}