Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

GUI's  RSS feed

 
Westly VonVeuslar
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this source which implements ActionListener to my class.

I add the action Listener

I then do actionPerformed where the even handling is done.


This works just fine, but I changed it so that it would draw a rectangle instead of making a button. I successfully done that, but was wondering if my code could be cleaned up a bit. If you could point out some beginner mistakes, that would be great. Remember that I am just starting out, so don't go too atomic in your criticism.



[ November 11, 2008: Message edited by: Wes Fakename ]

[ November 11, 2008: Message edited by: Wes Fakename ]
[edit]Add code tags andtidy up indents. CR[/edit]
[ November 12, 2008: Message edited by: Campbell Ritchie ]
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Wes,

Welcome to the ranch. We are happy to have you here
You seem to have missed out the naming policy. That is one of the few things we insist on adhering to the letter here. Please change your display name so that it is not "obviously fictious". You can change it by clicking here.

As you have probably noticed, we have quite a few forums. Posting in the proper forum will increase your chances of getting a more better/detailed solution. Since your question is more related to Swing, I am moving it to the proper forum for you.

While you are here, it might be worth your while to visit this link to get a better idea about getting the most from the ranch.

Coming back to your problem.
Your code looks good. Usually, you should call from your over ridden paintComponent method.
Also Swing is not thread safe. It is a good practice to start building and displaying your UI on a separate thread.
Check out .
 
Campbell Ritchie
Marshal
Posts: 55680
161
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Wes Fakename" I was obviously asleep when I saw your post earlier, but now I am awake, I shall send you a private message which you will have to take notice of.

CR
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!