SHARE
TWEET

Untitled

a guest Mar 26th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import javax.swing.*;
  2. import java.awt.*;
  3. import java.awt.event.*;
  4.  
  5. public class LatihanGUI extends JApplet implements ActionListener {
  6.     private JButton calculate;
  7.     private JLabel radius;
  8.     private JTextField jtfradius;
  9.     private JLabel area;
  10.     private JTextField result;
  11.    
  12.     @Override
  13.     public void init(){
  14.         Container pane=getContentPane();
  15.         pane.setBackground(Color.pink);
  16.         pane.setLayout(new GridLayout(3,2));
  17.       radius=new JLabel("Radius :");
  18.       pane.add(radius);
  19.       jtfradius=new JTextField(5);
  20.       pane.add(jtfradius);
  21.      
  22.        area=new JLabel("Area :");
  23.        pane.add(area);
  24.        result=new JTextField();    
  25.        pane.add(result);
  26.    
  27.      calculate=new JButton("calculate");
  28.      pane.add(calculate);
  29.    
  30.      
  31.      jtfradius.addActionListener(this);
  32.    
  33.      calculate.addActionListener(this);
  34.      
  35.     }
  36.  
  37.     @Override
  38.     public void actionPerformed(ActionEvent e) {
  39.         double p=Double.parseDouble(jtfradius.getText());
  40.        
  41.         double pi=3.142;
  42.         double area=Math.PI*(p*p);
  43.        
  44.         result.setText(""+area);
  45.     }
  46.    
  47. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top