Guest User

Untitled

a guest
Apr 23rd, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. package org.calc.stack;
  2.  
  3. import java.awt.BorderLayout;
  4.  
  5. /**
  6. * Provides UI by extending JFrame.
  7. * @author Elliot Gardner
  8. *
  9. */
  10. public class CalcView extends JFrame {
  11. /**
  12. * Provides generated serialVersionID.
  13. */
  14. private static final long serialVersionUID = 3671833875684048855L;
  15. /**
  16. * Provides contentPanel for Frame elements to
  17. * &nbsp be inserted.
  18. */
  19. private JPanel contentPane;
  20. /**
  21. * Provides textField for user to enter data.
  22. */
  23. private JTextField textField;
  24. //Moved from constructor to instance field.
  25. /**
  26. * Provides boolean which will be utilized in calcController.
  27. */
  28. private JRadioButton rdbtnNewRadioButton;
  29. //Moved from constructor to instance field.
  30. /**
  31. * Provides a button to evaluate expressions.
  32. */
  33. private JButton btnEvaluate;
  34. /**
  35. * Launch the application.
  36. */
  37. // public static void main(String[] args) {
  38. // EventQueue.invokeLater(new Runnable() {
  39. // public void run() {
  40. // try {
  41. // CalcView frame = new CalcView();
  42. // frame.setVisible(true);
  43. // } catch (Exception e) {
  44. // e.printStackTrace();
  45. // }
  46. // }
  47. // });
  48. // }
  49.  
  50. /**
  51. * Create the frame.
  52. */
  53. public CalcView() {
  54. setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  55. setBounds(100, 100, 450, 89);
  56. contentPane = new JPanel();
  57. contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
  58. contentPane.setLayout(new BorderLayout(0, 0));
  59. setContentPane(contentPane);
  60. textField = new JTextField();
  61. contentPane.add(textField, BorderLayout.NORTH);
  62. textField.setColumns(10);
  63. rdbtnNewRadioButton = new JRadioButton("Reverse Polish/Infix");
  64. contentPane.add(rdbtnNewRadioButton, BorderLayout.WEST);
  65. btnEvaluate = new JButton("Evaluate");
  66. contentPane.add(btnEvaluate, BorderLayout.EAST);
  67. }
  68. /**
  69. * returns the string of the textField.
  70. * @return returns type of String.
  71. */
  72. public final String getExpression() {
  73. return this.textField.toString();
  74. }
  75. /**
  76. * Sets the string of the textField.
  77. * @param expression takes String parameter.
  78. */
  79. public final void setExpression(final String expression) {
  80. this.textField.setText(expression);
  81. }
  82. }
Add Comment
Please, Sign In to add comment