Hello.
I am constructing a database using GUI. I wanted to have all my containers to be on one window. I am having a problem on how to have these containers on one window. Any suggestions? I am very sorry if the code was seem weird.
Here's the code:
public class EmployeeDatabase extends JFrame{
public static void main(String[] args) {
EmployeeDatabase ed = new EmployeeDatabase();
ed.setVisible(true);
}
Container main = getContentPane();
Container frontpage = getContentPane();
Container node = getContentPane();
JButton addButton;
JLabel d;
public EmployeeDatabase(){
super("EneBio Employee Database System");
frontPage();
/*super("EneBio Employee Database System");
this.setSize(650, 450);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);*/
}
public void frontPage(){
this.setSize(650, 450);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frontpage.setLayout(null);
frontpage.add(main);
frontpage.add(node);
}
class mainPage{{
//add button
addButton = new JButton("New profile");
addButton.setFont(new Font("Courier New Bold", Font.ITALIC, 15));
addButton.setLocation(400, 50);
addButton.setSize(170, 50);
addButton.setToolTipText("Inserts a new employee's profile.");
addButton.setBackground(new Color(45, 38, 72));
addButton.setForeground(new Color(92, 224, 132));
//addButton.addMouseListener(new addButtonListener());
main.add(addButton);
main.setVisible(true);
node.setVisible(false);
}
class newProfile{{
d = new JLabel("DEPARTMENT: ");
d.setFont(new Font("Courier New Bold", Font.ITALIC, 16));
d.setForeground(new Color(92, 224, 132));
d.setLocation(220, 70);
d.setSize(150, 30);
node.add(d);
node.setVisible(true);
main.setVisible(false);
}}
}
}
The error I always received was kind of Illegal Argument Exception : adding container to itself. How to solve that problem?