import javax.swing.*; import java.awt.*; public class GUITest { public static void main(String[] args) { Font font = new Font(Font.DIALOG, Font.PLAIN, 72); JLabel text = new JLabel(); text.setText("Hello, world!"); text.setFont(font); ImagePanel image = new ImagePanel(400, 400); JFrame window = new JFrame(); window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); window.setTitle("Hello, world!"); window.setLayout(new BorderLayout()); window.add(text, BorderLayout.NORTH); window.add(image, BorderLayout.SOUTH); window.pack(); window.setLocation(400, 400); window.setVisible(true); drawSquare(image, 100, 100, 100, 100, Color.BLUE); drawSquare(image, 150, 150, 100, 100, Color.RED); drawSquare(image, 200, 200, 100, 100, Color.GREEN); drawSquare(image, 0, 0, 200, 200, new Color(0.5f, 0.25f, 0.9f)); } public static void drawSquare(ImagePanel i, int topX, int topY, int height, int width, Color c) { for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { i.set(x + topX, y + topY, c); } } } }