aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes  help me ! what's wrong with my JDK1.2.2 compiler 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark " help me ! what Watch " help me ! what New topic
Author

help me ! what's wrong with my JDK1.2.2 compiler

sean zang
Ranch Hand

Joined: Apr 22, 2000
Posts: 33
HI, Jim, Tony ,and Maha AaNa
I try to complie the following code, But the compiler give the the silly message .I try to reinstall the JKD1.2.2 , but the problem stills exsit. please help me to check wether my compiler works correctly.
<pre>

import java.awt.*;
import java.awt.event.*;
import java.applet.Applet;
public class TextDemo extends Applet implements ActionListener {
TextField textField;
TextArea textArea;
String newline;
public void init() {
textField = new TextField(20);
textArea = new TextArea(5, 20);
textArea.setEditable(false);
//Add Components to the Applet.
GridBagLayout gridBag = new GridBagLayout();
setLayout(gridBag);
GridBagConstraints c = new GridBagConstraints();
c.gridwidth = GridBagConstraints.REMAINDER;
c.fill = GridBagConstraints.HORIZONTAL;
gridBag.setConstraints(textField, c);
add(textField);
c.fill = GridBagConstraints.BOTH;
c.weightx = 1.0;
c.weighty = 1.0;
gridBag.setConstraints(textArea, c);
add(textArea);
textField.addActionListener(this);
newline = System.getProperty("line.separator");
}
public void actionPerformed(ActionEvent evt) {
String text = textField.getText();
textArea.append(text + newline);
textField.selectAll();
}
}

</pre>
// look the following error message, why new TextField(20) is wrong.
C:\java\TextDemo.java:15: Wrong number of arguments in constructor.
textField = new TextField(20);
^
C:\java\TextDemo.java:35: Method addActionListener(TextDemo) not found in class TextField.
textField.addActionListener(this);
^
C:\java\TextDemo.java:41: Method getText() not found in class TextField.
String text = textField.getText();
^
C:\java\TextDemo.java:43: Method selectAll() not found in class TextField.
textField.selectAll();
^
4 errors
Process completed with exit code 1

[This message has been edited by maha anna (edited April 29, 2000).]
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
sean zang,
I copied your code and compiled . It compiles fine. I am also using jdk1.2.2 on win 98. All java related executables will be kept in the_installed_dir\bin directory.
Try to write a simple HellowWorld.java which doesn't import any pack as such and compile and run. We will go from there. And tell us what is the error message you get now.
<pre>
class Test {
public static void main(String[] args) {
System.out.println("HelloWorld");
}
}
</pre>
regds
maha anna
[This message has been edited by maha anna (edited April 29, 2000).]
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
IF I WERE TO GUESS...
I believe that you have another "TextField" class defined somewhere in your classpath. Try this - instead of just 'TextField' , write out java.awt.TextField anywhere you previously had just TextField in your code. If this compiles, search your hard drive for TextField.class (search .jar files too). That should give you the solution to your problem if I'm guessing right.
sean zang
Ranch Hand

Joined: Apr 22, 2000
Posts: 33
HI,
Java Nut
your "guess" is definetely helpful. Yes long time ago I declared the class named TextFied, so It always "overide" JAVA lib TextField.I change my classpath searching order, It works correctlly.
Thank you very much your great guess
maha anna
Ranch Hand

Joined: Jan 31, 2000
Posts: 1467
Thank you Java Nut.
regds
maha anna.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help me ! what's wrong with my JDK1.2.2 compiler
 
Similar Threads
grid bag panels overlap : please HELP if you can
Making two applets talk
GridbagLayout help needed (this time with code tags :-) )
ScrollBar Problem
Error in Eclipse and Netbeans