Bookmark Topic Watch Topic
  • New Topic

JTextPane is not showing the messages when the window is minimized

 
Jaheer Abbas Syed
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Report post to moderator
i'm trying to develop a Chat Application.In Chat Client i have used JTextPane to add different colors to the messages.its working properly.but when the Chat Client is minimized and when my method try to add text to JTextPane using setText().it is added to the JTextPane but it is not visible when i maximize the window.it is showing blank JTextPane.if the window(JFrame) is in maximized state then the message is visible. whent i try to select the area in JTextPane then it is showing the message that had been added.i want to show the message when user maximize the window.

How can i make the JTextPane show the messages when it is minimized.

Here is my Code.

JTextPane messages;


String mymsg = messages.getText();
int bodystrt = mymsg.indexOf("<body>");
int bodyend = mymsg.indexOf("</body>");
String body = mymsg.substring(bodystrt + 6, bodyend - 7);
String msgs[] = body.split("<br>");
System.out.println("--- After Splitting the Message ---");
String styledText = new String();
for (int i = 0; i < msgs.length; i++) {
styledText += msgs[i] + "<br>";
}
if (m.userName.equals(ChatClient.userName)) {
messages.setText(styledText + "<font color='blue'>" + time + m.userName + ": </font>" + m.userData);
} else {
if (m.userName.startsWith("Server")) {
System.out.println("Window Active:"+this.isActive());
if (this.getState() == 1 || this.getState()==0 || !this.isActive()) {
this.setState(0);
this.show();
}
messages.setText(styledText + "<font color='red'>" + time + m.userName + ": </font>" + m.userData);
} else {
this.setState(0);
messages.setText(styledText + "<font color='green'>" + time + m.userName + ": </font>" + m.userData);
this.show();

}

}
 
Rob Spoor
Sheriff
Posts: 20822
68
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please Use One Thread Per Question. Continuing here.
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!