• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Progress Bar and Thread

 
Ranch Hand
Posts: 73
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Anybody please help me i want that when reset is clicked then the current thread must terminate ...
and new thread must start....
 
Bartender
Posts: 15741
368
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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().
 
Sheriff
Posts: 22849
132
Eclipse IDE Spring Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Stephan van Hulst
Bartender
Posts: 15741
368
  • Likes 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ahh I see. Another reason for me to write my GUIs manually :P
 
Bartender
Posts: 5167
11
Netbeans IDE Opera Java
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ashish Agre
Ranch Hand
Posts: 73
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 28395
100
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 73
Netbeans IDE Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 5167
11
Netbeans IDE Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic