Skip to content

Commit

Permalink
Minor refactoring and reordering
Browse files Browse the repository at this point in the history
- refactored BUTTON_CC -> BUTTON_Clear
- refactored action listener BUTTON_ClearCurrentActionPerformed() ->
                             BUTTON_ClearEntryActionPerformed()
- moved BUTTON_ClearActionPerformed() code under
        BUTTON_ClearEntryActionPerformed()
  • Loading branch information
M4444 committed Jun 1, 2018
1 parent a07f49d commit b26011e
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 27 deletions.
Binary file modified dist/C41C.jar
Binary file not shown.
8 changes: 4 additions & 4 deletions src/c41c/Window.form
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@
<Group type="103" groupAlignment="0" attributes="0">
<Component id="BUTTON_6" alignment="0" min="-2" pref="38" max="-2" attributes="0"/>
<Group type="103" alignment="1" groupAlignment="0" attributes="0">
<Component id="BUTTON_CC" min="-2" pref="38" max="-2" attributes="0"/>
<Component id="BUTTON_Clear" min="-2" pref="38" max="-2" attributes="0"/>
<Component id="BUTTON_9" min="-2" pref="38" max="-2" attributes="0"/>
<Component id="BUTTON_MS" alignment="0" min="-2" pref="38" max="-2" attributes="0"/>
</Group>
Expand Down Expand Up @@ -274,7 +274,7 @@
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="BUTTON_plus_minus" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="BUTTON_CC" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="BUTTON_Clear" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="BUTTON_CE" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="BUTTON_backspace" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
<Component id="BUTTON_B" alignment="3" min="-2" pref="30" max="-2" attributes="0"/>
Expand Down Expand Up @@ -1357,7 +1357,7 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="BUTTON_MSActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="BUTTON_CC">
<Component class="javax.swing.JButton" name="BUTTON_Clear">
<Properties>
<Property name="text" type="java.lang.String" value="C"/>
<Property name="toolTipText" type="java.lang.String" value=""/>
Expand All @@ -1378,7 +1378,7 @@
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="BUTTON_ClearCurrentActionPerformed"/>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="BUTTON_ClearEntryActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="BUTTON_MR">
Expand Down
46 changes: 23 additions & 23 deletions src/c41c/Window.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ private void initComponents() {
BUTTON_E = new javax.swing.JButton();
BUTTON_F = new javax.swing.JButton();
BUTTON_MS = new javax.swing.JButton();
BUTTON_CC = new javax.swing.JButton();
BUTTON_Clear = new javax.swing.JButton();
BUTTON_CE = new javax.swing.JButton();
BUTTON_MR = new javax.swing.JButton();
BUTTON_MC = new javax.swing.JButton();
Expand Down Expand Up @@ -820,10 +820,10 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
}
});

BUTTON_CC.setText("C");
BUTTON_CC.setToolTipText("");
BUTTON_CC.setMargin(new java.awt.Insets(2, 2, 2, 2));
BUTTON_CC.addActionListener(new java.awt.event.ActionListener() {
BUTTON_Clear.setText("C");
BUTTON_Clear.setToolTipText("");
BUTTON_Clear.setMargin(new java.awt.Insets(2, 2, 2, 2));
BUTTON_Clear.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
BUTTON_ClearActionPerformed(evt);
}
Expand All @@ -834,7 +834,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
BUTTON_CE.setMargin(new java.awt.Insets(2, 2, 2, 2));
BUTTON_CE.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
BUTTON_ClearCurrentActionPerformed(evt);
BUTTON_ClearEntryActionPerformed(evt);
}
});

Expand Down Expand Up @@ -1188,7 +1188,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(BUTTON_6, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(BUTTON_CC, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(BUTTON_Clear, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(BUTTON_9, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(BUTTON_MS, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(39, 39, 39))
Expand Down Expand Up @@ -1229,7 +1229,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {
.addGap(1, 1, 1)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(BUTTON_plus_minus, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(BUTTON_CC, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(BUTTON_Clear, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(BUTTON_CE, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(BUTTON_backspace, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(BUTTON_B, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
Expand Down Expand Up @@ -1355,7 +1355,7 @@ private void addKeyDispatcher() {
default:
return false;
case KeyEvent.VK_ESCAPE:
BUTTON_CC.doClick();
BUTTON_Clear.doClick();
break;
case KeyEvent.VK_DELETE:
BUTTON_CE.doClick();
Expand Down Expand Up @@ -1487,13 +1487,24 @@ private void BUTTON_RemoveDigitActionPerformed(java.awt.event.ActionEvent evt) {
refreshTextArea();
}//GEN-LAST:event_BUTTON_RemoveDigitActionPerformed

private void BUTTON_ClearCurrentActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BUTTON_ClearCurrentActionPerformed
private void BUTTON_ClearEntryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BUTTON_ClearEntryActionPerformed
Operands[Active] = BigInteger.ZERO;
changeAllBits(Operands[Active]);
DivisionByZero = false;

refreshTextArea();
}//GEN-LAST:event_BUTTON_ClearCurrentActionPerformed
}//GEN-LAST:event_BUTTON_ClearEntryActionPerformed

private void BUTTON_ClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BUTTON_ClearActionPerformed
Operands[0] = BigInteger.ZERO;
Operands[1] = BigInteger.ZERO;
Operation = "";
performOperation();
changeAllBits(Operands[Active]);
DivisionByZero = false;

refreshTextArea();
}//GEN-LAST:event_BUTTON_ClearActionPerformed

private void BUTTON_OperationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BUTTON_OperationActionPerformed
String PreviousOperation = Operation;
Expand Down Expand Up @@ -1632,17 +1643,6 @@ private void BUTTON_MRActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR
refreshTextArea();
}//GEN-LAST:event_BUTTON_MRActionPerformed

private void BUTTON_ClearActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_BUTTON_ClearActionPerformed
Operands[0] = BigInteger.ZERO;
Operands[1] = BigInteger.ZERO;
Operation = "";
performOperation();
changeAllBits(Operands[Active]);
DivisionByZero = false;

refreshTextArea();
}//GEN-LAST:event_BUTTON_ClearActionPerformed

private void MENU_ITEM_CopyActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MENU_ITEM_CopyActionPerformed
StringSelection stringSelection = new StringSelection(Operands[0].toString(Base));
Clipboard.setContents(stringSelection, null);
Expand Down Expand Up @@ -2002,8 +2002,8 @@ public void run() {
private javax.swing.JButton BUTTON_AsR;
private javax.swing.JButton BUTTON_B;
private javax.swing.JButton BUTTON_C;
private javax.swing.JButton BUTTON_CC;
private javax.swing.JButton BUTTON_CE;
private javax.swing.JButton BUTTON_Clear;
private javax.swing.JButton BUTTON_D;
private javax.swing.JButton BUTTON_E;
private javax.swing.JButton BUTTON_F;
Expand Down

0 comments on commit b26011e

Please sign in to comment.