EDIT: Obviously a beginners question! Probably in the wrong forum, please feel free to move mods! Apologies!
I thought I'd help myself understanding the GUI and ActionListener proces a bit better by sussing out how to do something simple like putting a button and a rectangle on a screen and then having it change color from blue to red on buttonclick.
Appears I've ended up in a swamp and everytime I move I get sucked farther in.
I soon found out I have no clue how to easily change the color of something when clicking a button so I thought I'd fake it first by simply running a different color panel on mouseclick. And that failed miserably too! Trying to use the boolean swoosh in two different classes is not the way to go. So a little help, hint or push in the right direction would be greatly appreciated!
If it wasn't for physics and law enforcement, I'd be unstoppable!
Timothy Oldbean
Greenhorn
Joined: Jun 23, 2011
Posts: 17
posted
0
I'm trying to get the boolean to work in another class through using getter and setter but now I've run into a new problem. I get an error on the getter method.
Timothy Oldbean
Greenhorn
Joined: Jun 23, 2011
Posts: 17
posted
0
Stuck for hours and as soon as I post here I start getting somewhere.
I think I've got the getter and setter part sorted now:
The challenge I have now is to get the value of boolean swoosh into the if else statement which I'm wrongly attempting to do like so at the moment:
compile/run, the clicking the button numerous times will alternate between the two colors
note: if you had added 'recty' anywhere else but center, it would not have shown up (try adding it to NORTH).
without components, it normally needs to have a preferredSize set
Timothy Oldbean
Greenhorn
Joined: Jun 23, 2011
Posts: 17
posted
0
Thanks a lot Michael!
I'm going to take my time tomorrow comparing your code to mine and see where I went wrong. By the first look of it I see you doing a couple of things I haven't seen yet and thus don't understood so I might have a couple of extra questions later after I try to find it out myself.