Hi,
In this code:
DrawPanel.java
import java.awt.Graphics;
import javax.swing.JPanel;
public class DrawPanel extends JPanel
{
public void paintComponent(Graphics g)
{
super.paintComponent(g);
int width = getWidth();
int height = getHeight();
g.drawLine(0, 0, width, height);
g.drawLine(0, height, width, 0);
}
}
and this the application
DrawPaneTest.java
import javax.swing.JFrame;
public class DrawPaneTest {
public static void main(String args[])
{
DrawPanel panel = new DrawPanel();
JFrame application = new JFrame();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
application.add(panel);
application.setSize(250,250);
application.setVisible(true);
}
}
1- Who calls the method paintComponent() ?
2- What the purpose of super.paintComponent(g) and why there is no difference between keeping it or removing it from the source?
Any help is appreciated.