Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem with saving a state in calendar program.

 
Al Do
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have attached a calendar program currently being used in a bigger program. However there is a problem with saving on the component picked. Currently it changes the background colour when the button is clicked but when another square is clicked on then the background colour changes back to normal is there anyway to keep the background colour when another square is clicked on.



 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
311 lines and it doesn't compile?

you expect us to read all that, and build a calendar in our head, then click imaginary buttons,
and see all sorts of colors changing.

you try it first, let us know how it goes.
 
Al Do
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry there was some stuff linked to other parts of the program.
Here is the main



Here is the calendar:



It now compiles, sorry about that.
 
Roberto Perillo
Bartender
Posts: 2271
3
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think this question has more to do with Swing, so let's move this over to the Swing forum.
 
Michael Dunn
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your have coded the background to be reset.

in clearDayActive() you have
b.setBackground(b0.getBackground());

comment out that line and it should do what you want,
but you'll need to add some method to reset the colors when necessary.

have you thought about a JToggleButton?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic