I'm new to Java and I'm working on an airplane seat reservation program. I would like to know how to display a JTextfield text box and a JLabel after clicking a button that is already displayed in a JFrame window. I have tried to add the button after an if statement but it doesn't work. I have also tried button.setVisible(false) and then making it true later. I have a button.actionlistener(this) for each of the buttons used.
public void actionPerformed(ActionEvent event){
Container contentPane = null;
JButton clickedButton = (JButton) event.getSource();
if (event.getSource() == coach){
five.setForeground(Color.green);
eleven.setForeground(Color.green);
six.setForeground(Color.green);
two.setForeground(Color.black);
if (event.getSource() == five) {
inputLine = new JTextField();
inputLine.setBounds(110, 180, 185, 22);
contentPane.add(inputLine);
}
} else if (event.getSource() == firstClass){
two.setForeground(Color.green);
five.setForeground(Color.black);
eleven.setForeground(Color.black);
six.setForeground(Color.black);
}