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]
# 1
JLabel, JTextField inherit JComponentcheck setVisible(false); http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JComponent.html#setVisible(boolean)
rym82a at 2007-7-12 3:31:31 > top of Java-index,Java Essentials,Java Programming...
# 2

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!

PoleVaulta at 2007-7-12 3:31:31 > top of Java-index,Java Essentials,Java Programming...
# 3
there is an especial forum for this my friend, there is a lot of code that u can use for your homeworkregards
big_rota at 2007-7-12 3:31:31 > top of Java-index,Java Essentials,Java Programming...
# 4
what forum would that be?
PoleVaulta at 2007-7-12 3:31:32 > top of Java-index,Java Essentials,Java Programming...
# 5
Ok i posted in a better forumhere is the link for those that dont mind helping: http://forum.java.sun.com/thread.jspa?threadID=5167325I posted the code.
PoleVaulta at 2007-7-12 3:31:32 > top of Java-index,Java Essentials,Java Programming...