Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

how to pass info from a main class to Jdialog ???

Posted on 2002-03-17
9
Medium Priority
?
241 Views
Last Modified: 2010-03-31
Situation:
----------
I have a main class that call up a JDialog.
After call the JDialog, the main class should
do some calculation and pass the info to that JDialog so that it can update the TextArea inside it.

My Problem is:
--------------
   After the JDialog is showed on the screen, it is just waiting for the user interaction. The calculation part does not run until I close the JDialog.

Guys, can you help?
0
Comment
Question by:realman1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
9 Comments
 

Accepted Solution

by:
maggari earned 210 total points
ID: 6875959
Write a class which extends JDialog, add a method to that class which does the calculations. Call that method in its constructor.

0
 

Author Comment

by:realman1
ID: 6876067
it doesn't work.

can you give more details
0
 

Author Comment

by:realman1
ID: 6876075
it doesn't work.

can you give more details
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 5

Expert Comment

by:LexZEUS
ID: 6876083
post the code ...
0
 

Author Comment

by:realman1
ID: 6876107
this is the code
*****************

main class
---------------
public class FileDistribute extends JDialog {
      JDialog d;

      public FileDistribute() {
     // code that  pack the dialog - d
     //a JDialog successfully showed on the screen.    

     // now I want to called another JDialog, this d parent dialog will be stayed in the background but disable.
     startDownload();
      }

      private void startDownload() {
       new FtpDownload(d);
      }
}


========================================================
sub dialog
--------------

public class FtpDownload extends JDialog implements ActionListener {
       JDialog dFtpStatus;

       public FtpDownload(JDialog dFileDistribute) {      
          dFtpStatus =  new JDialog(dFileDistribute, "Ftp Status", true);
          showDialog();

          //after showDialog(), I successfully display a sub Dialog - dFtpStatus.
          // the parent d dialog has been disable in the background

          // ***** the following part doesn't work until i close this sub dialog
          System.out.println("after show dialog");
          calculate();

       } //end constructor

        public void showDialog() {
         // code to pack this sub dialog
         //........
            Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
         int w = dFtpStatus.getSize().width;
         int h = dFtpStatus.getSize().height;
         int x = (dim.width-w)/2;
         int y = (dim.height-h)/2;
              dFtpStatus.setBounds(x, y, w, h);
            dFtpStatus.setResizable(false);
            dFtpStatus.setVisible(true);                    
            dFtpStatus.addWindowListener(new WindowAdapter() {
                 public void windowClosing(WindowEvent e) {
                       dFtpStatus.dispose();
               }
            });
     }

        private void calculate() {
          // code to do process some calculation and display on sub Dialog dFtpStatus
     }
}
0
 

Author Comment

by:realman1
ID: 6876119
this is the code
*****************

main class
---------------
public class FileDistribute extends JDialog {
      JDialog d;

      public FileDistribute() {
     // code that  pack the dialog - d
     //a JDialog successfully showed on the screen.    

     // now I want to called another JDialog, this d parent dialog will be stayed in the background but disable.
     startDownload();
      }

      private void startDownload() {
       new FtpDownload(d);
      }
}


========================================================
sub dialog
--------------

public class FtpDownload extends JDialog implements ActionListener {
       JDialog dFtpStatus;

       public FtpDownload(JDialog dFileDistribute) {      
          dFtpStatus =  new JDialog(dFileDistribute, "Ftp Status", true);
          showDialog();

          //after showDialog(), I successfully display a sub Dialog - dFtpStatus.
          // the parent d dialog has been disable in the background

          // ***** the following part doesn't work until i close this sub dialog
          System.out.println("after show dialog");
          calculate();

       } //end constructor

        public void showDialog() {
         // code to pack this sub dialog
         //........
            Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
         int w = dFtpStatus.getSize().width;
         int h = dFtpStatus.getSize().height;
         int x = (dim.width-w)/2;
         int y = (dim.height-h)/2;
              dFtpStatus.setBounds(x, y, w, h);
            dFtpStatus.setResizable(false);
            dFtpStatus.setVisible(true);                    
            dFtpStatus.addWindowListener(new WindowAdapter() {
                 public void windowClosing(WindowEvent e) {
                       dFtpStatus.dispose();
               }
            });
     }

        private void calculate() {
          // code to do process some calculation and display on sub Dialog dFtpStatus
     }
}
0
 

Author Comment

by:realman1
ID: 6876123
I have solve the problem by using Thread.

Thanks guys.
0
 

Author Comment

by:realman1
ID: 6876127
this is the solution:-

main class
---------------
public class FileDistribute extends JDialog {
      JDialog d;

      public FileDistribute() {
     // code that  pack the dialog - d
     //a JDialog successfully showed on the screen.    

     // now I want to called another JDialog, this d parent dialog will be stayed in the background but disable.
     startDownload();
      }

      private void startDownload() {
       new FtpDownload(d);
      }
}


========================================================
sub dialog
--------------

public class FtpDownload extends Thread implements ActionListener {
       JDialog dFtpStatus;

       public FtpDownload(JDialog dFileDistribute) {      
          dFtpStatus =  new JDialog(dFileDistribute, "Ftp Status", true);
          showDialog();

          //after showDialog(), I successfully display a sub Dialog - dFtpStatus.
          // the parent d dialog has been disable in the background

          // ***** the following part doesn't work until i close this sub dialog
          System.out.println("after show dialog");
          calculate();

       } //end constructor

        public void showDialog() {
         // code to pack this sub dialog
         //........

         start();    

            Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
         int w = dFtpStatus.getSize().width;
         int h = dFtpStatus.getSize().height;
         int x = (dim.width-w)/2;
         int y = (dim.height-h)/2;
              dFtpStatus.setBounds(x, y, w, h);
            dFtpStatus.setResizable(false);
            dFtpStatus.setVisible(true);                    
            dFtpStatus.addWindowListener(new WindowAdapter() {
                 public void windowClosing(WindowEvent e) {
                       dFtpStatus.dispose();
               }
            });
     }

        private void start() {
             try
          {
               Thread.currentThread().sleep(500);              
          }
          catch (Exception e)
          {
               System.out.println("thread exception");
          }
          // code to do process some calculation and display on sub Dialog dFtpStatus
          //.....
     }
}          


                   
0
 

Author Comment

by:realman1
ID: 6876154
Just want to say thank you :)
0

Featured Post

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question