hi
i have a small frame/applet to do and the book is no help.
would someone point me in the right direction?
"Write a java app that displays a list of at least 10 items in a store in a frame. Allow the user to choose any number of times from the list, display the items that the user chooses"
i can not figure out how to get the action listner in the panel to recognize each button seperatly
import java.awt.*;
import java.awt.event.*;
public class Store extends Panel implements ActionListener
{
Button aButton = new Button("Shirt"
Label aLabel = new Label(" Location Info "
Button bButton = new Button("Pants"
Label bLabel = new Label(" Location Info "
Button cButton = new Button("Socks"
Label cLabel = new Label(" Location Info "
public Store()
{
setLayout(new GridLayout(3,0));
add(aButton);
aButton.addActionListener(this);
add(aLabel);
add(bButton);
bButton.addActionListener(this);
add(bLabel);
add(cButton);
cButton.addActionListener(this);
add(cLabel);
}
public void actionPerformed(ActionEvent e)
{
aLabel.setText("Blue Shirt"
bLabel.setText("Grey Pants"
cLabel.setText("Purple Socks"
}
}
thanks if you have the time to direct me
i have a small frame/applet to do and the book is no help.
would someone point me in the right direction?
"Write a java app that displays a list of at least 10 items in a store in a frame. Allow the user to choose any number of times from the list, display the items that the user chooses"
i can not figure out how to get the action listner in the panel to recognize each button seperatly
import java.awt.*;
import java.awt.event.*;
public class Store extends Panel implements ActionListener
{
Button aButton = new Button("Shirt"
Label aLabel = new Label(" Location Info "
Button bButton = new Button("Pants"
Label bLabel = new Label(" Location Info "
Button cButton = new Button("Socks"
Label cLabel = new Label(" Location Info "
public Store()
{
setLayout(new GridLayout(3,0));
add(aButton);
aButton.addActionListener(this);
add(aLabel);
add(bButton);
bButton.addActionListener(this);
add(bLabel);
add(cButton);
cButton.addActionListener(this);
add(cLabel);
}
public void actionPerformed(ActionEvent e)
{
aLabel.setText("Blue Shirt"
bLabel.setText("Grey Pants"
cLabel.setText("Purple Socks"
}
}
thanks if you have the time to direct me