问题描述
刚学java怎么通过点击menuItem来打开在另外一个类中的JInternalFrame?packageappmedicine.view;importjava.awt.BorderLayout;publicclassAppMainextendsJFrame{privateJPanelcontentPane;/***Launchtheapplication.*/publicstaticvoidmain(String[]args){EventQueue.invokeLater(newRunnable(){publicvoidrun(){try{AppMainframe=newAppMain();frame.setVisible(true);}catch(Exceptione){e.printStackTrace();}}});}/***Createtheframe.*/publicAppMain(){setTitle("u533Bu836Fu7BA1u7406u7CFBu7EDF");setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);setBounds(100,100,450,300);contentPane=newJPanel();contentPane.setBorder(newEmptyBorder(5,5,5,5));setContentPane(contentPane);contentPane.setLayout(newBorderLayout(0,0));JDesktopPanedesktopPane=newJDesktopPane();contentPane.add(desktopPane,BorderLayout.CENTER);JMenuBarmenuBar=newJMenuBar();contentPane.add(menuBar,BorderLayout.NORTH);JMenumenu=newJMenu("u4FE1u606Fu67E5u8BE2");menuBar.add(menu);JMenuItemmenuItem=newJMenuItem("u67E5u8BE2u987Eu5BA2u4FE1u606F");menuItem.addActionListener(newActionListener(){publicvoidactionPerformed(ActionEvente){JInternalFrametable=newJInternalFrame();}});menu.add(menuItem);JMenuItemmenuItem_1=newJMenuItem("u67E5u8BE2u7ECFu529Eu4EBAu4FE1u606F");menu.add(menuItem_1);JMenuItemmenuItem_2=newJMenuItem("u67E5u8BE2u836Fu54C1u4FE1u606F");menu.add(menuItem_2);JMenumenu_1=newJMenu("u4FE1u606Fu5F55u5165");menuBar.add(menu_1);JMenuItemmenuItem_4=newJMenuItem("u5F55u5165u987Eu5BA2u4FE1u606F");menu_1.add(menuItem_4);JMenuItemmenuItem_5=newJMenuItem("u5F55u5165u7ECFu529Eu4EBAu4FE1u606F");menu_1.add(menuItem_5);JMenuItemmenuItem_3=newJMenuItem("u5F55u5165u836Fu54C1u4FE1u606F");menu_1.add(menuItem_3);JMenumenu_2=newJMenu("u4FE1u606Fu5220u9664");menuBar.add(menu_2);JMenuItemmenuItem_6=newJMenuItem("u5220u9664u987Eu5BA2u4FE1u606F");menu_2.add(menuItem_6);JMenuItemmenuItem_7=newJMenuItem("u5220u9664u7ECFu529Eu4EBAu4FE1u606F");menu_2.add(menuItem_7);JMenuItemmenuItem_8=newJMenuItem("u5220u9664u836Fu54C1u4FE1u606F");menu_2.add(menuItem_8);JMenumenu_3=newJMenu("u4FE1u606Fu4FEEu6539");menuBar.add(menu_3);JMenuItemmenuItem_9=newJMenuItem("u4FEEu6539u987Eu5BA2u4FE1u606F");menu_3.add(menuItem_9);JMenuItemmenuItem_10=newJMenuItem("u4FEEu6539u7ECFu529Eu4EBAu4FE1u606F");menu_3.add(menuItem_10);JMenuItemmenuItem_11=newJMenuItem("u4FEEu6539u836Fu54C1u4FE1u606F");menu_3.add(menuItem_11);JMenumenu_4=newJMenu("u4FE1u606Fu6D4Fu89C8");menuBar.add(menu_4);JMenuItemmenuItem_12=newJMenuItem("u6D4Fu89C8u987Eu5BA2u4FE1u606F");menu_4.add(menuItem_12);JMenuItemmenuItem_13=newJMenuItem("u6D4Fu89C8u7ECFu529Eu4EBAu4FE1u606F");menu_4.add(menuItem_13);JMenuItemmenuItem_14=newJMenuItem("u6D4Fu89C8u836Fu54C1u4FE1u606F");menu_4.add(menuItem_14);JMenumenu_5=newJMenu("u6570u636Eu62A5u8868");menuBar.add(menu_5);JMenuItemmenuItem_15=newJMenuItem("u987Eu5BA2u4FE1u606Fu62A5u8868");menu_5.add(menuItem_15);JMenuItemmenuItem_16=newJMenuItem("u7ECFu529Eu4EBAu4FE1u606Fu62A5u8868");menu_5.add(menuItem_16);JMenuItemmenuItem_17=newJMenuItem("u836Fu54C1u4FE1u606Fu62A5u8868");menu_5.add(menuItem_17);JMenumenu_6=newJMenu("u5E2Eu52A9");menuBar.add(menu_6);}}
JInternalFramepackageappmedicine.view;importjava.awt.EventQueue;publicclassClientMessageextendsJInternalFrame{/****/privatestaticfinallongserialVersionUID=-6807436252773028098L;privateJTextFieldtextField;/***Launchtheapplication.*/publicstaticvoidmain(String[]args){EventQueue.invokeLater(newRunnable(){publicvoidrun(){try{ClientMessageframe=newClientMessage();frame.setVisible(true);}catch(Exceptione){e.printStackTrace();}}});}/***Createtheframe.*/publicClientMessage(){setBounds(100,100,385,254);getContentPane().setLayout(null);JLabellabel=newJLabel("u67E5u8BE2u987Eu5BA2u4FE1u606F");label.setFont(newFont("宋体",Font.BOLD,20));label.setBounds(116,30,136,24);getContentPane().add(label);JLabellabel_1=newJLabel("u8BF7u8F93u5165u987Eu5BA2u7F16u53F7uFF1A");label_1.setBounds(10,67,102,15);getContentPane().add(label_1);textField=newJTextField();textField.setBounds(110,64,128,21);getContentPane().add(textField);textField.setColumns(10);}}