Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import java.applet.*;
- public class A14k1_Kreis_Eingabe_M_R extends Applet implements ActionListener{
- public class Kreis {
- int x, y, r;
- public Kreis (int x1, int y1, int r1){
- x=x1;
- y=y1;
- r=r1;
- }
- public void zeichnedich (Graphics stift){
- stift.drawOval(x-r, y-r, 2*r, 2*r);
- }
- }
- int x, y, r;
- TextField X = new TextField();
- TextField Y = new TextField();
- TextField R = new TextField();
- Button z = new Button("Kreis zeichnen");
- public A14k1_Kreis_Eingabe_M_R () {
- setLayout(null);
- X.setBounds(110,40,70,20);
- Y.setBounds(200,40,70,20);
- R.setBounds(20,40,70,20);
- z.setBounds(80,80,130,30);
- z.setBackground(Color.gray);
- add(X); add(Y); add(R); add(z);
- z.addActionListener(this);
- }
- public void paint (Graphics stift) {
- stift.drawString("Radius:",20,30);
- stift.drawString("X Mittelpunkt:",110,30);
- stift.drawString("Y Mittelpunkt:",200,30);
- }
- public void actionPerformed (ActionEvent e) {
- if(e.getSource()==this.z) {
- x=Integer.parseInt(X.getText());
- y=Integer.parseInt(Y.getText());
- r=Integer.parseInt(R.getText());
- Graphics stift = this.getGraphics();
- Kreis K = new Kreis(x,y,r);
- K.zeichnedich(stift);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement