aspose file tools
The moose likes Swing / AWT / SWT and the fly likes JToggleButton as a Theatre Seat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Software Craftsman this week in the Agile forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JToggleButton as a Theatre Seat" Watch "JToggleButton as a Theatre Seat" New topic

JToggleButton as a Theatre Seat

Coq Rouge

Joined: Nov 17, 2001
Posts: 5

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);
EtchedBorder edge = new EtchedBorder (EtchedBorder.RAISED);
JToggleButton button = new JToggleButton("Free", false);
for (int i=0;i<Theatre.numberCols;i++)>
for (int j=0;j<Theatre.numberRows;j++)>
add(button = new JToggleButton("Free"));
button.addActionListener (this);

It is sorta covered in the JavaRanch Style Guide.
subject: JToggleButton as a Theatre Seat