Solved

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

Posted on 2002-03-17
9
238 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 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
hibernate insert example 13 37
How to determine if a string is a valid SHA value 7 43
eclipse console opening separately 2 35
SequenceInputStream example 3 21
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

740 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