SHARE
TWEET

Untitled

a guest Feb 16th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import javax.swing.*;
  2.  
  3. import java.awt.BorderLayout;
  4.  
  5. import java.awt.GridLayout;
  6.  
  7. public class Calculator
  8. {
  9.     public static void main (String[] args) { Calculator calc = new
  10.         Calculator();
  11.         }
  12.  
  13.  
  14.  
  15.     JPanel windowContent;
  16.  
  17. JTextField displayField;
  18.  
  19. JButton button0;
  20.  
  21. JButton button1;
  22.  
  23. JButton button2;
  24.  
  25. JButton button3;
  26.  
  27. JButton button4;
  28.  
  29. JButton button5;
  30.  
  31. JButton button6;
  32.  
  33. JButton button7;
  34.  
  35. JButton button8;
  36.  
  37. JButton button9;
  38.  
  39. JButton buttonPoint;
  40.  
  41. JButton buttonEqual;
  42.  
  43. JPanel pl;
  44.  
  45. public Calculator()
  46. {
  47.     windowContent = new JPanel(); BorderLayout bl = new
  48.     BorderLayout ();
  49.     windowContent.setLayout(bl); displayField = new JTextField(30);
  50.     windowContent.add("North", displayField);
  51.     button0=new JButton("0"); button1=new JButton("1"); button2=new
  52.     JButton("2"); button3=new JButton("3"); button4=new JButton("4");
  53.     button5=new JButton("5"); button6=new JButton("6"); button7=new
  54.     JButton("7"); button8=new JButton("8"); button9=new JButton("9");
  55.     buttonPoint = new JButton("."); buttonEqual = new JButton("=");
  56.     JPanel pl = new JPanel();
  57.     GridLayout gl = new GridLayout (4,3); pl.setLayout(gl);
  58.     pl.add(button1);
  59.     pl.add(button2);
  60.     pl.add(button3);
  61.     pl.add(button4);
  62.     pl.add(button5);
  63.     pl.add(button6);
  64.     pl.add(button7);
  65.     pl.add(button8);
  66.     pl.add(button9);
  67.     pl.add(button0);
  68.     pl.add(buttonPoint);
  69.     pl.add(buttonEqual);
  70.     windowContent.add("Center",pl);
  71.     JFrame frame = new JFrame("Calculator");
  72.     frame.setContentPane(windowContent); frame.pack();
  73.     frame.setVisible(true);
  74.     }
  75.  
  76.     }
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