Hey,
I seem to have a problem on a Java Swing Program with ActionListener. I've tried to use getSource in our class but seem don't have an idea why it won't work when I tried to program at home. ( I'm using an earlier version of JCreator in school and a JCreator Pro here at home, Does that affect the program at all? )
Here's the code:
The error text:
Thank You!
I seem to have a problem on a Java Swing Program with ActionListener. I've tried to use getSource in our class but seem don't have an idea why it won't work when I tried to program at home. ( I'm using an earlier version of JCreator in school and a JCreator Pro here at home, Does that affect the program at all? )
Here's the code:
Code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Group2 extends JFrame implements ActionListener{
public void Group2(){
JLabel text = new JLabel("Enter a number to partition: ");
JTextField input = new JTextField(15);
JButton submit=new JButton("Submit");
String listboxitems[]={"5","1111111","111111111","1111111111"};
JList listbox = new JList(listboxitems);
JLabel timeprocessed=new JLabel("It x milliseconds to process the output");
setSize(350, 250);
setTitle("Group 2 COPRO2 & DATASTRUCT Project");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
FlowLayout layoutManager = new FlowLayout(FlowLayout.CENTER);
layoutManager.setHgap(10);
layoutManager.setVgap(10);
setLayout(layoutManager);
getContentPane().setComponentOrientation(ComponentOrientation.LEFT_TO_RIGHT);
getContentPane().add(text);
getContentPane().add(input);
getContentPane().add(submit);
getContentPane().add(listbox);
getContentPane().add(timeprocessed);
submit.addActionListener(this);
}
public void actionPerformed(ActionEvent ae){
if(ae.getSource()==submit){
timeprocessed.setVisible(true);}
else{
System.out.println("error");
}
}
public static void main(String[] args) {
new Group2().setVisible(true);
}
}
Code:
C:\Documents and Settings\User\Desktop\Group2.java:31: cannot find symbol
symbol : variable submit
location: class Group2
if(ae.getSource()==submit){
^
C:\Documents and Settings\User\Desktop\Group2.java:32: cannot find symbol
symbol : variable timeprocessed
location: class Group2
timeprocessed.setVisible(true);}
^
2 errors
Comment