Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Changing Swing Colours  RSS feed

 
Nad Andy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey all,
Long time since ive been here.. heh C++. Anyway, trying to learn swing, i have a menu and a functional item listener to pick up what radio button is selected in a menu. The background is supposed to change colour depending on which radio button is selected. However, mine changes colour for a milisecond, and then back to default.



Thanks for any help .
Mad Nad
 
Stuart Gray
Ranch Hand
Posts: 410
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah, this one stumped me for ages once too. Under Swing you need to change the colour of the content pane, not of the frame itself. In itemStateChanged, change your two lines of code to look like this:
 
Nad Andy
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yay it worked like a charm. Thanks for that S Gray.
Mad Nad.
 
Ilja Preuss
author
Sheriff
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to Swing forum...
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!