aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Progress Bar and Thread Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Progress Bar and Thread" Watch "Progress Bar and Thread" New topic
Author

Progress Bar and Thread

Ashish Agre
Ranch Hand

Joined: Jan 22, 2011
Posts: 73



Anybody please help me i want that when reset is clicked then the current thread must terminate ...
and new thread must start....


| B.E IT | SCJP 6.0 98 % |
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3371
    
    9
In chVal's run() method, make the loop test not only whether it's at the end of progress, but also whether it has to abort. Simply use a boolean member variable, and set this boolean to abort in your reset button.

By the way, your code looks very bulky. Don't fully qualify classes in your code. Instead, import java.awt.event.*, javax.swing.event.* and javax.swing.border.* and use simply class names in your code.

Also, never use variable names like j or l as member variables. They need to be descriptive. You should also use upper camel case for class names. Don't use chVal, it doesn't follow naming conventions, and its meaning is not clear.
Also, don't call your methods names like jButton2ActionPerformed(), call them names that describe what they do, like reset().
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19543
    
  16

Stephan van Hulst wrote:Also, don't call your methods names like jButton2ActionPerformed(), call them names that describe what they do, like reset().

The GUI part has been automatically generated; you can tell from the use of GroupLayout, the way the event handling methods are named, and the presence of the initComponents method.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3371
    
    9
Ahh I see. Another reason for me to write my GUIs manually :P
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

I feel it's unfortunate that Oracle, and Sun before them, present the NetBeans visual designer as a beginners' tool, as witness the byline in the Swing Tutoral index page:
Learning Swing with the NetBeans IDE is the fastest and easiest way to begin working with Swing.


I wouldn't agree with that. The fastest and easiest way to learn Swing is to learn the API and how to use it, with the help of tutorials and the occasional input from a more experienced person, on a forum or elsewhere. The visual designer can be a powerful productivity booster in the hands of a skilled and experienced Java / Swing coder, who would know better than to blindly accept default variable and method names, and who would know just what all the auto-generated code does.

luck, db
There are no new questions, but there may be new answers.
Ashish Agre
Ranch Hand

Joined: Jan 22, 2011
Posts: 73

well darryl i tried that using netbeans for swing might be easy but ofcourse nobody likes it here... just complaints ..

when you know :

100 times then at 101th time you just need to drag and drop with the help of visual deigner but this doesn't seems to be acceptable
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18127
    
    8

Sure it's acceptable. The thing is, it's also acceptable to post your own code here and ask questions about it. But posting somebody else's code which you don't understand... that irritates people a bit. And that's basically what you're doing when you post code generated by Netbeans. So they tend to say things like "Learn Swing for yourself first, then you won't be taken aback when you are forced to debug somebody else's Swing code".

Just my two cents (CAD, not US pesos) about where those complaints are coming from.
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Ashish Agre wrote:well darryl i tried that using netbeans for swing might be easy but ofcourse nobody likes it here... just complaints ..

when you know :

100 times then at 101th time you just need to drag and drop with the help of visual deigner but this doesn't seems to be acceptable

If you have 100 buttons with a similar functionality (I'm thinking Minesweeper) you should be using an array.

And if you have 100 buttons on a single screen, and they don't have similar functionality, you have a severe design/usability problem.

Sorry if that comes across as supercilious and me acting superior, but just think about it for yourself -- do you agree?
Ashish Agre
Ranch Hand

Joined: Jan 22, 2011
Posts: 73

well darryl i just want to know it is good to use use netbeans IDE for studying swing as most memorizing thing that after applying . on the object (JButton.setEnable(true)) we are able to see how many more function are associated with the object so that every time we don't need to refer javadoc
@ paul after core i want to concentrate on swing should i continue with netbeans or the same cmd(>_) or terminal[ashish : $]
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4523
    
    5

Just to be clear: I don't recommend coding Java in Notepad. By all means take advantage of the syntax highlighting and code completion, with popup javadoc, that an IDE provides.

My stand is that the NetBeans visual designer is not a beginners' tool, and never will be. It actually lowers productivity for a beginner, and is IMHO about 5 times more difficult to learn than it is to learn hand coding.

OTOH, once you have adequate exposure to Swing coding, once you know what can (and should) be done, it's relatively easier to discover for the first time how to do that in a visual designer.

And Java has methods, not functions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Progress Bar and Thread
 
Similar Threads
Storing JTextField to variable
Pressing a button to open a new window
Problem With GUI of Net Beans
Symbol Not Found - What am I Missing?
Networked Programs that work across countries