简体   繁体   English

如何在gui类java中显示另一个类?

[英]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. 我用JMenuItem Add Employee创建一个下拉菜单,当您单击该菜单项时,它将在下面显示另一个jframe以输入所有员工详细信息。 I have the add employee JFrame made and it runs perfectly. 我有添加员工JFrame,它运行完美。 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。您可以在此处学习如何使用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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