import java.awt.*; import java.awt.geom.*; import java.awt.image.*; import java.applet.*; import java.awt.event.*; public class Tool extends Applet implements AdjustmentListener, ActionListener{ Scrollbar kerimisriba=new Scrollbar(Scrollbar.VERTICAL, 1, 5, 1, 100); //algväärtus, nupu suurus, vähim ja suurim väärtus Scrollbar kerimisriba2=new Scrollbar(Scrollbar.VERTICAL, 0, 5, 0, 100); Scrollbar kerimisriba3=new Scrollbar(Scrollbar.HORIZONTAL, 1, 5, 1, 70); TextField tf=new TextField(4); Panel p=new Panel(); int arv; int arv2; int arv3; int arv4; int i; int n1x=200; int n1y=120; int n2x=300; int n2y=120; int n3x=200; int n3y=180; int n4x=300; int n4y=180; int n5x=200; int n5y=250; int n6x=300; int n6y=250; int n7x=270; int n7y=270; int n8x=370; int n8y=270; int n9x=200; int n9y=350; int n10x=300; int n10y=350; int n11x=270; int n11y=370; int n12x=370; int n12y=370; int keskp=95; public Tool(){ setLayout(new BorderLayout()); add("West", kerimisriba); add("East", kerimisriba2); add("South", kerimisriba3); add("North",p); p.add(tf); kerimisriba.addAdjustmentListener(this); kerimisriba2.addAdjustmentListener(this); kerimisriba3.addAdjustmentListener(this); tf.addActionListener(this); } public void paint(Graphics tool){ //kella joonistamine tool.drawOval(50,70,100,100); tool.drawOval(55,75,90,90); tool.drawOval(95,115,10,10); //kella osutid //suurem tool.drawLine(100,120,100,75); //väiksem osuti tool.drawLine(100,120,120,100); //joonista tool tool.drawLine(n1x+arv3,n1y+arv,n2x+arv3,n2y+arv); tool.drawLine(n1x+arv3,n1y+arv,n3x+arv3,n3y+arv); tool.drawLine(n2x+arv3,n2y+arv,n4x+arv3,n4y+arv); tool.drawLine(n3x+arv3,n3y+arv,n4x+arv3,n4y+arv); tool.drawLine(n3x+arv3,n3y+arv,n5x+arv3,n5y); tool.drawLine(n4x+arv3,n4y+arv,n6x+arv3,n6y); tool.drawLine(n5x+arv3,n5y,n6x+arv3,n6y); tool.drawLine(n5x+arv3,n5y,n9x+arv3,n9y); tool.drawLine(n6x+arv3,n6y,n10x+arv3,n10y); tool.drawLine(n5x+arv3,n5y,n7x-arv3,n7y); tool.drawLine(n6x+arv3,n6y,n8x-arv3,n8y); tool.drawLine(n7x-arv3,n7y,n8x-arv3,n8y); tool.drawLine(n7x-arv3,n7y,n11x+arv2-arv3,n11y+arv2/2); tool.drawLine(n8x-arv3,n8y,n12x+arv2-arv3,n12y+arv2/2); } public void adjustmentValueChanged(AdjustmentEvent e){ arv=kerimisriba.getValue(); arv2=kerimisriba2.getValue(); arv3=kerimisriba3.getValue(); tf.setText(kerimisriba3.getValue()+""); repaint(); } public void actionPerformed(ActionEvent e){ repaint(); } public static void main(String argumendid[]){ Frame f=new Frame("Tool"); f.add(new Tool()); f.setSize(500, 500); f.setVisible(true); } }