Solved

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

Posted on 2002-03-17
9
237 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
  • 7
9 Comments
 

Accepted Solution

by:
maggari earned 70 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
servlet requestdispatcher include and forward differences 1 39
how to add new optional parameter to JSP 1 49
eclipse console opening separately 2 29
Setup GlassFish 4 22
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

828 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