Hi im doing my main page for my program and i want to happen is when i click the maze button, the Maze class would appear and same with the hexagonal button.
Can you tell me what is wrong with my program?everytime i run and click a button nothing happens.thanks for the huge help.
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.lang.*;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class Center extends JFrame {
Maze x = new Maze();
HEX h = new HEX();
JPanel jp = new JPanel();
JButton jb = new JButton("Maze");
JButton jb1 = new JButton("Hex");
JFrame frame = new JFrame();
public Center()
{
frame.setTitle("Prims Maze Generation");
//setVisible(true);
//setSize(400,200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
frame.setVisible(true);
frame.setSize(400, 200);
jp.add(jb);
jp.add(jb1);
frame.add(jp);
jb.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
x.setVisible(true);
frame.pack();
}
});
jb.addActionListener(new ActionListener(){
public void actionPerformed (ActionEvent e)
{
h.setVisible(true);
}
});
}
public static void main(String args[])
{
Center p = new Center();
}
}