Results 1 to 4 of 4
  1. #1
    vknehra10 is offline Senior Member
    Join Date
    Dec 2016
    Posts
    103
    Rep Power
    0

    Default Swing with Thread is it possible ?

    Java Code:
    import java.io.*;
    import javax.swing.*;
    import  java.awt.*;
    
    
    public class test implements Runnable{
    public test(){
            JFrame jn=new JFrame("tes");
            
    
    	   
    	    jn.setBounds(400,200,400,400);
    	jn.setDefaultCloseOperation(jn.EXIT_ON_CLOSE);
    	jn.setLayout(null);
    	jn.setVisible(true);
    
    
    
    
    
    }
    
    
    public void run(){
    
    Thread.sleep(10000);
    jn.dispose();
    
    
    }
    
    
    
    
    public static void main(String Dev[]){
    test ts=new test();
    Thread t=new Thread(ts);
    t.start();
    
    
    }
    }
    i want to run "jn.dispose" with thread is it possible....

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    6,226
    Rep Power
    13

    Default Re: Swing with Thread is it possible ?

    Did it do what you expected or wanted?

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  3. #3
    vknehra10 is offline Senior Member
    Join Date
    Dec 2016
    Posts
    103
    Rep Power
    0

    Default Re: Swing with Thread is it possible ?

    i want to create a thread for 10seconds after 10seconds my program show a dialog box that's it...

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    13,541
    Rep Power
    26

    Default Re: Swing with Thread is it possible ?

    At the moment the above code looks like it will display a frame and, after 10 seconds, get rid of it.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. JOptionPane blocking the Swing thread...?
    By kjkrum in forum AWT / Swing
    Replies: 4
    Last Post: 10-07-2013, 07:47 PM
  2. Swing GUI Thread Error?
    By dharav in forum New To Java
    Replies: 3
    Last Post: 01-18-2012, 06:02 PM
  3. Thread v swing timer
    By musico in forum New To Java
    Replies: 1
    Last Post: 06-23-2011, 09:51 PM
  4. Prompt for value in swing thread
    By dataphile in forum Threads and Synchronization
    Replies: 1
    Last Post: 12-05-2010, 12:50 AM
  5. JComboBox ActionListener and Swing Thread safety
    By frenk_castle in forum AWT / Swing
    Replies: 6
    Last Post: 04-05-2010, 10:02 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •