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 / January 2004

Tip: Looking for answers? Try searching our database.

My window flickers shortly when appears.

Thread view: 
Matteo - 26 Jan 2004 09:58 GMT
I'm writing a gui based application on java 1.4.2 on win 2000.

I have some windows that open after a a button press.
Every time I open a new window this "flickers" shortly, it appears
like it is drawed and then soon redrawed.
The very simple code opening each window is:

Button.addActionListener(new ActionListener()
{
 public void actionPerformed(ActionEvent e)
 {                          
   new windowFinestra.setVisible(true);
 }
});

Where newWindow is a JFrame already built and initialized.
By default all is doublebuffered.
Can you help me avoiding the flickering? What could it be? The layout
managers reshaping the window after it is made visible?

Thank you very much,
Matteo
Ryan Stewart - 26 Jan 2004 12:11 GMT
> I'm writing a gui based application on java 1.4.2 on win 2000.
>
[quoted text clipped - 15 lines]
> Can you help me avoiding the flickering? What could it be? The layout
> managers reshaping the window after it is made visible?

It probably could be about a hundred different things. How about some code
to look at? As lean as possible:
http://www.physci.org/codes/sscce.jsp
Matteo - 27 Jan 2004 09:54 GMT
> > I'm writing a gui based application on java 1.4.2 on win 2000.
> >
[quoted text clipped - 10 lines]
> to look at? As lean as possible:
> http://www.physci.org/codes/sscce.jsp

Sorry, you are right but the program is too big with too many UI
elements.
Thank to you, trying to reduce it to make a sscce I've found the line
of code that is responsible of the "flickering" of myWindow:

Button.addActionListener(new ActionListener()
{
 public void actionPerformed(ActionEvent e)
 {
   myWindow.update();  // <- this is the guilty line
   myWindow.setVisible(true);
 }
});

myWindow is a JFrame already built and initialized and the update()
method is full of setText() on a dozen of JTextField of myWindow.
it appears that the update routine happens after the setVisible,
giving me the "flickering" effect on the gui.
I have tried to put the two lines into a SwingUtilities.invokeLater
thread but with no result.
I have noted too that in all my other gui that are updated just before
being visible there is a flickering effect. The update are always some
JTextField.setText and some JTextBox.setSelected on the invoked
window.

Thank you,
Matteo

I've further analyzed the c
Andrew Thompson - 27 Jan 2004 10:26 GMT
...
| > It probably could be about a hundred different things. How about some code
| > to look at? As lean as possible:
[quoted text clipped - 4 lines]
| Thank to you, trying to reduce it to make a sscce I've found the line
| of code that is responsible of the "flickering" of myWindow:

:)  I am the author of the document you read.
But Ryan made it readable.     ;-)

--
Andrew Thompson
* http://www.PhySci.org/codes/ Web & IT help
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Matteo - 28 Jan 2004 10:16 GMT
> > > I'm writing a gui based application on java 1.4.2 on win 2000.
> > >
[quoted text clipped - 38 lines]
> Thank you,
> Matteo

I have resolved the problem with wrapping the myWindow.update() with a SwingWorker.

Matteo


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.