Crenox

Calculator

Jun 16th, 2014
335
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. // By: Sammy Samkough
  2.  
  3. package com.samkough.calculator.main;
  4.  
  5. import javax.swing.*;
  6. import java.awt.*;
  7. import java.awt.event.*;
  8.  
  9. public class Calc
  10. {
  11. private static final int WIDTH = 400;
  12. private static final int HEIGHT = 400;
  13.  
  14. JFrame frame;
  15. JPanel p1;
  16. JPanel p2;
  17.  
  18. JTextField tf1;
  19. JButton b1, b2, b3, b4, b5, b6, b7, b8, b9, b10, b11, b12;
  20.  
  21. public Calc()
  22. {
  23. frame = new JFrame("Calc");
  24. p1 = new JPanel();
  25. p2 = new JPanel();
  26.  
  27. frame.setContentPane(p1);
  28. p1.setLayout(new BorderLayout());
  29. p2.setLayout(new GridLayout(4, 3));
  30.  
  31. tf1 = new JTextField(" ");
  32. b7 = new JButton("7");
  33. b8 = new JButton("8");
  34. b9 = new JButton("9");
  35. b4 = new JButton("4");
  36. b5 = new JButton("5");
  37. b6 = new JButton("6");
  38. b1 = new JButton("1");
  39. b2 = new JButton("2");
  40. b3 = new JButton("3");
  41. b10 = new JButton("0");
  42. b11 = new JButton("+");
  43. b12 = new JButton("=");
  44.  
  45. p1.add(tf1, BorderLayout.NORTH);
  46. p1.add(p2, BorderLayout.CENTER);
  47. p2.add(b1);
  48. p2.add(b2);
  49. p2.add(b3);
  50. p2.add(b4);
  51. p2.add(b5);
  52. p2.add(b6);
  53. p2.add(b7);
  54. p2.add(b8);
  55. p2.add(b9);
  56. p2.add(b10);
  57. p2.add(b11);
  58. p2.add(b12);
  59.  
  60. frame.setSize(WIDTH, HEIGHT);
  61. frame.setLocationRelativeTo(null);
  62. frame.setResizable(false);
  63. // frame.setTitle("Sammy");
  64. frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  65. frame.setVisible(true);
  66. }
  67.  
  68. public void actionPerformed(ActionEvent e)
  69. {
  70.  
  71. }
  72. }
  73. -------------------------------------------------------------------------------------------------------------------------------------
  74. package com.samkough.calculator.main;
  75.  
  76. public class CalcTester
  77. {
  78. public static void main(String args[])
  79. {
  80. Calc c1 = new Calc();
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment