Homework Program Question
Im working on an applet and in it i have a JPanel
Within this Panel i have a message Label followed by a button.
EX:
JLabel message2 =
new JLabel("Did you have any airfare?");
JButton YesButton = new JButton("Yes");
YesButton.addActionListener(new YesButtonListener());
I then have another Message Label followed by a text field that I want to be hidden unless the user hits the yes button.
EX that followes the Example above:
JLabel message3 =
new JLabel("Please enter the amount of airfare: ");
airfarre = new JTextField(10);
I dont know the commands to hide and unhide them in java. I want it hidden unless the user presses the "Yes" butten and if they do the ButtonListener will simply unhide the message and text fields.
[807 byte] By [
PoleVaulta] at [2007-11-27 2:55:06]

Ok here is some of what i have.
JLabel message2 =
new JLabel("Did you have any airfare?");
JButton YesButton = new JButton("Yes");
YesButton.addActionListener(new YesButtonListener());
JLabel message3 =
new JLabel("Please enter the amount of airfare: ");
message3.setVisible(false);
airfare = new JTextField(10);
airfare.setVisible(false);
iPanel.add(message2);
iPanel.add(YesButton);
iPanel.add(message3);
iPanel.add(airfare);
private class YesButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent e)
{
message3.setVisible(true);
airfare.setVisible(true);
}
}
Im getting this error
cannot find symbol
symbol : variable message3
location: class TravelExpenses.YesButtonListener
message3.setVisible(true);
I understand what is going on but I dont know what I can do to fix it.
Thanks for the help!