i have a problem.
I want to have a Main Panel in which will load another panel that is inside a different class.
The main panel is this:
public class ClassPanel extends JPanel {
public ClassPanel(){
JLabel scritta = new JLabel("Which Panel");
JButton one = new JButton("Panel 1");
class b1Button implements ActionListener {
public void actionPerformed(ActionEvent e) {
GameOne gameone = new GameOne();
add(gameone);
}
}
one.addActionListener(new b1Button());
add(scritta);
add(one);
}}
And the class GameOne is this:
public class GameOne extends JPanel{
public GameOne() {
JLabel lab = new JLabel("Game 1 selected");
add(lab);
}}
The problem is that when i click the Button 1 in the main panel, i don't see the label in the GameOne class.
Whats the problem? Thanks :)