Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

J++

Posted on 1998-05-05
4
Medium Priority
?
267 Views
Last Modified: 2010-04-16
import java.awt.event.*;

gives me an error, Undefined package 'event'
I use version  1.0 ?
0
Comment
Question by:admiral
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 

Expert Comment

by:Charmaine041198
ID: 1220585
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.

0
 

Author Comment

by:admiral
ID: 1220586
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;
    }
 }

0
 

Expert Comment

by:Charmaine041198
ID: 1220587
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++.
0
 
LVL 1

Accepted Solution

by:
dufort earned 100 total points
ID: 1220588
Where did you get this example? Here's your problem: you have a JDK 1.1 examples but a JDK 1.0 development tool. Let's call it a mismatch! If you want to learn Java, you have two choices:

1. Keep using this version of J++, stick to the 1.0 model, and get examples from old Java books (I would suggest the first version of "Java in a nutchell" from O'Reilly & Associates), or:

2. Keep your book (or whatever source for your example) and find a development tool that supports the 1.1 model.

I would suggest solution #2, because you will have to do this one day or another. I guess that you could get a low-cost upgrade for J++. Or, browse a little at http://www.davecentral.com (or somewhere else) to find shareware tools such as JPad and ED4W.

By the way, just for the fun of it, here is your example "translated" in the JDK 1.0 model. I guess it will work perfectly in your version of J++.

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

public class ThirdMethod extends Applet
      {
       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);
          }

          public boolean handleEvent(Event e)
          {
              if((e.id == Event.ACTION_EVENT) && (e.target == pressMe))
              {
                  String newText;
                 String userName;
                  userName = theName.getText();
                  newText = getGreeting(userName);
                  theLabel.setText(newText);
                                          
                  return true;
                }
                return false;
         }
                              
          public String getGreeting(String Name)
          {
            String greeting;
            greeting ="Hi " + Name +"!";
            return greeting;
          }
}

0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
This video teaches viewers about errors in exception handling.
Suggested Courses

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question