• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

awt classes

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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).
 
"The Hood"
Posts: 8521
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ian,
Haven't seen you around lately. Just had your book out yesterday for someone at work .
 
Sartaj Syed
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic