Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-31-2004, 06:29 PM   #1
Registered: Oct 2003
Distribution: Mandrake 9
Posts: 46

Rep: Reputation: 15
Java "<identifier> expected" error.

I have a couple simple lines of code, one of which is giving me trouble.

JTextField txtDisplay = new JTextField();
The text field is created fine, but configuring the alignment is giving trouble. If you see the trouble with my code, please let me know.
The definition for setHorizontalAlignment is:

public void setHorizontalAlignment(int alignment)

Here is my error:

calculator/ [12:1] <identifier> expected
1 error
Errors compiling calculator
Old 08-31-2004, 06:44 PM   #2
Senior Member
Registered: Oct 2003
Location: Zurich, Switzerland
Distribution: Debian/unstable
Posts: 1,357

Rep: Reputation: 47
This compiles for me:
import javax.swing.*;

public class Foo {
    public static void main(String[] args) {
	JTextField txtDisplay = new JTextField();
Old 09-01-2004, 12:20 AM   #3
Mega Man X
LQ Guru
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 64
I'm not sure if you know about this:

but it has a lot of examples about Java classes. I also agree with ToniT, looks like you are forgetting to import the classes...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
What is a "string identifier" and how do I set it Ebisu_Dave Linux - Hardware 1 07-15-2005 05:11 PM
Java error "Exception in thread "main" java.lang.StackOverflowError" nro Programming 1 09-04-2004 03:47 AM
"undeclared identifier is reported only once for each " KDel Linux - Software 1 04-29-2004 05:40 PM
I cannot use "java chat". Browser says plugin required "x-java-vm". jdruin Linux - Software 4 04-18-2004 05:44 PM
lpd "no identifier" error abyss Linux - Software 0 08-28-2002 08:31 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:19 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration