aspose file tools*
The moose likes Beginning Java and the fly likes awt classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "awt classes" Watch "awt classes" New topic
Author

awt classes

Sartaj Syed
Greenhorn

Joined: Nov 11, 2001
Posts: 22
I am having some problem with the following code. Please help

import java.awt.*;
import java.awt.AWTEvent;
public class TS1 extends Frame {
TS1(){
super("Project Development Coordination System");
setSize(500,500);
setLayout(new BorderLayout());

//Build and add 1st Panel of TS1
Panel p1 = new Panel(new BorderLayout());
TextField Title = new TextField();
Title.setFont(new Font("Sansserif", Font.BOLD, 48));
Title.setText("HORNSONIC");
Title.setEditable(false);
TextField Name = new TextField();
Name.setFont(new Font("Sansserif", Font.BOLD, 30));
Name.setText("Hera International, Inc.");
Name.setEditable(false);
p1.add(Title, BorderLayout.NORTH);
p1.add(Name, BorderLayout.CENTER);
add(p1, BorderLayout.NORTH);
//Build and add 2nd Panel
Panel PDCS = new Panel();
TextField pdcs = new TextField();
pdcs.setFont(new Font("Sanserif", Font.BOLD, 22));
pdcs.setText("Project Development Coordination System");
pdcs.setEditable(false);
PDCS.add(pdcs);
Button input = new Button("INPUT");
input.addActionListener(new In ());
PDCS.add(input);
Button feedback = new Button("FEEDBACK");
feedback.addActionListener(new Feed());
PDCS.add(feedback);
add(PDCS, BorderLayout.CENTER);

//class In
class In implements ActionListener{
public void actionPerformed(ActionEvent ae){
System.out.println("In");}}
// class Feed
class Feed implements ActionListener{
public void actionPerformed(ActionEvent AE){
System.out.println("Feed");}}
The compilation errors I am gettin says cannot resolve symbol ActionListener. and ActionEvent
Ian Darwin
author
Ranch Hand

Joined: Aug 03, 2001
Posts: 64
Originally posted by Sartaj Syed:
I am having some problem with the following code. Please help

import java.awt.*;
import java.awt.AWTEvent;
public class TS1 extends Frame {
...
}
The compilation errors I am getting says cannot resolve symbol ActionListener. and ActionEvent

You need to import java.awt.event.*. This is not the same as the import of java.awt.AWTEvent (which, btw, is redundant since you already imported java.awt.*). So change that second import to
import java.awt.event.*;
and your code should compile (if that's the only compile error you were getting).


Ian Darwin
Many questions are answered in my Java Cookbook, 2nd Edition
Cindy Glass
"The Hood"
Sheriff

Joined: Sep 29, 2000
Posts: 8521
Hi Ian,
Haven't seen you around lately. Just had your book out yesterday for someone at work .
Sartaj Syed
Greenhorn

Joined: Nov 11, 2001
Posts: 22
Thanks Ian that solved my problem as far as compilation goes.
I need some more help . This particular code was like the main screen of my application . I want to use one button to open up another screen called Input screen and the second button to open up a feedback screen. I have the code for Input in an Input class ( in the same file) and the code(everything compiles). for Feedback in a feedback class. How do I do this?
As of now the main screen has these buttons but clicking them the action performed method does just a print statement.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: awt classes
 
Similar Threads
Display in the panels
small application
take a look at this please
Help-needed
buttons don't work