Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

??? JToggleButton ???

 
Coq Rouge
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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>
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I already answered this last week (with an example no less)!
Last Answer
Manfred.
 
Coq Rouge
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic