This is a very basic Java syntax question. I have a form called frmMainMenu in its own class, and that has a button labeled "Schedule". When you click "Schedule" I want it to open another form. That one is in a separate class called frmSchedule.
In the ActionListener part of frmMainMenu I have this:
public void actionPerformed(ActionEvent e) {
System.out.println("TEST");
frmSchedule window2 = new frmSchedule();
}
It prints the word "TEST" in the console (so I know the code is in the right place). But, it does not open the Schedule form. I also tried it like this, which also didn't work:
public void actionPerformed(ActionEvent e) {
System.out.println("TEST");
new frmSchedule();
}
Here's the code for frmSchedule:
import java.awt.BorderLayout;
import java.awt.EventQueue;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.JButton;
public class frmSchedule extends JFrame {
private JPanel contentPane;
public frmSchedule() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
contentPane = new JPanel();
contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
setContentPane(contentPane);
contentPane.setLayout(null);
JButton btnNewButton = new JButton("Trials");
btnNewButton.setBounds(128, 100, 89, 23);
contentPane.add(btnNewButton);
}
}
I guess I'm just having trouble finding the way to phrase the code to tell it to open the second form.