Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

J++

Posted on 1998-05-05
4
Medium Priority
?
272 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
  • 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the scanner class in this video and are introduced to receiving user input for their programs. Additionally, objects, conditional statements, and loops are used to help reinforce the concepts. Introduce Scanner class: Importing…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

773 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