Reputation: 1193
I have a JFrame with a JPanel in it. This JPanel is essentially a drawing panel. I am showing a JDialog to enter various parameters like radius and position to draw a circle. For showing JDialog i am using:
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
dialog.setVisible(true);
}
});
When the user presses the draw button on the jdialog, i dispose it (dialog.dispose();) and draw the circle based on the parameters entered by the user in Jdialog immediately after disposing.
The Circle draws but the JDialog also gets drawn erroneously. I am using repaint() call to draw the Circle. The painting gives desired result after i minimize and maximize the window:
Am i closing the Dialog in a wrong way?
Upvotes: 0
Views: 64
Reputation: 159864
Ensure
super.paintComponent();
is invoked when overriding paintComponent
when doing custom painting in Swing. This call will correctly paint the custom paint area. Without this call, background components will remain visible
Upvotes: 2