jonneymendoza
Supreme [H]ardness
- Joined
- Sep 11, 2004
- Messages
- 6,395
Hi, I am trying to create a very basic form using java netbeans. i have jdk 1.5.
I have two classes, the main class and the gui class. The main class creates a Jframe and adds then adds the gui components from the gui class I made. The problem is when I try to run the program, the compiler throws an exception saying that I am adding a container to a window. The line it points at is highlighted below:
I have two classes, the main class and the gui class. The main class creates a Jframe and adds then adds the gui components from the gui class I made. The problem is when I try to run the program, the compiler throws an exception saying that I am adding a container to a window. The line it points at is highlighted below:
Code:
import com.sun.org.apache.bcel.internal.verifier.structurals.Frame;
import javax.swing.JFrame;
import java.awt.*;
public class Main
{
public static void main(String[] args)
{
JFrame frame = new JFrame();
//frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
frame.setTitle("Login");
Login test1 = new Login();
frame.getContentPane().add(test1); //Line in which the compiler throws an exception
frame.setSize(200, 150);
frame.setVisible(true);
// TODO code application logic here
}
}