The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2002

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

Only import problem

Posted by Kishori Sharan on January 25, 2002 at 2:55 PM

Hello
Except import statements (I don't know if you forgot to mention import statements in your posting) there is nothing wrong with your code. import java.awt.* ; will only import classes on demand from java.awt package and nothing else. There is another package java.awt.event that you need to import classes from.
Thanks
Kishori
////////////////////////////////////////////////////////////
import javax.swing.* ;
import java.awt.* ;
import java.awt.event.* ;

public class HoursTrackerGUI extends JFrame {
private JButton setStartTime = new JButton("Clock in");
public HoursTrackerGUI() {
super();
this.setSize(400, 300);
Container contents = this.getContentPane();
contents.setLayout(new FlowLayout());
contents.add(setStartTime);
setStartTime.addActionListener(new SSTListener());
}

private class SSTListener implements ActionListener {
public void actionPerformed(ActionEvent e) {
System.out.println("The button was pressed!");
}
}

public static void main ( String[] args ) {
HoursTrackerGUI t = new HoursTrackerGUI ( ) ;
t.show() ;
}
}



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us