Ive been trying to make a program that should keep
the status of a hotel room layout.
main method should return this:
http://img202.imageshack.us/img202/969/layoutview.jpg
the cells should also be painted green if they are
available for renting
Yellow if they are booked
or red if the are not available
one class that stores the status of all these rooms
if they are available/booked or not available.
and a sub class of JPanel with 3 buttons that if you mark one
room on the grid and hit "booking" button it should be painted yellow
and if you mark another room and hit "pay" it should
be painted red
I have made an effort of making the button that should be printed
in the view area
public class GridButton extends JButton implements ActionListener {
private boolean selected;
public GridButton(int number) {
super("" + number);
setBackground(Color.GREEN);
selected = false;
setBorderPainted(false);
addActionListener(this);
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
g2.setColor(Color.BLACK);
if (selected) {
g2.setStroke(new BasicStroke(10));
}
g2.drawRect(0, 0, getWidth(), getHeight());
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
public void actionPerformed(ActionEvent e) {
selected = !selected;
}
}
I wonder how I can implement these as
in the view I want
or if there is an easier way of
doing this right in the view class itself?