لعبة المزرعة السعيدة لعبة الفراخ

جافا : GUI برنامج ايجاد مساحة الدائرة ... اعداد الطالبة آلاء غانم

import java.awt.GridLayout;
import java.awt.event.*;

import javax.swing.*;
public class Areacircle {

public static class MyareaCircle extends JFrame implements ActionListener{
JPanel myPanel ;
JTextField radius ; 
JLabel r ;
JLabel area ;

JLabel result ;
JButton click ;

public MyareaCircle(){
myPanel = new JPanel(new GridLayout(4 ,2, 20 ,0 ));
radius = new JTextField(10);
click = new JButton("click");
area = new JLabel();
r = new JLabel(" Enter radius : ");
result = new JLabel(" Area = ");
click.addActionListener(this);

myPanel.add(r);
myPanel.add(radius);
myPanel.add(result);
myPanel.add(area);
myPanel.add(click);
this.add(myPanel);

}

public static void main(String[] args) {
MyareaCircle first=new MyareaCircle();
first.setTitle("areaCircle");
first.setSize(300,200);
first.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
first.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent event) {
if( event.getSource() == click){
double r1 = Double.parseDouble(radius.getText()) ;
double a = r1 * r1 * 3.14;
area.setText(""+a);
}
}
}
}

هناك تعليق واحد:

لعبة من سيربح المليون لعبة زوما