aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes jButton Does not do all tasks Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "jButton Does not do all tasks" Watch "jButton Does not do all tasks" New topic
Author

jButton Does not do all tasks

peter m hayward
Ranch Hand

Joined: Sep 27, 2012
Posts: 35
Hi I have a jButton that when the action perform runs it only does part of the tasks some of the code doe not appear to run and i just can not figure out why i have tried wrapping parts of it in an if statement and it still do not run so here is the code behind the button hope some can help

in the code the parts that do not run are jTextField10.setText("Working Please Wait");
and jButton15.setVisible(false);

what i am expecting to happen is the text field has the words Working Please Wait placed in it , this does not happen

and the button should be hidden to prevent it being clicked a second time again this does not happen

the rest of the code works as expected

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42286
    
  64
this does not happen

Have you ascertained that the code is executed at all? Like printing out something from within the button handler?

Not sure if it's related to the problem, but an empty I/O catch block is a bad idea:

} catch (IOException e) {
}

You need to handle exceptions properly, or at least print output so that you will see if something goes wrong.


Ping & DNS - my free Android networking tools app
peter m hayward
Ranch Hand

Joined: Sep 27, 2012
Posts: 35
Hi take you point, please note i had other code but stripped it out bit by bit to try and find out what was happening i have rearrange this every way i can think of over two days and it still not working and i just can see why

when the process competes it print all done number of files processed in the same text box so that add another twist to the tail

regards pete
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42286
    
  64
Sorry, I can't tell from your post whether you have or have not ascertained that the action listener is being executed at all. Obviously, if you have not, then now would be the time to do that.
peter m hayward
Ranch Hand

Joined: Sep 27, 2012
Posts: 35
Hi I assume the action listener is run because the other events take place once i click the button , or maybe i have a miss understanding can you therefore please tell me how to check this
regards pete
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

Just add this as a first statement inside your actionPerformed


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
peter m hayward
Ranch Hand

Joined: Sep 27, 2012
Posts: 35
that prints out fine i should have said i original had a print statement there and it printed out the message it seems the call readIN(); is some how overiding everything even though it at the bottom of the list ?
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42286
    
  64
OK. The entire "try" block probably runs, but there might be an exception early on; be sure to print out the stack trace of any exception to the catch handler, like I suggested.

Line 19 and 20 should be run, obviously, but it's hard to say why their effect is not noticeable without seeing the context in which they operate.
 
wood burning stoves
 
subject: jButton Does not do all tasks