How to close dialogbox when next thread starts?.

Hello,
For my application, I want to scan an table entries through SNMP connection.The entries are in MIB in a external device.
So, when I press scan button, it will take some time to get the table entries from MIB thro' SNMP protocol.Heres the problem. Till to get datas, the screen get idel.
So, I want to use a Dialog box that displays " you are in scanning mode.Please wait". and this dialog box automatically closed when the user get datas.
How can i fix this problem?.
please, if possible give me the prgram code examples.
Thanks in advance.

public interface ThreadStoppedListener{
public void threadStopped();
public class MyFrame extends JFrame implements ThreadStoppedListener{
   MyDialog dialog;
   private void startProcessing(){
       new Thread(new MyThread(this)).start();
       dialog = new ....;
       dialog.setVisible(true);
   public void threadStopped(){
      dialog.setVisible(false);
public class MyThread implements Runnable{
   ThreadStoppedListener listener;
   public MyThread (ThreadStoppedListener listener){
         this.listener = listener;
  public void run(){
      // do work here
      // when work is done
      SwingUtilities.invokeLater(new Runnable(){
          public void run(){
              listener.threadStopped();
      return;
}Message was edited by:
BaltimoreJohn

Similar Messages

  • When my thread starts running, at that time keylistener is not working.

    when my thread starts running, at that time keylistener is not working.
    plz reply me.

    //FrameShow.java
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    import java.awt.Dimension;
    import java.awt.geom.Dimension2D;
    import java.awt.*;
    import java.awt.image.*;
    import java.awt.event.*;
    import java.util.logging.Level;
    import java.awt.event.*;
    import java.util.*;
    public class FrameShow extends JFrame implements ActionListener,KeyListener
         boolean paused=false;
         JButton stop;
         JButton start;
         JButton exit;
         public IncludePanel CenterPanel;
         public FrameShow()
    CenterPanel= new IncludePanel();
              Functions fn=new Functions();
              int height=fn.getScreenHeight();
              int width=fn.getScreenWidth();
              setTitle("Game Assignment--Santanu Tripathy--MCA");
              setSize(width,height);
              setResizable(false);
              setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              show();
              initComponents();
              DefaultColorSet();
              this.addKeyListener(this);
         this.setFocusable(true);
         public void initComponents()
              Container contentpane=getContentPane();
              //Creating Panel For Different Side
              JPanel EastPanel= new JPanel();
              JPanel WestPanel= new JPanel();
              JPanel NorthPanel= new JPanel();
              JPanel SouthPanel= new JPanel();
              //CenterPanel = new IncludePanel();
              //IncludePanel CenterPanel= new IncludePanel();
              EastPanel.setPreferredSize(new Dimension(100,10));
              WestPanel.setPreferredSize(new Dimension(100,10));
              NorthPanel.setPreferredSize(new Dimension(10,100));
              SouthPanel.setPreferredSize(new Dimension(10,100));
              //CenterPanel.setPreferredSize(new Dimension(200,200));
              //Adding Color to the Panels
              NorthPanel.setBackground(Color.green);
              SouthPanel.setBackground(Color.orange);
              CenterPanel.setBackground(Color.black);
              //Creating Border For Different Side
              Border EastBr = javax.swing.BorderFactory.createEtchedBorder(Color.cyan, Color.red);
              Border WestBr = javax.swing.BorderFactory.createEtchedBorder(Color.cyan, Color.red);
              Border NorthBr = javax.swing.BorderFactory.createEtchedBorder(Color.cyan, Color.red);
              Border SouthBr = javax.swing.BorderFactory.createEtchedBorder(Color.cyan, Color.red);
              Border CenterBr = javax.swing.BorderFactory.createEtchedBorder(Color.cyan, Color.red);
              //Creating Components For East Panel
              JLabel left= new JLabel("LEFT");
              JLabel right= new JLabel("RIGHT");
              JLabel rotate= new JLabel("ROTATE");
              left.setForeground(Color.blue);
              right.setForeground(Color.blue);
              rotate.setForeground(Color.blue);
              //Creating Components For West Panel
              ButtonGroup group = new ButtonGroup();
              JRadioButton rb1 = new JRadioButton("Pink",false);
              JRadioButton rb2 = new JRadioButton("Cyan",false);
              JRadioButton rb3 = new JRadioButton("Orange",false);
              JRadioButton _default = new JRadioButton("Black",true);
              rb1.setForeground(Color.pink);
              rb2.setForeground(Color.cyan);
              rb3.setForeground(Color.orange);
              _default.setForeground(Color.black);
              //Creating Components For North Panel
              JLabel name= new JLabel("Santanu Tripathy");
              name.setForeground(Color.blue);
              name.setFont(new Font("Serif",Font.BOLD,30));
              //Creating Components For South Panel
              start = new JButton();
              stop = new JButton();
              exit = new JButton();
              start.setToolTipText("Click this button to start the game");
              start.setFont(new java.awt.Font("Trebuchet MS", 0, 12));
              start.setText("START");
              start.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEmptyBorder(3, 5, 3, 5), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)));
              start.setMaximumSize(new java.awt.Dimension(90, 35));
              start.setMinimumSize(new java.awt.Dimension(90, 35));
              start.setPreferredSize(new java.awt.Dimension(95, 35));
              if(paused)
                   stop.setToolTipText("Click this button to pause the game");
              else
                   stop.setToolTipText("Click this button to resume the game");
              stop.setFont(new java.awt.Font("Trebuchet MS", 0, 12));
              stop.setText("PAUSE");
              stop.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEmptyBorder(3, 5, 3, 5), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)));
              stop.setMaximumSize(new java.awt.Dimension(90, 35));
              stop.setMinimumSize(new java.awt.Dimension(90, 35));
              stop.setPreferredSize(new java.awt.Dimension(95, 35));
              exit.setToolTipText("Click this button to exit from the game");
              exit.setFont(new java.awt.Font("Trebuchet MS", 0, 12));
              exit.setText("EXIT");
              exit.setBorder(javax.swing.BorderFactory.createCompoundBorder(javax.swing.BorderFactory.createEmptyBorder(3, 5, 3, 5), javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED)));
              exit.setMaximumSize(new java.awt.Dimension(90, 35));
              exit.setMinimumSize(new java.awt.Dimension(90, 35));
              exit.setPreferredSize(new java.awt.Dimension(95, 35));
              //Adding some extra things to the Panels
              group.add(rb1);
              group.add(rb2);
              group.add(rb3);
              group.add(_default);
              //Adding Component into the Panels
              EastPanel.add(left);
              EastPanel.add(right);
              EastPanel.add(rotate);
              WestPanel.add(rb1);
              WestPanel.add(rb2);
              WestPanel.add(rb3);
              WestPanel.add(_default);
              NorthPanel.add(name);
              SouthPanel.add(start);
              SouthPanel.add(stop);
              SouthPanel.add(exit);
              //Adding Border Into the Panels
              EastPanel.setBorder(EastBr);
              WestPanel.setBorder(WestBr);
              NorthPanel.setBorder(NorthBr);
              SouthPanel.setBorder(SouthBr);
              CenterPanel.setBorder(CenterBr);
              //Adding Panels into the Container
              EastPanel.setLayout(new GridLayout(0,1));
              contentpane.add(EastPanel,BorderLayout.EAST);
              WestPanel.setLayout(new GridLayout(0,1));
              contentpane.add(WestPanel,BorderLayout.WEST);
              contentpane.add(NorthPanel,BorderLayout.NORTH);
              contentpane.add(SouthPanel,BorderLayout.SOUTH);
              contentpane.add(CenterPanel,BorderLayout.CENTER);
              //Adding Action Listeners
              rb1.addActionListener(this);
              rb2.addActionListener(this);
              rb3.addActionListener(this);
              _default.addActionListener(this);
              exit.addActionListener(this);
              start.addActionListener(this);
    try
              start.addActionListener(
    new ActionListener() {
    public void actionPerformed( ActionEvent e )
                        start.setEnabled(false);
    CenterPanel.drawCircle();
    catch(Exception e)
    {System.out.println("Exception is attached with sart button exp = "+e);}
    try
              stop.addActionListener(
    new ActionListener() {
    public void actionPerformed( ActionEvent e )
                        paused=!paused;
                        if(paused)
                             start.setToolTipText("Click this button to resume the game");
                             stop.setText("RESUME");
                        else
                             start.setToolTipText("Click this button to pause the game");
                             stop.setText("PAUSE");
    CenterPanel.pause();
    catch(Exception e)
    {System.out.println("Exception is attached with sart button exp = "+e);}
         public void DefaultColorSet()
              getContentPane().setBackground(Color.white);
         public void actionPerformed(ActionEvent AE)
              String str=(String)AE.getActionCommand();
              if(str.equalsIgnoreCase("pink"))
                   CenterPanel.setBackground(Color.pink);
              if(str.equalsIgnoreCase("cyan"))
                   CenterPanel.setBackground(Color.cyan);
              if(str.equalsIgnoreCase("orange"))
                   CenterPanel.setBackground(Color.orange);
              if(str.equalsIgnoreCase("black"))
                   CenterPanel.setBackground(Color.black);
              if(str.equalsIgnoreCase("exit"))
                   System.exit(0);
         public void keyTyped(KeyEvent kevt)
    //repaint();
    public void keyPressed(KeyEvent e)
              System.out.println("here key pressed");
              //CenterPanel.dec();
         public void keyReleased(KeyEvent ke) {}
    }//End of FrameShow.ja
    //IncludePanel.java
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.image.*;
    import java.awt.Graphics.*;
    import java.awt.Dimension;
    import java.awt.geom.Dimension2D;
    import java.util.*;
    import java.util.logging.Level;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.event.*;
    public class IncludePanel extends JPanel implements Runnable
    int x=0,y=0;
    int color_1=0;
    int color_2=1;
    int start=0;
    Thread th;
    Image red,blue,green,yellow;
    java.util.List image;
    static boolean PAUSE=false;
         public IncludePanel()
         red= Toolkit.getDefaultToolkit().getImage("red.png");
         blue= Toolkit.getDefaultToolkit().getImage("blue.png");
         green= Toolkit.getDefaultToolkit().getImage("green.png");
         yellow= Toolkit.getDefaultToolkit().getImage("yellow.png");
    public void paintComponent(Graphics g)
              super.paintComponent(g);
              draw(g);
    public void dec()
         System.out.println("in dec method");
         x=x+30;
    public void draw(Graphics g)
              g.setColor(Color.red);
              int xx=0,yy=0;
              for (int row=0;row<=12;row++)
                   g.drawLine(xx,yy,180,yy);
                   yy=yy+30;
              xx=0;
              yy=0;
              for (int col=0;col<=6;col++)
                   g.drawLine(xx,yy,xx,360);
                   xx=xx+30;
              if(color_1==0)
                   g.drawImage(red, x, y, this);
              else if(color_1==1)
                   g.drawImage(blue,x, y, this);
              else if(color_1==2)
                   g.drawImage(green,x,y, this);
              else if(color_1==3)
                   g.drawImage(yellow,x,y, this);
    x=x+30;
              if(color_2==0)
                   g.drawImage(red, x, y, this);
              else if(color_2==1)
                   g.drawImage(blue,x,y, this);
              else if(color_2==2)
                   g.drawImage(green,x,y, this);
              else if(color_2==3)
                   g.drawImage(yellow,x,y, this);
    x=0;
    public void drawCircle( )
         th=new Thread(this);
         th.start();
         public void pause()
              if(PAUSE)
                   th.resume();
                   PAUSE=false;
                   return;
              if(!PAUSE)
              PAUSE=true;
         public synchronized void run()
              Random rand = new Random();
              Thread ani=Thread.currentThread();
              while(ani==th)
                   if(PAUSE)
                        th.suspend();
                   if(y==330)
                        color_1 = Math.abs(rand.nextInt())%4;
                        color_2 = Math.abs(rand.nextInt())%4;
                        if(color_1==color_2)
                             color_2=(color_2+1)%4;
                        y=0;
                   else
                        y=y+30;
                   repaint();
                   try
                        Thread.sleep(700);
                   catch(Exception e)
         }//End of run
    i sent two entire program

  • Windows XP gives message "BlackBerry Desktop Software has encountered a problem and needs to close." when trying to start Desktop Manager

    I apologize if this issue has already been handled in others' posts; I just can't locate my specific issue, and I'm a newbie with this.
    I first encountered the Windows crash shown in subject yesterday when trying to sync my Blackberry. Message is displayed after the program churns for awhile, but hasn't even detected a remote device or shown that it is doing any work.
    I vaguely recall agreeing to an update a few days back.  Perhaps Windows has updated recently as well? 
    I have uninstalled and installed most recent Desktop version several times, rebooting in between.  I have tried installing original version as well - Desktop at least starts then, but bombs before syncing anything.  I also have rolled back my Windows system to before last Windows update.
    Here is the error message that I believe is associated with this problem:
    Sunday, December 26, 2010
    .NET Runtime 2.0 Error Reporting
    EventType clr20r3, P1 rim.desktop.exe, P2 6.0.1.18, P3 4cfdab9c, P4 microsoft.practices.composite, P5 2.0.1.0, P6 4c58abaf, P7 12b, P8 50, P9 sclhiaanmqhkf4zdfpvvwejkphn1z uj, P10 NIL.
    Thanks in advance for any help you can provide.

    Bold 9650 running on Windows XP
    I finally solved my problem with blackberry desktop manager 6.0.1 by going bck to 6.0 version and here is how I did it, since the 6.0 version is not available on blackberry's website or on a disk and I have spent over 30 hours with BB tech support all to no avail in fixing 6.0.1 and enabling it to open.
    1) Removed any Blackberry desktop software from my computer via the  add/remove program in the control panel.  No need to deal with a clean uninstall in terms of registry cleaner, etc.
    2) Installed 6.0 which i was lucky enough to have backed up the intallation files from several months ago when I backed up my entire system to an external drive. 
    3) Opened BB desktop mananager and connected my device and configured my sysn with outlook and all worked out. 
    If anyone needs BB Desktop Manager 6.0 to go back to a version that once worked for you, please let me know and I will email it to you via yousendit.com since it is a 95mb file.
    -Marty

  • How to close sidebar when reading mail

    when reading mail in iPad i am unable to close the sidebar which shows emails accounts and inbox.

    This is to "art3410" --
    That's exactly how it was designed to work. If you want to suggest a different method to Apple, then do so here ...
    Product Feedback
    https://www.apple.com/feedback/

  • Why doesn't firefox close out when I'm done with it and close it; when next I try to open firefox again I get a dialog box telling me firefox is open and to close it or restart my computer? I'm tired of doing that one of more times a day.

    1. This happens at least once a day, and sometimes multiple times. Today it's happened twice, thus far. My home page is FoxNews.com and if I leave it up overnight or for longer periods during the day firefox doesn't allow the refresh of the home page it just goes to yahoo 404--error can't find the webpage. Then when I enter FoxNews.com it adds a /error to the url and doesn't allow me to go to MY homepage. So I close firefox and then if I try to reopen it and then I get the dialog box saying firefox is open and to close it or restart my computer. Very aggravating. 2. Also the Adobe flash drive update always fails. 3. Webpages get in loops and fail to load to the point I have to stop and refresh or close out and reopen.

    One situation in which Command+w or Ctrl+w might not work is if the "focus" is in a plugin such as the Flash player used on Youtube after you interact with the player controls. Firefox will continue to send the keyboard input to the plugin until you move the focus back to the page. Does that account for any of the problem?

  • How to close statement when calling in chain sequence

    Hi all,
    just have a look on below code:
    java.sql.connection con =null;
    //here getting connection
    ResultSet rs= con.createStatement().executeQuery("sql");
    its similer to chaining pattern. here I am having question,
    with the line:
    con.createStatement()
    I am creating the statement and later using this object (which is implicit object as i m not having any futher reference of it, is it correct word which i used) i am executing query and getting result set object.
    here statement object is implicit object.
    is I need to close this object? As per me its too required and i can retrived statement object with the help of resultset object and can use close method.
    but what does the java best pratice say? how they handle objects which are created in chain calling.
    for example
    //this.getPatternCode().getProperty().getName()
    thanks,
    Pax

    In short : stop doing this, it's a bad idea.
    You must always close all your resultsets, statements and connections._ Anyone who tells you anything different is wrong. End of story. Failure to properly close JDBC resources can lead to any number of problems including having your program crash and/or having the database crash.
    So stop doing that.
    There is only one correct practice and it is what is below.
    Create the connection and keep a reference to it.
    Create the statement (this can be a PreparedStatement or CallableStatement as well) using the connection and keep a reference to it (the statement).
    Create the result set using the statement.
    Process as needed.
    Close the resultset in a finally block.
    Close the statement in a finally block
    Close the connection in a finally block.

  • How can i control when my animation starts/stops with external JS

    I am making a web app that will allow you to go through "pages" by clicking and dragging or sliding your finger (touch devices).
    I am wanting to make a seperate animation on Edge for each page and play it when the current page is on witht the relevant edge comp.
    So far my code allows me to know what page is being viewed and that the animation should be played, however I can not figure out how to play the comp.
    ie.
    WHEN page = 1, play composition "page1".
         If currentPage is not currentPage, stop composition "page 1".
    Please could you help me as I've been racking my brain all day to figure this out.

    Hi,
    You'll find a tutoriel here.
    Then, example #1 and example #2.

  • How stop ambient sound when video sound starts?

    I play ambient background music in my movie. I've written
    Actionscript to attach an mp3 and control the overall sound volume.
    The code to control the overall sound is:
    _global.allSounds = new Sound ();
    _global.allSounds.setVolume(50); for example
    However, in my movie there are also video clips (w/sound)
    that I have embedded using the FLVPlayback component and one of the
    designer skins. The problem? I don't know how to stop the ambient
    music when the user clicks the "Play" button on the skin. Both the
    ambient sound and video sound play at the same time creating a
    cacophony. And if the user happens to click the "mute" button on
    the skin, my _global.allSounds.setVolume() commands have no effect.
    How do I integrate the way sound is controlled by
    Actionscript vs. the way it is controlled by video components?
    Thanks.

    The obvious answer would be: remove the Beep VI that's probably in there. Please show us your code.

  • How do you time when 2nd mp3 starts playing

    I have a client who built a Java app to compose music tracks.
    They have mp3 files broken down into segments (intro, verse,
    chorus, turnaround, etc) that the user can piece together to form
    complete songs.
    My job is to find a way to preview their selections in a
    Flash player. Their Java app does a great job at building the
    composed mp3's, but they still need a way to preview their
    selections when the user is composing.
    So far I've been unable to get the mp3's to playback
    seamlessly. I've tried to preload progressive downloads and I've
    tried streaming. I can get the mp3's to preload but I can't get the
    player to play them without a pause.
    Any ideas?

    I don't think Flash is the way to go here. I'd stick with
    Java and if necessary look at a 3rd party sound tool for Java's
    API.
    In order for Flash to play the sound like you want, you need
    Java to have created a temp file of the current composition. This
    file would not be a break down of the individual parts but a
    rastered final of the current state of the comp. If you can get it
    this far, my question would be why would you need Flash? If Java
    can raster the separate tracks together, why can't you save the
    comp into memory and build a sound player in Java that previews the
    selection?
    Is there more to the project that you aren't
    explaining?

  • HT4993 How to close apps.

    How to close apps when your done.

    Double Tap Home Button (Round Circle Button on the Bottom of the Screen)
    Tap + Hold on an App (You will only see 4 at the bottom) till it shakes
    Tap the Red Circle with the White " - " to close the open Apps

  • When playing songs in iTunes playlist, How do you keep the next song from jumping to next song? I am working on song list updating other tracks info and then the next song starts and I lose my spot in song list?

    When playing songs in iTunes playlist, How do you keep the next song from jumping to next song? I am working on song list updating other tracks info and then the next song starts and I lose my spot in song list?

    Max OSX 10.6.8, iTunes 11.1
    I had a similar problem: I wanted to synch my playlist to my iphone. I like to have my playlist sorted by genre. But under each genre, albums are not sorted by the track numbers. This is a problem, especially when I am listening to club mixes when the DJ smoothly transitions from 1 track sequentially to the next one. Under the properties of each audio file, the Track Numbers and Disc Numbers are already there.
    My perfect solution was to turn On Sorting - Sort Album under View>Show View Options. Then, select all the songs in that album (Shift click, Cmd click, etc) , and Edit multiple item information (Cmd I). You will see Info-Video-Sorting-Options buttons. Click on Sorting. Then, under Sort Album, Enter the name of the album. Then OK.
    You should now have the playlist sorted by Genre, then each album individually sorted by track numbers. On your playlist you should see, if you scroll right, the column added called "Sort Album".
    Hope this helps.

  • Every time I change my home page then close Firefox, when I start it up again, my new home page is replaced by a search window...how do I change my home page?

    In prior versions of Firefox I had three tabs pop up when I started the program. I load the addresses for those same three tabs into my home page setting under options...close Firefox...then start it up again and the tabs don't get saved. Not sure where I'm going wrong...this process worked in earlier versions.

    After trying many of the suggestions found online I found that the only thing that worked was to completely uninstall firefox and re-install it again!

  • How to stop an app from auto starting when signing on?

    how to stop an app from auto starting when signing on?

    Several point :
    1st : do you select "auto relaunch" application when you close ML last time? don't do that next time
    2nd : in system preferences/Users and Groups look at applications that are selected for automatic opening. You can remove application. Tab called "Open At Login"
    3rd : have a look at /Library/LaunchDeamons/
    4th : buy Lingon
    Hope it can help

  • How can i disable imessage from automatically starting up when i turn on macbook air?

    how can i disable imessage from automatically starting up when i turn on macbook air? i dont know my imessages to pop up on my laptop when it turns on. But i dont want to disable imessage totally on my macbook.

    Welcome to the Apple Support Communities
    First of all, check that Messages is closed when you turn off your MacBook. This is so important because, by default, OS X will reopen all opened apps the next time you start your Mac.
    Apart from that, when you go to  > Shut Down, or  > Restart, in the window you see to restart or turn off your MacBook, unmark "Reopen windows when logging back in". This will avoid that your Mac opens all opened apps the next time you start the MacBook, so Messages won't start automatically at startup

  • When I close Firefox, then later want to start up again, I get I message that Firefox is still running. With "START TASK MANAGER", I need to close Firefox in order to start again.

    When I close Firefox, then later want to start up again, I get I message that Firefox is still running. With "START TASK MANAGER", I need to close Firefox in order to start again.

    I have the same problem. Firefox won't unload regardless of how long I wait. Literally hours ... I must go in and 'end the process'. This has been a real hassle for a while now. Even considered giving up on firefox. Please look into this! An additional problem; I have to run firefox to get the updates, but I can't get the updates to take because I can't get firefox to unload so I can restart it.

Maybe you are looking for