SHARE
TWEET

Untitled

a guest Nov 13th, 2019 91 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package lab6;
  2.  
  3. import java.awt.Dimension;
  4. import java.awt.FlowLayout;
  5. import java.awt.GridLayout;
  6.  
  7. import javax.swing.JButton;
  8. import javax.swing.JFrame;
  9. import javax.swing.JLabel;
  10. import javax.swing.JPanel;
  11. import javax.swing.JTextArea;
  12. import javax.swing.JTextField;
  13.  
  14. public class MainApp {
  15.  
  16.     public static void main(String[] args) {
  17.         // TODO Auto-generated method stub
  18.        JFrame frame=new JFrame("Calculator");
  19.        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  20.        frame.setSize(350,350);
  21.        frame.setLocation(400,400);
  22.        frame.getContentPane().setLayout(new GridLayout(3,1));
  23.        JPanel p1=new JPanel(new FlowLayout());
  24.        JLabel oplabel1=new JLabel("Operand 1");
  25.        oplabel1.setPreferredSize(new Dimension(120,20));
  26.        JTextField tf1=new JTextField();
  27.        tf1.setPreferredSize(new Dimension(120,20));
  28.        JLabel oplabel2=new JLabel("Operand 2");
  29.        oplabel2.setPreferredSize(new Dimension(120,20));
  30.        JTextField tf2=new JTextField();
  31.        tf2.setPreferredSize(new Dimension(120,20));
  32.        p1.add(oplabel1);
  33.        p1.add(tf1);
  34.        p1.add(oplabel2);
  35.        p1.add(tf2);
  36.        
  37.        JTextArea rez=new JTextArea();
  38.        rez.setPreferredSize(new Dimension(220,60));
  39.        JPanel p2=new JPanel(new FlowLayout());
  40.        JButton adnbtn=new JButton("adunare");
  41.        adnbtn.setPreferredSize(new Dimension(120,20));
  42.        adnbtn.addActionListener(new Adunare(tf1,tf2,rez));
  43.        
  44.        JButton scdbtn=new JButton("scadere");
  45.        scdbtn.setPreferredSize(new Dimension(120,20));
  46.        scdbtn.addActionListener(new Scadere(tf1,tf2,rez));
  47.        
  48.        JButton mulbtn=new JButton("inmultire");
  49.        mulbtn.setPreferredSize(new Dimension(120,20));
  50.        mulbtn.addActionListener(new Inmultire(tf1,tf2,rez));
  51.        
  52.        JButton impbtn=new JButton("impartire");
  53.        impbtn.setPreferredSize(new Dimension(120,20));
  54.        impbtn.addActionListener(new Impartire(tf1,tf2,rez));
  55.        p2.add(adnbtn);
  56.        p2.add(scdbtn);
  57.        p2.add(mulbtn);
  58.        p2.add(impbtn);
  59.        
  60.        JPanel p3=new JPanel(new FlowLayout());
  61.        JButton clear=new JButton("clear");
  62.        clear.addActionListener(new Clear(rez));
  63.        clear.setPreferredSize(new Dimension(220,30));
  64.        p3.add(rez);
  65.        p3.add(clear);
  66.        frame.getContentPane().add(p1);
  67.        frame.getContentPane().add(p2);
  68.        frame.getContentPane().add(p3);
  69.        frame.setVisible(true);
  70.     }
  71.  
  72. }
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