HighLow2working is not abstract and does not override abstract method actionPerformed(java.awt.event.ActionEvent) in java.awt.event.ActionListener
public class HighLow2working extends Applet implements ActionListener
Another issue I am having is actually getting this to work, I really am at a loss and have no clue. If anyone can help it would be greatly appreciated.
import java.awt.*;
import java.applet.Applet;
import java.awt.event.*;
import java.util.Scanner;
import java.util.Random;
public class HighLow2working extends Applet implements ActionListener
{
//declare variables
Panel nPanel, sPanel, tcPanel, bcPanel, cPanel;
Button one;
Label top,lbl1, lbl2, lbl3, lbl4, bottom, output;
TextField txt;
int number, cnumber;
final int MAX = 25;
public void init()
{
//set north panel
nPanel = new Panel();
nPanel.setBackground(Color.pink);
top = new Label("HighLow Game");
//set south panel
sPanel = new Panel();
sPanel.setBackground(Color.green);
Label outputLabel = new Label("Pick a number between 1-25");
//set center panel
cPanel = new Panel();
tcPanel = new Panel();
bcPanel = new Panel();
one = new Button("Submit your Guess");
one.addActionListener(this);
lbl1 = new Label();
lbl2 = new Label();
lbl3 = new Label("WOW, That guess was high");
lbl3.setBackground(Color.red);
txt = new TextField();
lbl4 = new Label("Whoa, you hit the bottom, try a higher number");
lbl4.setBackground(Color.blue);
//set topcenter GridLayout
tcPanel.setLayout (new GridLayout(3,1,5,5));
tcPanel.add(lbl1);
tcPanel.add(one);
one.addActionListener(this);
tcPanel.add(lbl2);
//set bottomcenter GridLayout
bcPanel.setLayout (new GridLayout(3,1,5,5));
bcPanel.add(lbl3);
bcPanel.add(txt);
bcPanel.add(lbl4);
//combine tc and bc panels
cPanel.setLayout(new BorderLayout());
cPanel.add(tcPanel, BorderLayout.WEST);
cPanel.add(bcPanel, BorderLayout.EAST);
//set layout and label for top
nPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
nPanel.add(outputLabel);
//set layout and label for bottom
sPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
sPanel.add(bottom);
//set layout for the Applet
this.setLayout(new BorderLayout());
add(nPanel, BorderLayout.NORTH);
add(cPanel, BorderLayout.CENTER);
add(sPanel, BorderLayout.SOUTH);
}
public void actionPreformed(java.awt.event.ActionEvent e)
{
number = Integer.parseInt(txt.getText());
Random generator = new Random();
cnumber = generator.nextInt(MAX) + 1;
}
}

New Topic/Question
Reply




MultiQuote









|