Writing a line in a JTextArea from another class

Posted by Christopher Nastovski on Stack Overflow See other posts from Stack Overflow or by Christopher Nastovski
Published on 2012-10-01T20:38:23Z Indexed on 2012/10/01 21:37 UTC
Read the original article Hit count: 222

Filed under:
|
|

I'm trying to use a Method in my class 'Visual' to write a line of code into a JTextArea and it prints when I call it from 'Visual' but when I call it from 'Login' It only prints Text into the Console, not to the TextArea.

private static Visual Visual;
Visual.WriteLine("I'm sorry, your username or password is incorrect. Please try again.");

or

private static Visual Visual = new Visual();
Visual.WriteLine("I'm sorry, your username or password is incorrect. Please try again.");

Dont work form 'Login'

But,

WriteLine("Test"); 

works from 'Visual', the class that the method is in.

Here's the method in 'Visual'

public void WriteLine(String Text) {
    System.out.println(Text);
    SystemFeed.append(Text.toString() + "\n");
    SystemFeed.setCaretPosition(SystemFeed.getDocument().getLength());
}

© Stack Overflow or respective owner

Related posts about java

Related posts about swing