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.
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>
Hi, I already answered this last week (with an example no less)! Last Answer Manfred.
Coq Rouge
Greenhorn
Joined: Nov 17, 2001
Posts: 5
posted
0
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