how to call main frame from showMessage OK button clicked?.

hello,

I create one project. there, I create one textfield and button. after clicking it, the input add into JList.

when I click the list component and enter OK button ,it will go to another window.

When the input is fault, it show error in dialog box. then, when i click the OK button, it must go to main window and processed from first.

My problem is,

When I click OK in show dialog box, it is not going to main frame.

if((source==ConnectButton) != firstSel)

{

String message="Not Able to Connect to the Specified IP !!!";

int answer = JOptionPane.showConfirmDialog(MainFrame.emsMainFrame, message);

if (answer == JOptionPane.YES_OPTION){

initcomp();

MainFrame.setSize(750, 550);

// Image icon = Toolkit.getDefaultToolkit().getImage("Images.gif");

//emsMainFrame.setIconImage(icon);

emsMainFrame.setVisible(true);

emsMainFrame.setEnabled(true);

initSNMPlogin();

// BroIPSelect.setVisible(true);

// BroIPSelect.setEnabled(true);

//--

// workPanel.add();

//JPanel cp = new JPanel(new GridLayout(0,3));

workPanel.setVisible(true);

workPanel.add(new JLabel("work" ) );

// leftPanel.setVisible(true);

//-

}

elseif (answer == JOptionPane.NO_OPTION){

// User clicked NO.

System.exit(0);

}

To go to main frame and access , what can I do.

thanks.

[2255 byte] By [rameshsa] at [2007-11-26 12:59:36]
# 1

Wow that's a mess.

Normally when you want to go back to your main window, the only thing you have to do is hide your second window. Then the focus automatically returns to your main window.

Hiding a frame is calling setVisible(false) on it.

If you keep a reference somewhere to your hidden frame, you can easily show it up again without rebuilding it.

But post some other code.

What is "MainFrame"?

Is it a class with static methods for accessing MainFrame.emsMainFrame?

Note that objects/instances/variables/references should start with a lowercase letter, and classes should start with an uppercase letter.

Why do you call initcomp()? If it is a function for initialising the GUI components, then make it run once at the start of your program.

Why do you have this XOR:

((source==ConnectButton) != firstSel)

tom_jansena at 2007-7-7 16:58:53 > top of Java-index,Desktop,Core GUI APIs...