Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package org.calc.stack;
- import java.awt.BorderLayout;
- /**
- * Provides UI by extending JFrame.
- * @author Elliot Gardner
- *
- */
- public class CalcView extends JFrame {
- /**
- * Provides generated serialVersionID.
- */
- private static final long serialVersionUID = 3671833875684048855L;
- /**
- * Provides contentPanel for Frame elements to
- *   be inserted.
- */
- private JPanel contentPane;
- /**
- * Provides textField for user to enter data.
- */
- private JTextField textField;
- //Moved from constructor to instance field.
- /**
- * Provides boolean which will be utilized in calcController.
- */
- private JRadioButton rdbtnNewRadioButton;
- //Moved from constructor to instance field.
- /**
- * Provides a button to evaluate expressions.
- */
- private JButton btnEvaluate;
- /**
- * Launch the application.
- */
- // public static void main(String[] args) {
- // EventQueue.invokeLater(new Runnable() {
- // public void run() {
- // try {
- // CalcView frame = new CalcView();
- // frame.setVisible(true);
- // } catch (Exception e) {
- // e.printStackTrace();
- // }
- // }
- // });
- // }
- /**
- * Create the frame.
- */
- public CalcView() {
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- setBounds(100, 100, 450, 89);
- contentPane = new JPanel();
- contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
- contentPane.setLayout(new BorderLayout(0, 0));
- setContentPane(contentPane);
- textField = new JTextField();
- contentPane.add(textField, BorderLayout.NORTH);
- textField.setColumns(10);
- rdbtnNewRadioButton = new JRadioButton("Reverse Polish/Infix");
- contentPane.add(rdbtnNewRadioButton, BorderLayout.WEST);
- btnEvaluate = new JButton("Evaluate");
- contentPane.add(btnEvaluate, BorderLayout.EAST);
- }
- /**
- * returns the string of the textField.
- * @return returns type of String.
- */
- public final String getExpression() {
- return this.textField.toString();
- }
- /**
- * Sets the string of the textField.
- * @param expression takes String parameter.
- */
- public final void setExpression(final String expression) {
- this.textField.setText(expression);
- }
- }
Add Comment
Please, Sign In to add comment