-
multiple dialogs
Hello.
I have two dialogues: one name "dialog" and another named "queryDialog". Each dialog has one button among other things and they are supposed to make their respective dialogues hide when clicked. But the second button doesn't work.Here is my code:
Code:
import java.io.*;
import java.util.*;
import java.util.concurrent.TimeUnit;
import com.sun.management.OperatingSystemMXBean;
import java.lang.management.ManagementFactory;
import java.lang.System;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
public class SysinfoHooshi implements ActionListener{
..
JDialog dialog = new JDialog();
JButton button = new JButton("OK");
/****************Query dialog variables*******************/
JDialog queryDialog = new JDialog();
JButton queryButton = new JButton("OK");
...
/*********************************************************/
public void simulate()throws Exception{
this.showDialog();
...
showQueryDialog();
}//end simulate()
public void showDialog()
{
dialog.setModal(true);
dialog.setSize(400, 150);
dialog.setTitle("Input dialog");
Container pane = dialog.getContentPane();
pane.setLayout(null);
...
pane.add(button);
button.addActionListener(this);
button.setBounds(100,100,80,30);
dialog.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
dialog.setVisible(false);
System.out.println("Here1");
}
public void showQueryDialog()
{
queryDialog.setModal(true);
queryDialog.setSize(400, 150);
queryDialog.setTitle("Query dialog");
JPanel queryPane = new JPanel();
queryPane.setLayout(new FlowLayout());
...
queryPane.add(queryButton);
queryDialog.add(queryPane);
queryDialog.setVisible(true);
...
queryButton.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e)
{
queryDialog.setVisible(false);
System.out.println("Here2");
}
}
);
}
..
public static void main(String args[]) throws Exception{
SysinfoHooshi o = new SysinfoHooshi();
o.simulate();
} // end main
}// end class
Where have I gone wrong?
I tried to follow the example of http://stackoverflow.com/questions/5...-in-java-swing
Thanks in advance
-
Re: multiple dialogs