gridbaglayout crash on start

why does this crash on start?

need help, why doesthis crash on launch?

import java.awt.*;

import javax.swing.*;

publicclass WhoWoulduliketokill{

publicstaticvoid main( String args[]){

new test();

}

}

class testextends JPanel{

public test(){

initComponents();

}

privatevoid initComponents(){

// JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents

// Generated using JFormDesigner Evaluation license - Kevin Rose

label1 =new JLabel();

textField1 =new JTextField();

label2 =new JLabel();

textField2 =new JTextField();

scrollPane1 =new JScrollPane();

textArea1 =new JTextArea();

button1 =new JButton();

//======== this ========

// JFormDesigner evaluation mark

setBorder(new javax.swing.border.CompoundBorder(

new javax.swing.border.TitledBorder(new javax.swing.border.EmptyBorder(0, 0, 0, 0),

"JFormDesigner Evaluation", javax.swing.border.TitledBorder.CENTER,

javax.swing.border.TitledBorder.BOTTOM,new java.awt.Font("Dialog", java.awt.Font.BOLD, 12),

java.awt.Color.red), getBorder())); addPropertyChangeListener(new java.beans.PropertyChangeListener(){publicvoid propertyChange(java.beans.PropertyChangeEvent e){if("border".equals(e.getPropertyName()))thrownew RuntimeException();}});

setLayout(new GridBagLayout());

((GridBagLayout)getLayout()).columnWidths =newint[]{0, 0, 0, 0, 0};

((GridBagLayout)getLayout()).rowHeights =newint[]{0, 0, 0, 0, 0, 0, 0};

((GridBagLayout)getLayout()).columnWeights =newdouble[]{0.0, 0.0, 0.0, 0.0, 1.0E-4};

((GridBagLayout)getLayout()).rowWeights =newdouble[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0E-4};

//- label1 -

label1.setText("Person To Kill: ");

add(label1,new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,

GridBagConstraints.CENTER, GridBagConstraints.BOTH,

new Insets(0, 0, 5, 5), 0, 0));

//- textField1 -

textField1.setColumns(10);

add(textField1,new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,

GridBagConstraints.CENTER, GridBagConstraints.BOTH,

new Insets(0, 0, 5, 5), 0, 0));

//- label2 -

label2.setText("How Many Times: ");

add(label2,new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,

GridBagConstraints.CENTER, GridBagConstraints.BOTH,

new Insets(0, 0, 5, 5), 0, 0));

add(textField2,new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,

GridBagConstraints.CENTER, GridBagConstraints.BOTH,

new Insets(0, 0, 5, 5), 0, 0));

//======== scrollPane1 ========

{

//- textArea1 -

textArea1.setRows(3);

scrollPane1.setViewportView(textArea1);

}

add(scrollPane1,new GridBagConstraints(0, 2, 3, 3, 0.0, 0.0,

GridBagConstraints.CENTER, GridBagConstraints.BOTH,

new Insets(0, 0, 5, 5), 0, 0));

//- button1 -

button1.setText("Kill Them!");

add(button1,new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0,

GridBagConstraints.CENTER, GridBagConstraints.BOTH,

new Insets(0, 0, 0, 5), 0, 0));

// JFormDesigner - End of component initialization //GEN-END:initComponents

}

// JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables

// Generated using JFormDesigner Evaluation license - Kevin Rose

private JLabel label1;

private JTextField textField1;

private JLabel label2;

private JTextField textField2;

private JScrollPane scrollPane1;

private JTextArea textArea1;

private JButton button1;

// JFormDesigner - End of variables declaration //GEN-END:variables

}

[6881 byte] By [krrose27a] at [2007-11-26 18:12:50]
# 1
You need to create a JFrame and add the panel to the frame and then make the panel visible.Read the [url http://java.sun.com/docs/books/tutorial/uiswing/TOC.html]Swing tutorial[/url] for examples. I don't know how to do it in your IDE.
camickra at 2007-7-9 5:45:45 > top of Java-index,Desktop,Core GUI APIs...
# 2
what do u mean?
krrose27a at 2007-7-9 5:45:45 > top of Java-index,Desktop,Core GUI APIs...
# 3
Where in your code to you create a JFrame and make it visible?Read any of the examples from the Swing tutorial and follow the structure used in the examples.
camickra at 2007-7-9 5:45:45 > top of Java-index,Desktop,Core GUI APIs...
# 4

camickr means that you cannot see anything until you have not created a JFrame and put your panel on it. So your sample is no crash. There just is nothing to show.

Try this in your constructor:

public test() {

initComponents();

JFrame frame = new JFrame();

frame.add(this);

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

frame.pack();

frame.setVisible(true);

}

BTW: class names should start with capital letters.

the12huntersa at 2007-7-9 5:45:45 > top of Java-index,Desktop,Core GUI APIs...