user3328281
user3328281

Reputation: 201

How to display another class in a gui class java?

I'm trying to create an employee payroll system. Im creating a dropdown menu with JMenuItem Add Employee, and when you click that menu item then it will display another jframe below to enter in all the employee details. I have the add employee JFrame made and it runs perfectly. So i was wondering how do link the two? This is a part of it that might help

public static void main(String[] args) {
        final JFrame frame = new JFrame("Payroll");

        //create the Employee menu
        JMenu employee = new JMenu("Employee");
        employee.setMnemonic(KeyEvent.VK_E);
        employee.add(new JMenuItem("Add"));
        final JMenuItem add = new JMenuItem();
        add.addActionListener(new ActionListener() {
             public void actionPerformed(ActionEvent e) {
                 if (add.isSelected()) {
                     JFrame f = new EmployeeTaxDetails1();
                     final JFrame frame = new JFrame();
                             f.setVisible(true);
                                 frame.setVisible(false);

             }

        }});

Upvotes: 0

Views: 117

Answers (1)

Subhan
Subhan

Reputation: 1634

JInternal Frame is a frame within a frame in java so you should probably use JInternalFrame You can learn how to use it here.

Upvotes: 1

Related Questions