Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / October 2005

Tip: Looking for answers? Try searching our database.

Drawing custom JButton with no flicker

Thread view: 
Melinda - 11 Oct 2005 23:50 GMT
I'm drawing a custom jbutton by overriding update and paint in the ButtonUI
attached to the button.

The problem is that every graphic operation I do shows up immediately on
the screen, even before the function returns.
This is causing flicker (the whole background is redrawn to lighter shade
of color for rollover effect).

isDoubleBuffer() shows as true.

Any ideas on what options I have?

-Mel
Andrey Kuznetsov - 12 Oct 2005 00:56 GMT
> I'm drawing a custom jbutton by overriding update and paint in the
> ButtonUI
[quoted text clipped - 8 lines]
>
> Any ideas on what options I have?

Since not every one here has magic ball, the best option is to post your
code.

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Melinda - 12 Oct 2005 01:40 GMT
>> I'm drawing a custom jbutton by overriding update and paint in the
>> ButtonUI
[quoted text clipped - 11 lines]
> Since not every one here has magic ball, the best option is to post
> your code.

The question is about the behavior of swing not my code, so one does not
need a "crystal ball" unless one doesn't know how swing behaves in this
situation, in which case one doesn't need to answer.

Swing behavior:
 Graphic operations performed within an overload of the Update() function
of a ButtonUI instance occur instantaneously.

Effect of swing behavior:
 This causes flicker as the background of the button is drawn then the
contents of the button are drawn.

Question about general methadology required to counter or work with this
behavior:
 What is the general method of drawing a custom JButton so that all the
graphics are presented at once (so as not to cause flicker)?
Andrey Kuznetsov - 12 Oct 2005 02:40 GMT
> The question is about the behavior of swing not my code, so one does not
> need a "crystal ball" unless one doesn't know how swing behaves in this
> situation, in which case one doesn't need to answer.
because you overridden update, you have changed Swing behavior.

> Swing behavior:
>  Graphic operations performed within an overload of the Update() function
> of a ButtonUI instance occur instantaneously.

this is surely due error in your code
in general you should not override update.
you may override paint.

HTH

Signature

Andrey Kuznetsov
http://uio.imagero.com Unified I/O for Java
http://reader.imagero.com Java image reader
http://jgui.imagero.com Java GUI components and utilities

Thomas Weidenfeller - 12 Oct 2005 08:24 GMT
> The question is about the behavior of swing not my code, so one does not
> need a "crystal ball" unless one doesn't know how swing behaves in this
> situation, in which case one doesn't need to answer.

I take it that you don't really want help. So, can you please post your
lectures to another group? Thanks for playing, and don't let the door
hit you on your way out.

http://www.catb.org/~esr/faqs/smart-questions.html
http://www.physci.org/codes/sscce.jsp
http://groups.google.com/group/comp.lang.java.help/msg/54df002655344dcc

/Thomas
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

Roedy Green - 12 Oct 2005 12:19 GMT
>The question is about the behavior of swing not my code, so one does not
>need a "crystal ball" unless one doesn't know how swing behaves in this
>situation, in which case one doesn't need to answer.

If you are so all fired sure you know the cause of your trouble, you
should be able to fix it yourself.

Others wanted to take a step back.  paintImmediately causes immediate
painting, but update repaints wait on the queue like anything else.
The people who were trying to help you did not accept your diagnosis.

I think I know your  trouble and I gave you the answer in another
post.  For flicker problems generally, see
http://mindprod.com/jgloss/flicker.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Roedy Green - 12 Oct 2005 12:11 GMT
>I'm drawing a custom jbutton by overriding update and paint in the ButtonUI
>attached to the button.

For JButton, you override paintComponent, not paint.

see http://mindprod.com/jgloss/paint.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.