Copyright Derek O'Reilly, Dundalk Institute of Technology (DkIT), Dundalk, Co. Louth, Ireland.
All graphical output to the screen is done via the paint() method
Example with paintComponent() method (Run Applet).
import java.awt.*; import javax.swing.*; public class PaintDemo extends JApplet { @Override public void init() { this.setContentPane(new View()); } public class View extends JPanel { @Override public void paintComponent(Graphics g) { g.drawLine(10, 10, 100, 50); } } }
Copyright Derek O' Reilly, Dundalk Institute of Technology (DkIT), Dundalk, Co. Louth, Ireland.