multiple dialogs
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: multiple dialogs

  1. #1
    Join Date
    Dec 2013
    Posts
    26

    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.

  2. #2
    Join Date
    Jun 1999
    Location
    SW Missouri
    Posts
    3,430

    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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center