Enable-Disable JMenu from JInternalFrame
Hi
In many attempts for to call a method inside a JFrame from a InternalFrame named Login for to Enable-Disable a JMenu i never can get the goal.
Basically i need to use a InternalFrame for to manage JMenuItems in my Java App(JFrame).
Can us comment about what is the better way for to solve this problem?
THIS IS THE InternalFrame Login
public class Login extends JInternalFrame {
public Framework framework;
public Login(){
initComponents();
}
public void initComponents() {
...
...
...
pack();
}
public void jButton_closeActionPerformed(ActionEvent evt){
dispose();
}
public void jbutton_okActionPerformed(ActionEvent evt){
EnableMenu();
}
public void EnableMenu(){
framework = new Framework();
framework.EnableJMenuItems();
}
public String user,pass;
public JLabel jlabel_user,jlabel_pass;
public JTextField jtextfield_user;
public JPasswordField jPasswordField1;
public JButton jButton_close,jbutton_ok;
}
THIS IS THE Main JFrame App
public class Framework extends JFrame {
public JMenu menu1;
public JMenu menu2;
public JMenu menu3;
public JMenu menu4;
public Framework() {
super(":: Tester Connection ::");
setSize(1024,750);
Image imagen,imageicon;
Toolkit test=Toolkit.getDefaultToolkit();
imageicon=test.getImage("");
setIconImage(imageicon);
icon = new ImageIcon("icons\\br.png");
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
desktop = new JDesktopPane();
setJMenuBar(createMenuBar());
getContentPane().add( desktop, BorderLayout.CENTER);
getContentPane().add( createToolBar(), BorderLayout.NORTH) ;;
desktop.putClientProperty("JDesktopPane.dragMode", "outline");
desktop.setBackground(Color.white);
}
public JMenuBar createMenuBar(){
...
...
...
}
public void EnableJMenuItems(){
try{
menuItem3.setEnabled(false);
}catch(Exception e){System.out.println(e); }
}
public void createFrameLogin() {
Login frame = new Login();
frame.setSize(420, 320);
frame.setOpaque(false);
try {
frame.setSelected(true);
} catch (Exception e) {
}
desktop.add(frame);
frame.show();
}
public static void main(String[] args) {
Framework frame = new Framework();
frame.setVisible(true);
}
}