JTextArea wont append ...
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Anonymous
Posted On:   Monday, May 13, 2002 01:53 PM

Hi, I have a JTextArea called jTextArea1 in a Gui class ( ChatPanel )I add it into a JScrollPane using : static JTextArea jTextArea1 = new JTextArea(); static JScrollPane jScrollPane1 = new JScrollPane(jTextArea1); They are both class variables, I have a listener on a button called GroupSelectButton In the listener method of the ( ChatPanel ) method i can append text to the JTextArea as much as i want... I want to be able to append text from *another class so i wrote a function to do this in the Gui class called appendText , i have it here below : void appendText(String input)    More>>

Hi,



I have a JTextArea called jTextArea1 in a Gui class

( ChatPanel )I add it into a JScrollPane using :


			
static JTextArea jTextArea1 = new JTextArea();

static JScrollPane jScrollPane1 =

new JScrollPane(jTextArea1);


They are both class variables,



I have a listener on a button called GroupSelectButton


In the listener method of the ( ChatPanel ) method i can append text to the JTextArea as much as i want...



I want to be able to append text from *another class so i wrote a function to do this in the Gui class called appendText , i have it here below :


			
void appendText(String input)

{

jTextArea1.append("
" + input);

System.out.println("What is in the jTextArea *after the
append" + jTextArea1.getText());

}



My problem is that when i setup an object reference to ChatPanel class in another class ( ChatCode class ) like :


			
ChatPanel myChatPanel = new ChatPanel();

myChatPanel.appendText(message);



It seems to append the text to the textArea alright ,

** But it wont display the new text in the app **



I've tried calling jTextArea1.repaint() , and jScrollPane1.repaint();

but that didnt do it .

I've also tried removing everything from the JScrollpane viewport and adding in the JTextArea again like so :


			
jScrollPane1.getViewport().remove(jTextArea1);

jTextArea1.append("
" + input);

jScrollPane1.getViewport().add(jTextArea1);


But this does nothing either ...


What am I doing wrong here ?

I'm sure its something simple but i just cant get it to work ...


Thanks for the help,

Michael

   <<Less
About | Sitemap | Contact