This week's giveaways are in the MongoDB and Jobs Discussion forums.
We're giving away four copies of Mongo DB Applied Patterns and 4 resume reviews from Five Year Itch and have the authors/reps on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes Scrollbar flickers after using setText() Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of Mongo DB Applied Patterns this week in the MongoDB forum
or a resume review from Five Year Itch in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Reply 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: 32599
    
    4
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: 32599
        
        4
    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: 32599
        
        4
    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: 32599
        
        4
    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: 32599
        
        4
    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: 32599
        
        4
    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: jrebel
     
    subject: Scrollbar flickers after using setText()
     
    Similar Threads
    set TextField value from another class
    setText doesn't display html!
    Can I fill a text area with System.out?
    about JTextField
    Problem with JEditorPane