Advertisement
Guest User

Calculator

a guest
Jul 25th, 2012
1,067
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 KB | None | 0 0
  1. import java.awt.BorderLayout;
  2. import java.awt.Event;
  3. import java.awt.GridLayout;
  4.  
  5. import javax.swing.*;
  6.  
  7.  
  8. public class main {
  9. static JFrame window;
  10. static JPanel holder;
  11. static JButton one;
  12. static JButton two;
  13. static JButton three;
  14. static JButton four;
  15. static JButton five;
  16. static JButton six;
  17. static JButton seven;
  18. static JButton eight;
  19. static JButton nine;
  20. static JButton zero;
  21. static JButton equals;
  22. static JTextArea text;
  23. static JTextArea answer;
  24. static JPanel top;
  25. static JButton top1;
  26. static JButton top2;
  27. static JButton mult;
  28. static JButton divid;
  29. static JPanel bottom;
  30.  
  31. public static void main(String[] args){
  32.  
  33. JFrame window = new JFrame("Calculator");
  34. JPanel holder = new JPanel();
  35. JButton one = new JButton("1");
  36. JButton two = new JButton("2");
  37. JButton three = new JButton("3");
  38. JButton four = new JButton("4");
  39. JButton five = new JButton("5");
  40. JButton six = new JButton("6");
  41. JButton seven = new JButton("7");
  42. JButton eight = new JButton("8");
  43. JButton nine = new JButton("9");
  44. JButton zero = new JButton("0");
  45. JTextArea text = new JTextArea();
  46. JPanel top = new JPanel();
  47. JButton top1 = new JButton("+");
  48. JButton top2 = new JButton("-");
  49. JButton mult = new JButton("°");
  50. JButton divid = new JButton("÷");
  51. JPanel bottom = new JPanel();
  52. JButton equals = new JButton("=");
  53.  
  54. text.getLineWrap();
  55. text.setSize(25,5);
  56. //window.add(BorderLayout.NORTH,top);
  57. ///top.setLayout(new GridLayout(4,3));
  58. //top.add(top1);
  59. //top.add(text);
  60. //top.add(top2);
  61.  
  62. holder.setLayout(new GridLayout(5,3));
  63. holder.add(top1);
  64. holder.add(text);
  65. holder.add(top2);
  66. holder.add(one);
  67. holder.add(two);
  68. holder.add(three);
  69. holder.add(four);
  70. holder.add(five);
  71. holder.add(six);
  72. holder.add(seven);
  73. holder.add(eight);
  74. holder.add(nine);
  75. holder.add(divid);
  76. holder.add(zero);
  77. holder.add(mult);
  78. bottom.add(equals);
  79. window.add(BorderLayout.SOUTH,bottom);
  80. //window.add(BorderLayout.PAGE_START, text);
  81. window.add(BorderLayout.CENTER,holder);
  82. window.setSize(250,300);
  83. window.setVisible(true);
  84.  
  85.  
  86.  
  87.  
  88. }
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement