I am making application, using IDEA
Forms. I want to have different forms. First for login, then for displaying information from database after login. I created two different forms. First one: MenuMain
and second AdminForm
. After clicking a login button in MenuMain I want to open AdminForm, I tried with setContentPane
and passing main panel from AdminForm, but it does not work. How to solve this?
public class MenuMainForm extends JFrame implements ActionListener {
private JPanel panel1;
private JTextPane logowanieText;
private JTextField userField;
private JTextField passField;
private JButton logowanieButton;
public MenuMainForm(){
logowanieButton.addActionListener(this);
public void actionPerformed(ActionEvent e) {
AdminForm adminForm = new AdminForm();
this.setContentPane(adminForm);
}
public static void main( String[] args){
JFrame menuFrame = new JFrame("Kawiarnia");
menuFrame.setContentPane(new MenuMainForm().panel1);
menuFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
menuFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);
menuFrame.setVisible(true);
}
And the AdminForm Code:
public class AdminForm extends JPanel{
private JPanel adminPanel;
private JButton infoKawiarniaButton;
private JTable tabelaInfo;
private static String QUERY_INFO = "SELECT * FROM NATALIAGAZDA.KAWIARNIE ";
public AdminForm() {
DefaultTableModel model = (DefaultTableModel) tabelaInfo.getModel();
model.addRow(new Object[]{"Atrybut", "Wartosc"});
public JPanel getAdminPanel() {
return adminPanel;
}