Hi,
I am lost and confused. I need to write a class to test the following program, and I don't have a clue where to start. Any help would be appreciated.
import javax.swing.*;
import java.awt.*;
import java.awt.event. *;
public class VideoStore extends JApplet implements ActionListener {
public JButton button1, button2, button3;
public JLabel header, movie1, movie2, movie3;
public JTextField selection;
Font headerFont = new Font("Times New Roman", Font.BOLD, 24);
Font labelFont = new Font("Courier", Font.BOLD, 14);
public void init()
{
button1 = new JButton("Buy");
button2 = new JButton("Buy");
button3 = new JButton("Buy");
header = new JLabel("CCAC Video Store");
movie1 = new JLabel("Johnson Family Vacation");
movie2 = new JLabel("Pitch Black");
movie3 = new JLabel("Meet the Folkers");
selection = new JTextField(20);
FlowLayout flow = new FlowLayout();
setLayout(flow) ;
header.setFont( headerFont);
add(header);
movie1.setFont( labelFont);
add(movie1);
add(button1);
movie2.setFont( labelFont);
add(movie2);
add(button2);
movie3.setFont( labelFont);
add(movie3);
add(button3);
selection.setEd itable(false);
add(selection);
button1.addActi onListener(this );
button2.addActi onListener(this );
button3.addActi onListener(this );
}
public void actionPerformed (ActionEvent e)
{
if(e.getSource( ) == button1)
{
selection.setTe xt("Johnson Family Vacation");
}
else if(e.getSource( ) == button2)
{
selection.setTe xt("Pitch Black");
}
else if(e.getSource( ) == button3)
{
selection.setTe xt("Meet the Folkers");
}
}
}
I am lost and confused. I need to write a class to test the following program, and I don't have a clue where to start. Any help would be appreciated.
import javax.swing.*;
import java.awt.*;
import java.awt.event. *;
public class VideoStore extends JApplet implements ActionListener {
public JButton button1, button2, button3;
public JLabel header, movie1, movie2, movie3;
public JTextField selection;
Font headerFont = new Font("Times New Roman", Font.BOLD, 24);
Font labelFont = new Font("Courier", Font.BOLD, 14);
public void init()
{
button1 = new JButton("Buy");
button2 = new JButton("Buy");
button3 = new JButton("Buy");
header = new JLabel("CCAC Video Store");
movie1 = new JLabel("Johnson Family Vacation");
movie2 = new JLabel("Pitch Black");
movie3 = new JLabel("Meet the Folkers");
selection = new JTextField(20);
FlowLayout flow = new FlowLayout();
setLayout(flow) ;
header.setFont( headerFont);
add(header);
movie1.setFont( labelFont);
add(movie1);
add(button1);
movie2.setFont( labelFont);
add(movie2);
add(button2);
movie3.setFont( labelFont);
add(movie3);
add(button3);
selection.setEd itable(false);
add(selection);
button1.addActi onListener(this );
button2.addActi onListener(this );
button3.addActi onListener(this );
}
public void actionPerformed (ActionEvent e)
{
if(e.getSource( ) == button1)
{
selection.setTe xt("Johnson Family Vacation");
}
else if(e.getSource( ) == button2)
{
selection.setTe xt("Pitch Black");
}
else if(e.getSource( ) == button3)
{
selection.setTe xt("Meet the Folkers");
}
}
}