add clear history button
This commit is contained in:
parent
8a095b2b16
commit
46f83731f7
11
GFrame.java
11
GFrame.java
|
|
@ -79,7 +79,7 @@ public class GFrame extends JFrame {
|
|||
// History Text Field
|
||||
History history = new History();
|
||||
JTextArea tHist = new JTextArea();
|
||||
tHist.setBounds(380, 50, 200, 290);
|
||||
tHist.setBounds(380, 50, 200, 240);
|
||||
tHist.setEditable(false);
|
||||
tHist.setBorder(new RoundBtn(5));
|
||||
tHist.setBackground(Color.decode("#2B2B2B"));
|
||||
|
|
@ -91,6 +91,7 @@ public class GFrame extends JFrame {
|
|||
// Buttons
|
||||
JButton bEval = newButton("=", 250, 100, 100, 40);
|
||||
JButton bClear = newButton("CL", 180, 100, 60, 40);
|
||||
JButton bClearHistory = newButton("Clear History", 380, 300, 200, 40);
|
||||
JButton bAdd = newButton("+", 250, 300, 100, 40);
|
||||
JButton bSub = newButton("-", 250, 250, 100, 40);
|
||||
JButton bMul = newButton("x", 250, 200, 100, 40);
|
||||
|
|
@ -114,6 +115,7 @@ public class GFrame extends JFrame {
|
|||
// Add the buttons to the Frame
|
||||
this.add(bEval);
|
||||
this.add(bClear);
|
||||
this.add(bClearHistory);
|
||||
this.add(bAdd);
|
||||
this.add(bSub);
|
||||
this.add(bMul);
|
||||
|
|
@ -194,6 +196,13 @@ public class GFrame extends JFrame {
|
|||
}
|
||||
});
|
||||
|
||||
bClearHistory.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
history.clearHistory();
|
||||
tHist.setText("");
|
||||
}
|
||||
});
|
||||
|
||||
bCut.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
String text = tf.getText();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,10 @@ public class History {
|
|||
hist = new Vector<String>();
|
||||
}
|
||||
|
||||
public void clearHistory() {
|
||||
hist.clear();
|
||||
}
|
||||
|
||||
public Vector<String> getHistory() {
|
||||
return hist;
|
||||
}
|
||||
|
|
|
|||
Reference in New Issue