Traditional Culture Encyclopedia - Hotel reservation - JAVA SWING hotel management system interface room button discoloration and other issues.

JAVA SWING hotel management system interface room button discoloration and other issues.

First, customize a room class or RoomInfo class to record various properties of the room, such as price tag, type, etc.

Public? Class? Room {

int? Num// number

int? Price; //Price

String? Type; //type

//... constructor. Setter? getter? ,? toString,HashCode,equals? equilong

} Then, customize a JButton class. When constructing this class, you need to pass in a room class.

Public? Room button? Extension? Button {

Room? Room;

Public? RoomButton (room? Room) {

This.room = room; ? //? This puts the room information in the button.

}

Public? Room? getRoom(){

Return? Room;

}

} Third, add a mouse event responder to the button, take out the room when the mouse moves to the button, and then set the information in the room as JLabel.

jlabel . settext(room button . getroom()。 getNum()); ? //Display the rendering after the numbering is completed.