Results 1 to 8 of 8
Thread: Use of Start button's action
- 04-18-2009, 07:56 PM #1
Member
- Join Date
- Mar 2009
- Posts
- 10
- Rep Power
- 0
Use of Start button's action
hi guys i'm a newbie in java and i have a question.
i have 3 class but i used threads in 2 of them.In one class i used run function and in the another one's main used start function.I also used paint and paintComponent function in the class which i used start function. ( i have a user interface in this class )
in paint function i draw a few rectangles and paintCompenent function i added a few rectangles.
what i want is when i clicked the start button : run,start and paintCompenent functions start.
i am waiting your answers, thanks...
- 04-18-2009, 08:20 PM #2
Creating a GUI with JFC/Swing
and more specifically
Writing Event Listeners
Also, why are you using a Thread if all you call run() instead of start()? Why are you using both paint() and paintComponent()? You should only use paintComponent(). You also shouldn't add any Components in paintComponent().Last edited by OrangeDog; 04-18-2009 at 08:23 PM.
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 04-18-2009, 08:57 PM #3
Member
- Join Date
- Mar 2009
- Posts
- 10
- Rep Power
- 0
i learned that when i call start(), run() works.
i used both paint() and paintComponent() because, first i drew somethings and program do a few changes so i used paintComponent() to show the changes.
please give me your ideas
- 04-18-2009, 09:04 PM #4
Yes, you implement the run() method, but you should never call it. Similarly, you should override the paintComponent() method in order to draw on the component, but you should never call it. Call repaint() instead when things need updating.
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 04-18-2009, 09:20 PM #5
Member
- Join Date
- Mar 2009
- Posts
- 10
- Rep Power
- 0
ok i got the run() part. But in paintComponent() part, i draw new rectangles in the form how can i implement this?
- 04-18-2009, 09:25 PM #6
Member
- Join Date
- Mar 2009
- Posts
- 10
- Rep Power
- 0
ok i got the run() part. But in paintComponent() part, i draw new rectangles in the form how can i implement this?
i wanted to do somethings like, i wrote a paintComponent() there i drew 2 new rectangles and wanted to show them in the form.
at the end when i clicked the start button i want ( if it can ) paintComponent() func runs. ( or you can say me another idea )
- 04-18-2009, 10:14 PM #7
in paintComponent() use the drawing methods on the Graphics object as described in the tutorials linked above. If you want to change what is displayed, you will need additional flags that determine what you draw in paintComponent().
Don't forget to mark threads as [SOLVED] and give reps to helpful posts.
How To Ask Questions The Smart Way
- 04-19-2009, 06:52 PM #8
Member
- Join Date
- Mar 2009
- Posts
- 10
- Rep Power
- 0
Similar Threads
-
How do you start a Java program from the "Start" menu under Windows?
By ScottVal in forum New To JavaReplies: 5Last Post: 03-20-2009, 10:04 PM -
action class
By jayagowri in forum Web FrameworksReplies: 1Last Post: 05-07-2008, 03:23 PM -
jsp:forward action
By Java Tip in forum Java TipReplies: 0Last Post: 12-24-2007, 10:04 AM -
jsp:param action
By Java Tip in forum Java TipReplies: 0Last Post: 12-24-2007, 10:03 AM -
Few action in one Jbutton
By kubiasty in forum New To JavaReplies: 0Last Post: 07-25-2007, 10:19 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks