I need to make this a popup when a button is clicked. This is the code for the Button.
JButton moreOptionsButton = new JButton("More Options");
moreOptionsButton.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
timer.stop();
}
} );
I need this information to come up in a new window. After a option is clicked the window closes or when I click the Close just the new window closes.
{
// Set the title bar text.
// setTitle("More Options");
// Set the size of the window.
setSize(WINDOW_WIDTH, WINDOW_HEIGHT);
// Specify an action for the close button.
// setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
// Add a GridLayout manager to the content pane.
setLayout(new GridLayout(4, 2));
// Create four buttons.
JButton fillButton = new JButton("Fill Board");
fillButton.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
model.clear();
model.fill();
}
} );
JButton shapeButton = new JButton("Shape 1");
shapeButton.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
model.clear();
model.shape1();
}
} );
JButton helloWorldButton = new JButton("Hello World");
helloWorldButton.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
model.clear();
model.helloWorld();
}
} );
JButton aboutButton = new JButton("About");
aboutButton.addActionListener( new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
}
} );
// Create four labels.
JLabel fillLabel = new JLabel("Fill Board with Live Cells.");
JLabel shapeLabel = new JLabel("Display Walking Shape.");
JLabel helloWorldLabel = new JLabel("Display Hello World.");
JLabel aboutLabel = new JLabel("Information About Program.");
// Create four panels.
JPanel panel1 = new JPanel();
JPanel panel2 = new JPanel();
JPanel panel3 = new JPanel();
JPanel panel4 = new JPanel();
JPanel panel5 = new JPanel();
JPanel panel6 = new JPanel();
JPanel panel7 = new JPanel();
JPanel panel8 = new JPanel();
// Add the labels to the panels.
panel2.add(fillLabel);
panel4.add(shapeLabel);
panel6.add(helloWorldLabel);
panel8.add(aboutLabel);
// Add the buttons to the panels.
panel1.add(fillButton);
panel3.add(shapeButton);
panel5.add(helloWorldButton);
panel7.add(aboutButton);
// Add the panels to the content pane.
add(panel1); // Goes into row 1, column 1
add(panel2); // Goes into row 1, column 2
add(panel3); // Goes into row 2, column 1
add(panel4); // Goes into row 2, column 2
add(panel5); // Goes into row 3, column 1
add(panel6); // Goes into row 3, column 2
add(panel7); // Goes into row 4, column 1
add(panel8); // Goes into row 4, column 2
// Display the window.
setVisible(true);
}