Solved

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

Posted on 2002-03-17
9
240 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
Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

 
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

626 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