aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Scrollbar flickers after using setText() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Scrollbar flickers after using setText()" Watch "Scrollbar flickers after using setText()" New topic
Author

Scrollbar flickers after using setText()

Katja Ernst
Greenhorn

Joined: Dec 30, 2005
Posts: 12
hi, im using a jeditorpane to display html text. this works fine until the scrollbars are shown. the scrollbars flicker after the text is put into the editorpane using setText().

how can i avoid that?

thanks :-)
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 36478
    
  16
Thank you for the query. It is difficult to know what to say without more details, but please consider these two questions, which might help you out:
  • Have you got super.paintComponent(); as your first statement in your paintComponent method?
  • Where are you calling repaint(); ?

  • CR
    Katja Ernst
    Greenhorn

    Joined: Dec 30, 2005
    Posts: 12
    hi, im not calling repaint as it is automatically called, isnt it? i have a simple jeditorpane and a jscrollpane:

    JEditorPane p = new JEditorPane();
    p.setContentType("text/html");
    JScrollPane jsp = new JScrollPane(p);

    String s = "<html><body>this is sentence...</body></html>"

    as soon as the string s is too long to be displayed without scrolling the scrollbars are displayed and the scrollbars are flickering. do you need more details?

    thanks :-)
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 36478
        
      16
    I think I do need more details, please, yes.
    CR
    Katja Ernst
    Greenhorn

    Joined: Dec 30, 2005
    Posts: 12
    hi, hm...what kind of details do you need?

    thanks in advance:-)
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 36478
        
      16
    I have tried it myself, and it doesn't flicker.
    Have you included the setEditable(false) call on your JEditorPane?
    Try that.

    CR
    Katja Ernst
    Greenhorn

    Joined: Dec 30, 2005
    Posts: 12
    hi, yes, i set it using: pane.setEditable(false); so i think this is not the problem. can you post your code?

    thanks
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 36478
        
      16
    It is a crude thing, with the wrong formatting; you get one button at the top and one at the bottom. Maybe if I had used GridLayout rather than Border it would have been better. You get your scroll in the middle, a button which adds the Lord's Prayer (Paternoster) to the html text, and a button which exits the whole application.

    You will have to get rid of the line breaks in the setText() call before you try compiling the code.

    [Change: There appeared to be line breaks when I posted the reply, but they disappeared when I looked at the final result, so you might not have to get rid of line breaks. ]

    CR
    [ January 02, 2006: Message edited by: Campbell Ritchie ]
    Katja Ernst
    Greenhorn

    Joined: Dec 30, 2005
    Posts: 12
    hi, hm, you were right. the scrollbars in your application dont flicker. but the scrollbars in my applet do still flicker...:-|.

    more ideas?

    thanks
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 36478
        
      16
    Don't know.


    I never knew it was an Applet; are you in the correct forum?
    Please show us your code, so we can see the difference.
    Katja Ernst
    Greenhorn

    Joined: Dec 30, 2005
    Posts: 12
    hi, unfortunately not...to much code. maybe i have to overwrite the paint method. hm

    thanks
    Campbell Ritchie
    Sheriff

    Joined: Oct 13, 2005
    Posts: 36478
        
      16
    Show us your paint() and init() methods, or even "edited highlights."

    This is a public discussion and the idea of this forum is for us all to be able to learn from one another. We shan't do that wihtout seeing more of your code.
    Katja Ernst
    Greenhorn

    Joined: Dec 30, 2005
    Posts: 12
    hi, im sorry, i really cant post the code. is there any difference between using this in an applet or an application?

    thanks:-)
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Scrollbar flickers after using setText()
     
    Similar Threads
    Problem with JEditorPane
    setText doesn't display html!
    Can I fill a text area with System.out?
    set TextField value from another class
    about JTextField