daily pastebin goal
80%
SHARE
TWEET

Untitled

a guest Mar 25th, 2019 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.awt.*;
  2. import javax.swing.*;
  3.  
  4. import java.awt.event.KeyEvent;
  5.  
  6.  
  7.  
  8. public class AppGUI extends JFrame {
  9.     public AppGUI(){
  10. setTitle("AppGUI");
  11. JTextField display = new JTextField("0.0");
  12. //add(display, BorderLayout.NORTH);
  13. //setLayout(new GridLayout(2,1));
  14.  
  15. JPanel p1 = new JPanel();
  16. p1.setBackground(Color.WHITE);
  17. p1.setLayout(new GridLayout(4,1));
  18.  
  19.  
  20. JButton bmc = new JButton("MC");
  21. JButton bmr = new JButton("MR");
  22. JButton bms = new JButton("MS");
  23. JButton bmplus = new JButton("M+");
  24. //p1.add(display, BorderLayout.NORTH);
  25. //p1.add(display);
  26. //p1.add(display, BorderLayout.PAGE_START);
  27.  
  28.  
  29. p1.add(bmc, BorderLayout.LINE_START);
  30. p1.add(bmr, BorderLayout.LINE_START);
  31. p1.add(bms, BorderLayout.LINE_START);
  32. p1.add(bmplus, BorderLayout.LINE_START);
  33. add(p1, BorderLayout.LINE_START);
  34.  
  35. JPanel p2 = new JPanel();
  36. p2.setBackground(Color.WHITE);
  37. p2.setLayout(new GridLayout(4,4));
  38.  
  39. JButton b0 = new JButton("0");
  40. JButton b1 = new JButton("1");
  41. JButton b2 = new JButton("2");
  42. JButton b3 = new JButton("3");
  43. JButton b4 = new JButton("4");
  44. JButton b5 = new JButton("5");
  45. JButton b6 = new JButton("6");
  46. JButton b7 = new JButton("7");
  47. JButton b8 = new JButton("8");
  48. JButton b9 = new JButton("9");
  49. JButton badd = new JButton("+");
  50. JButton bmul = new JButton("*");
  51. JButton bsub = new JButton("-");
  52. JButton bdiv = new JButton("/");
  53. JButton bdot = new JButton(".");
  54. JButton beq = new JButton("=");
  55.  
  56. p2.add(b7, BorderLayout.LINE_END);
  57. p2.add(b8, BorderLayout.LINE_END);
  58. p2.add(b9, BorderLayout.LINE_END);
  59. p2.add(badd, BorderLayout.LINE_END);
  60. p2.add(b4, BorderLayout.LINE_END);
  61. p2.add(b5, BorderLayout.LINE_END);
  62. p2.add(b6, BorderLayout.LINE_END);
  63. p2.add(bsub, BorderLayout.LINE_END);
  64. p2.add(b1, BorderLayout.LINE_END);
  65. p2.add(b2, BorderLayout.LINE_END);
  66. p2.add(b3, BorderLayout.LINE_END);
  67. p2.add(bmul, BorderLayout.LINE_END);
  68. p2.add(b0, BorderLayout.LINE_END);
  69. p2.add(bdot, BorderLayout.LINE_END);
  70. p2.add(beq, BorderLayout.LINE_END);
  71. p2.add(bdiv, BorderLayout.LINE_END);
  72. add(p2,BorderLayout.CENTER);
  73.  
  74. JToolBar toolbar = new JToolBar();
  75.  toolbar.setRollover(true);
  76.  JButton button = new JButton("File");
  77.  toolbar.add(button);
  78.  toolbar.addSeparator();
  79.  toolbar.add(new JButton("Edit"));
  80.  toolbar.addSeparator();
  81.  toolbar.add(new JComboBox(new String[]{"Item 1", "Item 2", "Item 3"}));
  82.  toolbar.addSeparator();
  83.  add(toolbar, BorderLayout.NORTH);
  84.  
  85.  
  86.  
  87.  
  88.  JToolBar tool = new JToolBar();
  89. tool.add(new JButton(new ImageIcon("icon.gif")));
  90. tool.addSeparator();
  91. tool.add(new JButton(new ImageIcon("icon.gif")));
  92. tool.add(new JButton(new ImageIcon("icon.gif")));
  93.  
  94.  
  95.  
  96.  
  97. JPanel top = new JPanel();
  98. top.setLayout(new BoxLayout(top, BoxLayout.Y_AXIS));
  99. top.add(display);
  100. top.add(toolbar);
  101. top.add(tool);
  102. add(top, BorderLayout.NORTH);
  103.  
  104.  
  105.  
  106.     }
  107.  
  108. public static void main(String[] args){
  109. AppGUI frame = new AppGUI();
  110. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  111. frame.setSize(600, 500);
  112. frame.setVisible(true);
  113.  
  114.  
  115. }
  116. }
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