I have some labels in my code that I don't want shown until a button is pressed. I put .setVisable(false) on all the labels and in the action listener for the button, put .setVisable(true) on all the labels. When I run the program and press the button, the labels do not appear.
Here is one of the labels
try{
lblPressure2 = new JLabel(toolKit.getPressure(selectedTown.toLowerCase()));
lblPressure2.setBounds(322, 114, 61, 14);
lblPressure2.setVisible(false);
panel.add(lblPressure2);
}catch(Exception e){e.printStackTrace();}
and here is my button
btnGet = new JButton("Show Me The Weather");
btnGet.setBounds(119, 71, 176, 24);
innerP.add(btnGet);
btnGet.addActionListener
(new ActionListener () {
public void actionPerformed(ActionEvent e) {
lblPressure2.setVisible(true);
}
});