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.