-
July 18th, 2014, 09:27 PM
#1
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
Last edited by soheil2; July 18th, 2014 at 09:32 PM.
-
July 19th, 2014, 08:27 AM
#2
Re: multiple dialogs
Norm
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|