Link to home
Start Free TrialLog in
Avatar of admiral
admiral

asked on

J++

import java.awt.event.*;

gives me an error, Undefined package 'event'
I use version  1.0 ?
Avatar of Charmaine041198
Charmaine041198

In the awt 1.0 model, event is a class in the java.awt package so the statement should be changed to "import java.awt.event" OR "java.awt.*".
The compiler imterprets the asterisk in your code as a package name instead of a class name.

Avatar of admiral

ASKER

I tried the code you  gave - it would not compile
Here is all the code if it can help:

thank you

import java.awt.*;
import java.applet.*;
import java.awt.event.*;





public class ThirdMethod extends Applet implements ActionListener
{
 Label theLabel= new Label("Enter your first name");
 TextField theName= new TextField(20);
 Button pressMe = new Button("Ok");


    public void init()
    {
     add(theLabel);
     add(pressMe);
     add(theName);
     pressMe.addActionListener(this);
    }

    public void actionPerformed(ActionEvent theEvent)
    {
     String newText;
     String usersName;
     usersName= theName.getText();
     newText=getGreeting(userName);
     theLabel.setText(newText);
    }
    public String getGreeting(String Name)
    {
      String greeting;
      greeting ="Hi" + Name +"!";
      return greeting;
    }
 }

Visual J++ 1.0/1.1 does not support Sun jdk 1.1. Your code is written with jdk 1.1 so it can't be compiled in J++.
ASKER CERTIFIED SOLUTION
Avatar of dufort
dufort

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial