import javax.swing.*; import java.awt.*; public class Joonis2 extends JComponent{ Image pilt=Toolkit.getDefaultToolkit().getImage("javalogo.gif"); public void paintComponent(Graphics g0){ Graphics2D g=(Graphics2D)g0; g.setStroke(new BasicStroke(3)); //Joone paksus g.drawRect(10, 20, 30, 40); //vasakult, ülalt, laius, kõrgus g.setColor(Color.GREEN); g.fillOval(50, 20, 40, 30); g.setColor(Color.BLACK); g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g.drawLine(100, 20, 110, 50); //x1, y1, x2, y2 g.drawArc(120, 20, 30, 30, 90, 180); //vasakult, ülalt, laius, kõrgus, algnurk, kaarepikkus g.drawString("Tere!", 40, 80); g.drawImage(pilt, 40, 100, this); } public static void main(String[] arg){ JFrame f=new JFrame("Esimene aken"); f.setSize(300, 200); f.getContentPane().add(new Joonis2()); f.setVisible(true); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }