Java "<identifier> expected" error.
I have a couple simple lines of code, one of which is giving me trouble.
Code:
JTextField txtDisplay = new JTextField(); The definition for setHorizontalAlignment is: public void setHorizontalAlignment(int alignment) Here is my error: calculator/calculator.java [12:1] <identifier> expected txtDisplay.setHorizontalAlignment(JTextField.RIGHT); -------------------------------------^ 1 error Errors compiling calculator |
This compiles for me:
Code:
import javax.swing.*; |
I'm not sure if you know about this:
http://java.sun.com/j2se/1.4.2/docs/api/ but it has a lot of examples about Java classes. I also agree with ToniT, looks like you are forgetting to import the classes... |
All times are GMT -5. The time now is 05:48 AM. |