I have a class called HotelMenu, which is called by my Main class. HotelMenu is a GUI which shows a hotel menu. Now within HotelMenu, there are two options for which I want a GUI to be displayed when add or view buttons are clicked.
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class HotelMenu extends JFrame implements ActionListener{
// I have frame dimension constants here
public HotelMenu() {
// this is where the GUI for HotelMenu is created
}
public void actionPerformed(ActionEvent event) {
JButton clickedButton = (JButton) event.getSource();
if (clickedButton == viewBtn) {
// Want to generate a GUI here
}
else if (clickedButton == addBtn) {
//Want to generate a GUI here
}
else // else it's the Exit button
setVisible(false); //you can't see me!
dispose(); // closes the HotelMenu form
}
// Maybe I can include methods that generate GUI for 2 buttons here?
}
I want to know if I can write two methods within HotelMenu class that allows me to generate a simple JRadioButton GUI for when addbtn , viewbtn are clicked.
I don't want to create a separate class for these, if possible.