Thanks for the response. I found out that the flickers are actually caused by the JDialog containers used as control panels in my program. The reason for using JDialog instead of JToolBar is that I could not make JToolBar starting with float. Here is a sample code. You can see that the frame flickers when you drag it around with the JDialog containers on top of it.
import javax.swing.*;
import java.awt.*;
public class TestFlicker extends JFrame
{
public TestFlicker()
{
JDialog jdlCtrl[]=new JDialog[3];
JPanel jpl=new JPanel();
jpl.setPreferredSize(new Dimension(600,400));
jpl.setBackground(Color.blue);
setSize(600,400);
getContentPane().setLayout(new BorderLayout());
getContentPane().add(jpl, BorderLayout.CENTER);
pack();
setVisible(true);
for(int i=0; i<3; i++)
{
jdlCtrl=new JDialog(this);
jdlCtrl.setSize(100,100);
jdlCtrl.setVisible(true);
}
jdlCtrl[0].setLocation(100,20);
jdlCtrl[1].setLocation(100,140);
jdlCtrl[2].setLocation(100,300);
}
public static void main(String args[])
{
new TestFlicker();
}
}
Use the "Code" formatting tags when posting code so the code is readable and compileable.
This seems to be a "feature" of Swing. It even happens in the [url http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html#dialogdemo]Dialog Demo[/url] from the Swing tutorial. Its more noticable in your example because you've changed the background to something other than the default gray.
It seems to work a little better when you add this property at the start of your program:
System.setProperty("sun.awt.noerasebackground", "true");
> By the way, I did use the the code tag when copy and paste the code.
> Do not know why it does not format the code correctly.
No you didn't. Either the code would be formatted correctly, or the tags would appear in the posting.
Thats why the forum has a "Preview" button. So you can check you message before posting it.