Advertisement
Guest User

Untitled

a guest
Dec 14th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. import java.awt.*;
  2. import javax.swing.*;
  3. public class AppGUI extends JFrame {
  4. public AppGUI(){
  5. setTitle("AppGUI");
  6. JPanel p1 = new JPanel();
  7. JPanel p2 = new JPanel();
  8. //p1.setBackground(Color.RED);
  9. JTextField display = new JTextField("0.0");
  10. JButton b1 = new JButton("MC");
  11. JButton b2 = new JButton("MR");
  12. JButton b3 = new JButton("MS");
  13. JButton b4 = new JButton("M+");
  14. p1.setLayout(new GridLayout(4,4));
  15. JButton a1 = new JButton("1");
  16. JButton a2 = new JButton("2");
  17. JButton a3 = new JButton("3");
  18. JButton a4 = new JButton("4");
  19. JButton a5 = new JButton("5");
  20. JButton a6 = new JButton("6");
  21. JButton a7 = new JButton("7");
  22. JButton a8 = new JButton("8");
  23. JButton a9 = new JButton("9");
  24. JButton a10 = new JButton("0");
  25. JButton a11 = new JButton(".");
  26. JButton a12 = new JButton("=");
  27.  
  28. JButton c1 = new JButton("+");
  29. JButton c2 = new JButton("-");
  30. JButton c3 = new JButton("*");
  31. JButton c4 = new JButton("/");
  32.  
  33. p2.setLayout(new GridLayout(4,1));
  34. p2.add(b1);
  35. p2.add(b2);
  36. p2.add(b3);
  37. p2.add(b4);
  38.  
  39. p1.add(a9);
  40. p1.add(a8);
  41. p1.add(a7);
  42. p1.add(c1);
  43. p1.add(a6);
  44. p1.add(a5);
  45. p1.add(a4);
  46. p1.add(c2);
  47. p1.add(a3);
  48. p1.add(a2);
  49. p1.add(a1);
  50. p1.add(c3);
  51. p1.add(a10);
  52. p1.add(a11);
  53. p1.add(a12);
  54. p1.add(c4);
  55.  
  56. add(display,BorderLayout.PAGE_START);
  57. add(p2,BorderLayout.LINE_START);
  58. add(p1, BorderLayout.CENTER);
  59. }
  60. public static void main(String[] args){
  61. AppGUI frame = new AppGUI();
  62. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  63. frame.setSize(600, 500);
  64. frame.setVisible(true);
  65. }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement