sooo i finally got the new "pop up" frame after a button is clicked. so than after the user clicks the button and new frame pops up i try to add some stuff and buttons to that new frame.. but it doesn't show. it's just a black frame. I don't understand. Can someone help/modify so it displays. thanks!@
this is my program (I bolded the part where I added the new buttons to the new popup page, but it still shows black on the popup page.. how come? >.>"
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.Dimension;
public class RestaurantFirstPage1 {
final static String LABEL_TEXT = "Welcome to the restaurant rating website";
JFrame frame;
JFrame firstFrame;
JFrame secondFrame;
JPanel contentPane;
JLabel label;
JButton signIn;
JButton signUp;
JButton exit;
JButton exit2;
public RestaurantFirstPage1() {
frame = new JFrame("Restaurant First Page");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
contentPane = new JPanel();
contentPane.setLayout(new BoxLayout(contentPane, BoxLayout.PAGE_AXIS));
contentPane.setBorder(BorderFactory.createEmptyBorder(50,20,30,20));
contentPane.setBackground(Color.white);
label = new JLabel(LABEL_TEXT);
label.setForeground(Color.black);
label.setAlignmentX(JLabel.CENTER_ALIGNMENT);
label.setBorder(BorderFactory.createEmptyBorder(20,50,20,50));
contentPane.add(label);
signIn = new JButton("Sign In");
contentPane.add(signIn);
signIn.setAlignmentX(JButton.CENTER_ALIGNMENT);
contentPane.add(Box.createRigidArea(new Dimension(0, 15)));
signIn.setActionCommand("Sign In");
signIn.addActionListener(new NextPage());
signUp = new JButton("Sign Up");
contentPane.add(signUp);
signUp.setAlignmentX(JButton.CENTER_ALIGNMENT);
contentPane.add(Box.createRigidArea(new Dimension(0, 15)));
signUp.setActionCommand("Sign Up");
signUp.addActionListener(new NextPage());
exit = new JButton("Exit");
contentPane.add(exit);
exit.setAlignmentX(JButton.CENTER_ALIGNMENT);
contentPane.add(Box.createRigidArea(new Dimension(0, 15)));
exit.addActionListener(new Terminate());
frame.setContentPane(contentPane);
frame.pack();
frame.setVisible(true);
}
private static void runGUI() {
JFrame.setDefaultLookAndFeelDecorated(true);
RestaurantFirstPage1 firstPage = new RestaurantFirstPage1();
}
class NextPage implements ActionListener {
public void actionPerformed(ActionEvent event) {
String eventName = event.getActionCommand();
if(eventName.equals("Sign In")) {
[b] firstFrame();
frame.dispose();
frame = null;
}
else if(eventName.equals("Sign Up")) {
secondFrame();
frame.dispose();
frame = null;
}
}
private void firstFrame() {
firstFrame = new JFrame("SignIn");
firstFrame.setSize(350, 320);
firstFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
firstFrame.setVisible(true);
}
private void secondFrame() {
secondFrame = new JFrame("SignUp");
secondFrame.setSize(350, 320);
secondFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
secondFrame.setVisible(true); [/b]
}
}
class Terminate implements ActionListener {
public void actionPerformed(ActionEvent event) {
System.exit(0);
}
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
runGUI();
}
});
}
}