Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JTextPane refresh issue  RSS feed

 
Joe Crew
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I'm having a problem with a JTextPane in an Applet. I think part of the problem may be using an Applet, I don't know. Anyway I have dropped a JTextPane in a JScrollPane so I can create documents with multiple style attributes. My problem is I can't see any modifications I make to the document without giving focus to an other application I have open. Then when I give focus back to my browser and bring it to the front again, the change has been made.
For example, my JTextPane has no blinking cursor. I click on the JTextPane and nothing "appears" to happen. I click on another program in my taskbar, then click back on my browser, and the cursor is waiting at the end of my document. Keep in mind here that the cursor is not blinking. Well then I can hit my backspace key, for example, 10 times. Nothing appears to happen. But I can click on another app I have open, then return to my browser where the applet is located, and 10 characters from where my non blinking cursor was located, have been removed. I'm new to swing but it seems to me like I should not have to repaint or refresh what is basically a text area. I have also converted this applet to an application and it works just fine and dandy. No repaint or refresh issues at at all. Can someone who has maybe used a JTextPane maybe pass along some advice what is happening here. I can post some code but it's pretty basic really so I thought I would hold off for now.
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you using Applet or JApplet. Don't mix swing and awt components.
 
Joe Crew
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,
Thanks for your reply. I know we're kinda talking about applets here now but I thought it was JTextPane issue which is why I posted the question here in this newsgroup to begin with.
I am using an Applet, not JApplet. This is my first Swing Applet and I didn't even consider that being an issue. I should probably change the buttons to JButtons (in my makeshift toolbar) too. I'll let you know what happens.
Joe
 
Joe Crew
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,
You were completely correct. It wasn't the JTextPane at all. I was doing 3 things incorrectly since this was my first swing applet.
1: I was mixing Swing and AWT components
2: I wasn't using a JApplet
3: i wasn't using getContentPane().add(someJComponent);
Thanks for setting me along the right path.
Joe
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!