Program freezes when a thread is run in another class.

I have a class that extends Thread, and then I have a GUI that needs this thread.
The thread class looks like this:
public class ScoreboardCheck extends Thread
    private int clock;
    private boolean running;
    public ScoreboardCheck(int timeOnClock)
        super();
        this.clock = timeOnClock;
        running = false;
    public int getClock()
        return this.clock;
    public void toggleRunning()
        if (running == false)
            running = true;
        else
            running = false;
    public void run()
        while (Thread.currentThread() == this)
            if (running == true)
                try
                    Thread.sleep(1000);
                    clock--;
                catch(InterruptedException ie)
                    ie.printStackTrace();
}This is suppose to update the clock on the GUI. I instantiate the thread in the GUI class, and call start on it. This works fine, but whenever I call run, it freezes up....Either way it never does anything.
In the GUI class, how am I suppose to continously update the clock without this thing freezing up? I've tried implementing runnable in the GUI class, but that didn't work.

Thanks for the replies, guys.
When I call start it doesn't freeze. That's good. The only other problem I'm faced with, is updating the GUI probably every second. I've tried using a run method in the GUI which runs while true, but that froze things up....This is the point I'm stuck at. For now, I'm going to try what someone suggested: the Timer class. Is there another way of doing this though? Without the timer?

Similar Messages

  • Windows CS3 Programs Freeze When Opening Files

    Windows CS3, all programs freeze when trying to open files by going through the file menu.
    Able to open files when navigating with windows explorer then right clicking on file and choosing "open with"
    Windows XP Professional SP3, 4 Gb Ram Quad Core Processor.
    Have uninstalled and reinstalled CS3 (Design Premium)
    Have deleted photoshop settings file and tried using photoshop.
    Any time I try to open a new file or existing file by going through the file menu the program freezes and must be terminated using the task manager.

    Erika,
    I wish you had posted that last night. LOL I'm glad it worked for you and I will tell anyone who has this problem to try that before they try my fix. I was starting to have other problems like inDesign corrupting images.
    Here's how I fixed it,
    I DO NOT RECOMMEND THIS UNLESS YOU ARE WILLING TO RISK HAVING TO REFORMAT YOUR PC.
    1. Backup entire pc
    2. Deactivate Creative Suite 3 (or whatever application you are having a problem with)
    3. Uninstall problem application or suite, then uninstall everything by adobe.
    4. Search PC for all folders and files with "adobe", no quotes, in the name.
    5. Delete all folders and files with "adobe", no quotes, in the name.
    6. Restart PC
    7. Run ccleaner and also run the registry fix.
    8. Restart PC.
    9. Backup registry.
    10. Scan registry for "adobe", no quotes. Delete every instance of "adobe", no quotes making sure the reference is truly "adobe" and not something else.
    11. Restart PC.
    12. Install adobe suite or application.
    13. Install any other adobe application you may need.
    Worked for me, but
    I DO NOT   RECOMMEND THIS UNLESS YOU ARE WILLING TO RISK HAVING TO REFORMAT YOUR PC.

  • How to deal with the mouse events when the thread is running

    Hi everybody,
    I have a problem with my program.
    Now I want to present a picture for some time in the Canvas,then automatically clear the screen, but when the user press the mousebutton or keybutton, I want to stop the thread and clear the screen.
    How can I receive the mouse event when the thread is running?
    Thanks,

    I use my code in a GUI applet.
    I try to use the code tag, it's the first time.
                   Image im=sd.getStimulus(obj);
                   if(pos==null){
                        g.drawImage(im, (w-im.getWidth(null))/2,(h-im.getHeight(null))/2,null);
                   }else{
                        g.drawImage(im, pos.x,pos.y,pos.w,pos.h,null);
                   try{
                        sleep(showtime);
    //                    Thread.sleep(showtime);
                   }catch(InterruptedException e){}
                   if(pos==null){
                        g.clearRect((w-im.getWidth(null))/2,(h-im.getHeight(null))/2,im.getWidth(null),im.getHeight(null));
                   }else{
                        g.clearRect(pos.x,pos.y, pos.w, pos.h);
                   }

  • Program freezes when adding text to clip

    Hi,
    I have sent a 40 minute slideshow to PE7. I am splitting the slide show at various points and inserting short video clips. After having added text to both photos and video two or three times, I now find that the program freezes when I either try to add further text or even if I try to edit previously inserted text.
    Has anyone a solution to this please?
    Thanks
    Jim
    P.S. the reason I am adding video to the slide show and not the other way around is that I like the pan and zoom facility of the slide show which is not available as a transition in PE7.
    Apparently I cannot add video clips to slide shows in PSE 7 - or at least not more than 5 seconds of video at a time.

    Hi, Thanks for you reply.
    The photos are between 1 to 3 MB each if thats any help, My Sony Handycam was set to 16:9 format but I can't select this in Project preferences which seems fixed at 4:3. The point is that I have used photos of this size in a project containing both photos and video previously without problems. I have not tried to splice video footage into an imported slide show before.
    I will investigate further later.
    Thanks again
    Jim

  • 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

  • Program freezes when used through ext. hd...

    So, I upgraded, blah blah blah.
    However, after struggling to get Classic back on here, which I finally did...
    Now, my Microsoft 98 and Microsoft Office for OS X both freeze when I am editing a document or after I've printed it or something. It takes a few minutes but it eventually beach balls.
    Then I try to Force Quit, which then doesn't work right away at all for some reason. Then I try to do something in Finder then finder starts to beach ball. So annoying. So after a while it will say if I want to continue to force quit even though Word isn't logging out and I click continue but still it's all so strange!
    So, finally it dawned on me to drag the Microsoft OS X folder to my desktop. So it copies, then I eject my ext. hd... Then when I use the Word app. running through my int. hd, then it works.
    Anyone know what could be the deal? I don't want this to be a sign that my LaCie is going to die soon... But if it is I need to know.

    I noticed that no matter what program or even file I was using through my hard drive it would freeze. So I repaired permissions and the disk and it seems okay for now...

  • 5200 T128. my computer freezes when i try to run games

    OK.. the thing is:  i just bought a Geforce FX 5200 T128, with 128 MB DDR (the one without a cooling fan), and when i try to run my DirectX 9 games (GTA: Vice city, NFS: Underground, Hitman: Contracts) my computer locks up in the game's loading screen. These lock-ups occur also, when i set the anisotropic filtering at values higher than 2x, and/or when i turn the V-sync on, but only when i start a game..
       ALSO...... the same lock-up occurs when i try to RENAME A FILE ------- the cursor is still blinking, but EVERYTHING else freezes.
          So? whats up guys.... last time i checked the FX 5200 had support for DX9, didn't it?
          Well, i can't tell exactly if the problem is common to all DX9 games, because i didn't tryed many of them... but the games listed above, all require DX9. Furter more, those games ran on my older Geforce2 MX400, witch doesn't have support for DX9. All my other non DX9 games work fine (well not to the max, because i still have a mainboard witch supports only AGP 4x). If i change my mainboard to one with AGP 8x will the problem be solved?
         Also, the videocard, out of my opinion, gets  too hot after i play a game, but i don't think this should be the problem, because when i try to start those games, my computer still locks up, even though i just started it, and the videocard didn't have time to overheat.
          The problem occurs with both the driver from the CD that came with the card, and the new Forceware 56.72. I haven't tryed oder drivers. The videocard is not overclocked, and the frequencies are on the standard 200 Mhz (GPU), and 400 Mhz (RAM)
          So, can you help me out here.. give me some suggestions? I have written here all the information i beleive are relevant to the problem. My processor is a 1200 Mhz AMD Duron, and 256 MB SDRAM
    -------------  -------------

    Obi One,
    Have you tried changing the AGP voltage in your bios to 1.6V?  Got the same problem before when running 3D games.  My system doesn't lock up but it gives me weird display (lot of greens).  It was solved when I increased my AGP voltage setting from 1.5V to 1.6V.  You may want to post your power supply specs too because the FX cards are really power hungry.
    Good Luck  

  • CS5 programs freeze when opening documents (OSX Mavericks)

    Hi all,
    Just curious if anyone else is having this issue. After installing Mavericks, now any document I attempt to open in an adobe program freezes for a very long time before it opens. It could even be a tiny 72 dpi image that I try to open in Photoshop. It is also having some plugin issues when trying to open documents on a network. Is anyone else having this issue?
    Thanks,
    Anthony

    Hi Sebastian,
    Thanks for the help! Unfortunately by the time I saw this I had already reformatted the computers having the issue and reinstalled an earlier OS. I will definitely try this out if it happens again though!
    - Anthony

  • Problems with iPhone freezing when trying to answer while on another call?

    I am wondering if others are having the problem with your iPhone freezing when you are on a call and another calls comes in. I have had this problem repeatedly. If I try to answer a call while on another call, the other caller can not hear me. when I try and hang up the call...iPhone freezes and disconnects ALL calls.
    I do not have a problem if I initiate BOTH calls for a conference call. I am hoping that Apple is aware of this issue and are working on a fix in the next update. Whenever that will be???
    Oh well, if you are having this problem and know how to fix it...please let me know. Thanks

    I have noticed that during or at the end of a conference call when one party hangs up all parties have always been disconnected. I can tell you that if this is the way it works normally, this is not the way is should work. This is a pain in the butt when it is necessary to call one of the parties back since that party is also trying to call you back. You both get a busy signal.
    I do not have a problem answering a second call during a time when I am on a first call. It will place the first call on hold and I will only be talking to the second party. It should work that way. My iPhone works that way.
    It should also allow you to add the second call to the first call through the 'merge' feature so that both the first and second calls can be joined together. My iPhone works that way.
    My previous Treo worked great on these situations but I do have burps with the iPhone.
    I think that the problem is with the iPhone and AT&T interface in these conditions.
    I would provide your comments to Apple via:
    http://www.apple.com/feedback/iphone.html.

  • Program Freezes when setting up GUI & can't figure why...

    Hi Folks,
    I'm having some serious problems with a program i've written, basically the program creates several threads.
    Each thread creates and uses a JFrame to play a movie.
    The problem i'm getting though is that the program keeps freezing(deadlocking) on me when i'm in the process of setting up each JFrame. I haven't even started the threads....
    This happens intermittedly too boot, what i mean is that the program could run all day, then when it tries to setup a new group of JFrames will freeze, or it could run for just one hour and then the same would happen. I don't know why it is happening... Below is all the relevant code.
    //code from the class which creates the Threads (the threads are called polly and passes the details
    // required to them
    private void createAndSendPollyDetails(){
            for(int i = 0; i < polly.length; i++){
                polly[i] = new Polly(basil);
                System.err.println(" created polly: " + (i+1));
                //get screen percentages
                for(int w = 0; w < 4; w++) {
                    if (w == 0){
                        sWidth = screenSizePercentages[i][w];
                    if (w == 1){
                        eWidth = screenSizePercentages[i][w];
                    if (w == 2){
                        sHeight = screenSizePercentages[i][w];
                    if (w == 3){
                        eHeight = screenSizePercentages[i][w];
                System.err.println("about to send setupScreen details");
                polly.setUpScreen(sWidth,eWidth,sHeight,eHeight);
    System.err.println("about to send array data");
    polly[i].setVals(AScreenDisplayDataHolder.getPlayList(i),
    AScreenDisplayDataHolder.getPlayListLengths(i),
    AScreenDisplayDataHolder.getSizeOfPlayList(i),
    AScreenDisplayDataHolder.getSizeOfPlayListLengths(i));
    if(AScreenDisplayDataHolder.getMainScreenInMainScreenDetails(i)) {
    boolean b = true;
    mainPollyNumber = i;
    polly[i].setMainTrue(b);
    polly[i].setMainLen(AScreenDisplayDataHolder.getMainLengthInMainScreenDetails(i));
    try{
    Thread.sleep(1300);
    }catch (InterruptedException ie) {
    ie.printStackTrace();
    // code from Thread, which just sends the details to screen for setup, the threads haven't even started....
    public void setUpScreen(final double sWidthIn, final double eWidthIn, final double sHeightIn, final double eHeightIn) {
    System.err.println("calling screen.setDisplay");
    Runnable doWorkRunnable = new Runnable() {
    public void run() { screen.setDisplay(sWidthIn, eWidthIn, sHeightIn, eHeightIn);  }
    //SwingUtilities.invokeLater(doWorkRunnable);
    try{
    SwingUtilities.invokeAndWait(doWorkRunnable);
    } catch(InterruptedException ie) {
    System.err.println("error");
    } catch(InvocationTargetException ite) {
    System.err.println("target exception");
    System.err.println("fin call to screen.setDisplay");
    public void setVals(final String[] movieArrayIn, final String[] movieLengthArrayIn, final int lengthOfMovieArray,
    final int lengthOfMovieLengthArray) {
    Runnable doWorkRunnable = new Runnable() {
    public void run() { screen.setValues(movieArrayIn, movieLengthArrayIn, lengthOfMovieArray, lengthOfMovieLengthArray);
    System.err.println("screen.setValues has finished in the void run method");
    //SwingUtilities.invokeLater(doWorkRunnable);
    try{
    SwingUtilities.invokeAndWait(doWorkRunnable);
    } catch(InterruptedException ie) {
    System.err.println("error");
    } catch(InvocationTargetException ite) {
    System.err.println("target exception");
    System.err.println("got to end of SetVals");
    //code from the JFrame which loads the data required by the JFrame into arrays and sets the size(bounds)
    // of the JFrame. Had to use setBounds as start location not always going to be 0,0 for all JFrames
    public void setValues(final String[] movieArrayIn, final String[] movieLengthArrayIn, final int lengthOfMovieArray,
    final int lengthOfMovieLengthArray) {
    Runnable doWorkRunnable = new Runnable() {
    public void run() {
    movieArray = new String[lengthOfMovieArray];
    System.err.println("done moviearray new");
    movieArray = movieArrayIn;
    System.err.println("done moviearray copy");
    movieLengthArray = new String[lengthOfMovieLengthArray];
    System.err.println("done movieaLengthArray new");
    movieLengthArray = movieLengthArrayIn;
    System.err.println("done movieLengthArray Copy");
    SwingUtilities.invokeLater(doWorkRunnable);
    // set the size of the screen
    public void setDisplay(final double sWidthIn, final double eWidthIn, final double sHeightIn, final double eHeightIn){
    Runnable doWorkRunnable = new Runnable() {
    public void run() {
    Dimension wholeScreenSize = getToolkit().getScreenSize();
    if(sWidthIn == 0){
    sWidth = 0;
    else {
    sWidth = wholeScreenSize.getWidth()/100 * sWidthIn;
    if(eWidthIn == 0){
    eWidth = 0;
    else {
    eWidth = (wholeScreenSize.getWidth()/100 * eWidthIn) - sWidth;
    if(sHeightIn == 0){
    sHeight = 0;
    else {
    sHeight = wholeScreenSize.getHeight()/100 * sHeightIn;
    if(eHeightIn == 0){
    eHeight = 0;
    else {
    eHeight = (wholeScreenSize.getHeight()/100 * eHeightIn) - sHeight;
    Screen.this.setBounds((int)sWidth, (int)sHeight, (int)eWidth, (int)eHeight);
    System.err.println("done SetBounds");
    screenSize = new Dimension((int)eWidth,(int)eHeight);
    System.err.println("done setting dimension screenSize");}
    SwingUtilities.invokeLater(doWorkRunnable);
    As you can see i've tried putting them all in SwingUtilities.invokeLater, and still freezes....
    I don't understand why it still does freeze... I'm also wondering when do you need to use the SwingUtilities.invokeLater and invokeAndWati, is it when you are changing/using any element/variable within a JFrame or just when you are changing/using and element/variable that effects the GUI display on a screen
    Please help,
    I'm very stuck,
    Andy.

    Keep it simple, start by removing all of the threads launches and frame builds and make sure it runs. Then have it build one frame and one thread and see if it runds. Then add another one and then ... you get the idea.
    The first thought I had when I was reading your post was that you might want the thread to spin up its own frame rather than have the frame done first and then the thread launched.
    Just a couple of thoughts on the subject.

  • Indeterminate progressbar freezes when executing thread

    Hi people,
    Here is my problem.
    In my GUI application, at some point the user needs to perform a time consuming application. I want to tell the user that the task is performing as it is supposed to by displaying an undeterminate progressbar. However, when the task is being executed, the progress bar just freezes, until the task is finished. This particular task involves the use of an external process (i.e. .exe file).
    To remedy this, I launch a separate thread to perform my task, using SwingWorker, which, as I understand it, is a class designed for exactly this sort of thing. But it does not work! I spent a lot of time trying to get this problem solve but with no success. I also tried to put the the task in a "conventional" thread, but it always result in the same behavior. Here is some of my code, so someone can maybe see what am I doing wrong. In that code, the progressDialog displays a progressbar set at indeterminate(true);
    Since I successfully used the code below to perform more simple tasks (like reading files and extracting lines from it), I am wondering if the use of an external .exe might be the problem here.
    Cheers,
    progressDialog = new StatusJDialog(new javax.swing.JFrame(), false);
    progressDialog.setVisible(true);
    task = new Task();
    task.execute();
    class Task extends SwingWorker<Void, Void> {
    * Main task. Executed in background thread.
    @Override
    //None GUI stuff goes here.
    public Void doInBackground()  {
           try {
                    Thread.sleep(100);
                    WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
                        public void run() {
                            //Do time consuming task using external .exe here...
                } catch (InterruptedException ignore) {}
                return null;
             * Executed in event dispatch thread
    @Override
    public void done() {
        Toolkit.getDefaultToolkit().beep();
        progressDialog.setVisible(false);
    }

    It looks to me as if you're creating a SwingWorker background thread, but within that background thread, you're placing a long-running task on the EDT with this:
    WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
    }So you're defeating the purpose of the SwingWorker.
    You need to understand that code called in the doInBackground is called off of the EDT. I suggest that you get rid of the code to invoking the WindowManager and simply call your long running task in doInBackground.
    i.e.,
    public Void doInBackground()  {
           try {
                    Thread.sleep(100);
                    //    **** delete block below
                    // WindowManager.getDefault().invokeWhenUIReady(new Runnable() {
                    //     public void run() {
                    //   **** delete block above
                   //  ***  Do time consuming task using external .exe here...  *** 
                } catch (InterruptedException ignore) {}
                return null;
            }For others, a link to the WindowManager API is here: [http://bits.netbeans.org/dev/javadoc/org-openide-windows/org/openide/windows/WindowManager.html#invokeWhenUIReady%28java.lang.Runnable%29]

  • CC programs freeze when mouse settings are changed to left hand use

    Hi everyone,
    I have a little problem with several CC programs, when the mouse setting is changed to letf hand use for one user.
    We are running Windows 7 x64 Professional and the latest version of Adobe CC 2014 of Photoshop and Illustrator.
    When the user works with large files, the CC program (Photoshop in most cases, but e.g. Illustrator as well)  freezes, the only window that works then is the window of the file that is open at the moment. Windows of other files are not clickable . When the taskmanager is opened then the other windows become clickable again. But when the user clicks somewhere, for example on the desktop  a right click is a left click. that stops when a the left mouse button is clicked, than it works again.
    The problem appears once or twice a day. When we change the mouse settings back to normal everything works fine.
    I appreciate any hints and help
    Thanks,
    Andre

    I tested them all.
    As I already mentioned above: I just don't use the Touch and Launch Tool. I prefer to use only the extended functions of the usual Toshiba driver (as the extended corner functionality or the Easy Launcher). I know that I can set the mouse speed there. (that's what I did) But I?m already at the maximum speed and moreover there?s no possibility to increase the mouse acceleration. That?s why I?d like to change this in the usual windows-settings window.
    For the moment I placed a shortcut to the mouse settings in the autostart folder. So every time I start up, I can change the settings immediately. But of course this is no long-term solution.
    By the way: My goal is to have as less tools and running software as possible on my computer, because I use it for music production and a really need all resources I can get!!

  • GUI freezes when new Thread object start()ed. Neat, brief code included :)

    The title says it all really.. I have the code below in a method startScan() that is called when a button is pressed. The thread executes fine, but the GUI locks up while the thread is executing. I don't really understand why, since a new thread is implicitly separate from the event dispatch thread.
    Must I use a SwingWorker to get things working? Would someone be kind enough to explain why, if this is the case?
    private void startScan() throws InterruptedException {
              final Runnable breadthFirstComparer = new Runnable() {
                   /** Sleep interval used when scan paused */
                   private int interval = 1000;
                    * Kills the current thread
                   public void stop() {
                        scanProgressLabel.setText("Scanning complete");
                        scanComplete = true;
                    * Sleeps the currently running thread if user has paused the scan,
                    * otherwise initiates comparison of the trees' next depth node sets
                   public void run() {
                        while (!scanComplete) {
                             while (scanPaused) {
                                  try {
                                       Thread.sleep(interval);
                                  } catch (Throwable exc) {
                                       Gecko.logException("Scanner thread could not be paused", exc);
                             compareTrees();
                        // Stop thread execution once scan is complete, and disable
                        // scanner-related buttons
                        toggleScanButton.setEnabled(false);
                        stop();
              scanner = new Thread(breadthFirstComparer)
                   public void start() {
                        scanProgressLabel.setText("Scanning in progress...");
                        breadthFirstComparer.run();
              scanButton.setEnabled(false);
              scanner.start();
         }Many thanks.

    it's getting really irritating that pretty much every thread out of the last
    20 I've made, you've criticised me for not posting an SSCCE. How do you think I feel. I'm donating my time to help you solve a problem, but you are not willing to spend 5-10 minutes to post a SSCCE so that we can fully understand what you have done and what the problem is.
    You don't have to post a SSCCE if you don't want to. Thats fine, I just won't answer your questions.
    what's the point me spending 30 minutes or more my end creating an
    SSCE, and you spending 10 minutes or more compiling, running and analyzing it your end?It should not take 30 minutes. If it does it just goes to prove that you don't really understand what you are attempting to do. And if you don't know what you are doing how do you expect us to guess what you are doing? One of the benefits of a SSCCE it to help you learn to develop problem solving skills by learning to simplfy the problem.
    Also, what if we can't figure out the problem based on your verbal description of the problem? If you post code it gives us the option of compiling and testing the code if we so desire. Without the code we give up and move on to the next question.
    but since the simple information that you've provided, and the chunk of code that Michal so kindly donated, are likely more than enough of an explanationThis time we were able to guess what the problem was, but that is not true in all cases. You seem to think that we are all miracle workers, that you can place a couple of lines of code in front of us and we can automatically tell whats wrong. Well, thats not true (at least for me). Many times I use my problem solving skills to solve the problem.
    I really should learn to scroll down and read all the posting before replying. es5f2000 pretty much said it all for me.
    Message was edited by:
    camickr

  • Program freezes when sending to itunes

    I use Garageband to make audiobook files. I'll throw, for example, an audiobook disc's worth of content into a garageband "song" chronologically, then send the track to iTunes. That way, my audiobooks on iTunes will be in a few long tracks rather than in a bunch of tiny tracks. I've been doing it for a long time and Garageband's always done it perfectly. Lately, however, it's been freezing up almost every time I try to send it. During the "creating mixdown" process it'll stop somewhere in the time line and freeze. I basically have to force close when it happens. I've tried numerous techniques to stop it from freezing during the process, sometimes it's worked, but it's been freezing quicker and more frequently as of late. My software is up to date, and my Mac hasn't been having any other problems at all.
    Anyone got any suggestions?

    Hello there, KMB1.
    The following Knowledge Base article provides some great steps for isolating your issue running iTunes in Safe Mode:
    iTunes: Troubleshooting issues with third-party iTunes plug-ins
    http://support.apple.com/kb/TS3430
    There are several ways in which an add-on can cause iTunes to act erratically, such as those listed below:
    - Loss of iTunes functionality, such as the Visualizer.
    - Distortion or irregularity in the iTunes interface.
    - Slow performance.
    - iTunes won't open or quits unexpectedly.
    - You see an alert while syncing stating "... cannot be synced. A duplicate file name was specified."
    If you notice any of the above symptoms or other unusual behavior, you can disable any plug-ins not manufactured by Apple by opening iTunes in Safe Mode. This is done by holding down the Option and Command keys (on Mac OS X) or holding down the Shift and Control keys (on Windows) while opening iTunes. If performed correctly, you should see the following dialog before iTunes finishes starting up:
    "iTunes is running in Safe Mode. Visual plug-ins you have installed have been temporarily disabled."
    If the above does not resolve your issue, try to isolate further by testing in another user account:
    Isolating an issue by using another user account
    http://support.apple.com/kb/TS4053
    Symptoms
    When isolating issues and/or troubleshooting software issues in OS X, you might want to use a different user account. Learn how to use this technique to narrow down the cause of an issue.
    Resolution
    The issue at hand may simply be caused by a bad preference setting or user-specific data file. With proper isolation, you can avoid time-consuming and inappropriate troubleshooting methods.
    Thanks for reaching out to Apple Support Communities.
    Cheers,
    Pedro.

  • MAX and whole comp. gets freeze when I tried to run RESMAN

    Hi
    I am trying to run RESMAN for VXI-MXI-2 in MAX 3.3.1, but it and the computer gets freeze and said "Searching for Statically Configured Devices" such as message 1 (attached). Then next time I tried to run it again it says "VXI locked up" I have to reset it. Please help!! Thanks in advance.
    Attachments:
    message 1.jpg ‏73 KB

    This problem happens when there is no VXI Bus Timeout. The way to verify it is when the Resource Manager locks up again, turn off the chassis but leave the computer on, if the computer resumes and go back to normal, then this will be the cause of the hanging.
    The fix to it is to configure the VXI-MXI Bus Timeout, since you can not use the configuration utility, try switch the Factory Overwrite dip switch, this should fix it for you. The location of the this Factory Overwrite switch can be found in the KnowledgeBase you saw before:
    http://zone.ni.com/devzone/conceptd.nsf/webmain/86054DE2C9DACE7A86256CEE0070237C?opendocument
    The TMExlorer only came with older versions of VXI driver and the new driver uses Measurement & Automation Explorer which covers all the functionality of the old TMExlorer. By switching to the old driver will not help in this situation.

Maybe you are looking for