简体   繁体   中英

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);

             }

        }});

JInternal Frame是Java框架中的一个框架,因此您可能应该使用JInternalFrame。您可以在此处学习如何使用它。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM