Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.56 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.event.*;
  3. import java.applet.*;
  4.  
  5. public class A14k1_Kreis_Eingabe_M_R extends Applet implements ActionListener{
  6.     public class Kreis {
  7.         int x, y, r;
  8.        
  9.         public Kreis (int x1, int y1, int r1){
  10.             x=x1;
  11.             y=y1;
  12.             r=r1;
  13.         }
  14.        
  15.         public void zeichnedich (Graphics stift){
  16.             stift.drawOval(x-r, y-r, 2*r, 2*r);
  17.         }
  18.     }
  19.    
  20.     int x, y, r;
  21.    
  22.     TextField X = new TextField();
  23.     TextField Y = new TextField();
  24.     TextField R = new TextField();
  25.     Button z = new Button("Kreis zeichnen");
  26.    
  27.     public A14k1_Kreis_Eingabe_M_R () {
  28.         setLayout(null);
  29.        
  30.         X.setBounds(110,40,70,20);
  31.         Y.setBounds(200,40,70,20);
  32.         R.setBounds(20,40,70,20);
  33.         z.setBounds(80,80,130,30);
  34.         z.setBackground(Color.gray);
  35.        
  36.         add(X); add(Y); add(R); add(z);
  37.        
  38.         z.addActionListener(this);
  39.     }
  40.    
  41.     public void paint (Graphics stift) {
  42.         stift.drawString("Radius:",20,30);
  43.         stift.drawString("X Mittelpunkt:",110,30);
  44.         stift.drawString("Y Mittelpunkt:",200,30);
  45.     }
  46.    
  47.     public void actionPerformed (ActionEvent e) {
  48.         if(e.getSource()==this.z) {
  49.             x=Integer.parseInt(X.getText());
  50.             y=Integer.parseInt(Y.getText());
  51.             r=Integer.parseInt(R.getText());
  52.            
  53.             Graphics stift = this.getGraphics();
  54.             Kreis K = new Kreis(x,y,r);
  55.             K.zeichnedich(stift);
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement