Advertisement
Guest User

Untitled

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