Tutorial by Examples

Intro The Graphics class allows you to draw onto java components such as a Jpanel, it can be used to draw strings, lines, shapes and images. This is done by overriding the paintComponent(Graphics g) method of the JComponent you are drawing on using the Graphics object received as argument to do the...
Images can be drawn onto a JComponent using the drawImage method of class Graphics: loading an image BufferedImage img; try { img = ImageIO.read(new File("stackoverflow.jpg")); } catch (IOException e) { throw new RuntimeException("Could not load image", e); } dr...
The MyFrame class the extends JFrame and also contains the main method import javax.swing.JFrame; public class MyFrame extends JFrame{ //main method called on startup public static void main(String[] args) throws InterruptedException { //creates a frame window ...

Page 1 of 1