I am trying to change the default behavior of a JTextArea. I want to change the font, the font flags, and the font size of the text entered into the area. Here is my code in its amazing entirety:
Code:
JTextArea canvas = new JTextArea(30,70);
canvas.setFont(new Font("Arial", Font.BOLD | Font.ITALIC, 20));
I am getting a compiler error specifying "identifier expected" for the 2nd line. It is complaining about the call to setFont(), which is a method inherited from Component. I posted this on a programming-oriented forum on another site and everyone is baffled and says my code should be fine. I am using JDK5 and compiling using javac.
I am thinking that perhaps I have an error elsewhere (and above) in my code and that perhaps it is cascading down to this function call....
The weird thing is if I comment out the 2nd line and replace it with:
Locale l = canvas.getLocale();
it works fine. In other words, it handles other Component methods perfectly fine, which tells me it doesn't like my call to setFont. I checked the method's definition out in the java docs and according to Sun, the signature for setFont() is this:
public void setFont(Font f)
So I don't see what I am missing here...