This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes ??? JToggleButton ??? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply Bookmark "??? JToggleButton ???" Watch "??? JToggleButton ???" New topic
Author

??? JToggleButton ???

Coq Rouge
Greenhorn

Joined: Nov 17, 2001
Posts: 5
Really need help here!!
I've got a problem - hope anyone can help me (or ask anyone who can)!!!
Consider the following:
I'm going to create a booking system for a cinema theatre, which is going to consist of components (seats)
that's showing the text "Free" in black on a grey background.
I am to be able to cancel a reservation or reserve a seat with only one click on the respective component.
When the seat is reserved the component will show the text "Occupied" with an other color than black and the
backgroud of the component are to be in an other color than grey.
I've been trying out the JToggleButton, but I connot figure out how to change the component with a click.
The JToggleButton has properties for true and false - can I change these properties??
This is a resume from the class showing the seats i the theatre:

public Chairs ()
{
GridLayout grid = new GridLayout(Theatre.numberRows,Theatre.numberCols,5,15);
setLayout(grid);
EtchedBorder edge = new EtchedBorder (EtchedBorder.RAISED);
JToggleButton button = new JToggleButton("Free", false);
for (int i=0;i<Theatre.numberRows;i++)>
for (int j=0;j<Theatre.numberCols;j++)>
{
add(button = new JToggleButton("Free"));
button.setBorder(edge);
button.addActionListener (this);
}
}
<big>thanks</big>

[img]<http://home.no.net/warezcoq/spider.gif>[/img]<BR>
Manfred Leonhardt
Ranch Hand

Joined: Jan 09, 2001
Posts: 1492
Hi,
I already answered this last week (with an example no less)!
Last Answer
Manfred.
Coq Rouge
Greenhorn

Joined: Nov 17, 2001
Posts: 5
Originally posted by Manfred Leonhardt:
Hi, I already answered

I know how to change the panel-background, I wanted to change the BUTTON preferences as following:
JButton button = (JButton) get.Source ();//cannot use JToggleButton have to use JButton.
button.setBackground(new Color(128,128,128));//changes component
button.setForeground(new Color(0,0,0));//changes label/text

Remeber that setLabel has been deprecated and been replaced with setText i Class AbstractButton.
After all I've figured it out after all :-)
never mind
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: ??? JToggleButton ???
 
Similar Threads
Class Project: Airline Reservation System
JToggleButton as a Theatre Seat
complicated code, 900 labels.
Button Colors
JToggleButton Question