Chris
2011-12-10 19:49:51 UTC
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class LoginGUI extends JFrame implements ActionListener {
JTextField username = new JTextField(15);
JPasswordField password = new JPasswordField(15);
JButton submit = new JButton("Submit");
JButton cancel = new JButton("Cancel");
public LoginGUI(){
super("Login to the Project Management System");
setBounds(150,200,200,175);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane = new JPanel();
JLabel userLabel = new JLabel("Username: ");
JLabel passLabel = new JLabel("Password: ");
pane.add(userLabel);
pane.add(username);
pane.add(passLabel);
pane.add(password);
pane.add(submit);
submit.addActionListener(this);
pane.add(cancel);
cancel.addActionListener(this);
add(pane);
setVisible(true);
}
public void actionPerformed(ActionEvent evt) {
Object source = evt.getSource();
if(source == submit){
System.out.println("submit hit");
}else if(source == cancel){
setVisible(false);
}
}
public static void main(String[] args) {
LoginGUI login = new LoginGUI();
}
}
And my compile error is:
Exception in thread "AWT-EventQueue-0" java.lang.Error: Unresolved compilation problem:
out cannot be resolved or is not a field
at LoginGUI.actionPerformed(LoginGUI.java:45)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Thanks!