Changed some variable names and got rid of the red font color

This commit is contained in:
U-BASIS\dsmyda 2018-10-01 09:36:58 -04:00
parent a3f1ed49b2
commit 100c7d1ddc
2 changed files with 18 additions and 27 deletions

View File

@ -35,8 +35,8 @@
<EmptySpace min="0" pref="451" max="32767" attributes="0"/> <EmptySpace min="0" pref="451" max="32767" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="charactersRemainingLabel" min="-2" max="-2" attributes="0"/> <Component id="remainingCharactersLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/> <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="okButton" min="-2" pref="75" max="-2" attributes="0"/> <Component id="okButton" min="-2" pref="75" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="cancelButton" min="-2" pref="75" max="-2" attributes="0"/> <Component id="cancelButton" min="-2" pref="75" max="-2" attributes="0"/>
@ -53,13 +53,13 @@
<Component id="commentLabel" min="-2" max="-2" attributes="0"/> <Component id="commentLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jScrollPane1" max="32767" attributes="0"/> <Component id="jScrollPane1" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="cancelButton" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="okButton" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Component id="charactersRemainingLabel" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="remainingCharactersLabel" alignment="0" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
@ -110,10 +110,6 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"></Property> <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"></Property>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="charactersRemainingLabel"> <Component class="javax.swing.JLabel" name="remainingCharactersLabel"></Component>
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor"></Property>
</Properties>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View File

@ -105,7 +105,7 @@ final class CentralRepoCommentDialog extends javax.swing.JDialog {
private Integer remainingCharacters = MAX_CHARACTERS; private Integer remainingCharacters = MAX_CHARACTERS;
public CentralRepoCommentLengthFilter() { public CentralRepoCommentLengthFilter() {
charactersRemainingLabel.setText(getUpdatedCharacterText()); updateLabel();
} }
/** /**
@ -146,7 +146,7 @@ final class CentralRepoCommentDialog extends javax.swing.JDialog {
throws BadLocationException { throws BadLocationException {
super.remove(filter, offset, length); super.remove(filter, offset, length);
remainingCharacters += length; remainingCharacters += length;
charactersRemainingLabel.setText(getUpdatedCharacterText()); updateLabel();
} }
/** /**
@ -170,26 +170,21 @@ final class CentralRepoCommentDialog extends javax.swing.JDialog {
//Truncate the replace if its too long //Truncate the replace if its too long
String truncatedText = input; String truncatedText = input;
if ((filter.getDocument().getLength() + input.length() - length) > MAX_CHARACTERS) { if ((filter.getDocument().getLength() + input.length() - length) > MAX_CHARACTERS) {
truncatedText = input.substring(0, MAX_CHARACTERS - filter.getDocument().getLength() - length); truncatedText = input.substring(0, MAX_CHARACTERS -
filter.getDocument().getLength() - length);
} }
super.replace(filter, offset, length, truncatedText, attrSet); super.replace(filter, offset, length, truncatedText, attrSet);
remainingCharacters -= truncatedText.length() - length; remainingCharacters -= truncatedText.length() - length;
charactersRemainingLabel.setText(getUpdatedCharacterText()); updateLabel();
} }
/** /**
* Returns remaining character count in HTML format. If the remaining * Updates the remainingCharactersLabel to reflect the current state
* count is at the 0, then make the text red
* *
* @return HTML formatted JLabel text
*/ */
private String getUpdatedCharacterText() { private void updateLabel() {
if (remainingCharacters == 0) { remainingCharactersLabel.setText(String.format("<html>%d %s</html>",
return String.format("<html><font color=\"red\">%d</font>%s</html>", remainingCharacters, "characters remaining"));
remainingCharacters, " characters remaining");
}
return String.format("<html><font color=\"black\">%d</font>%s</html>",
remainingCharacters, " characters remaining");
} }
} }
@ -207,7 +202,7 @@ final class CentralRepoCommentDialog extends javax.swing.JDialog {
okButton = new javax.swing.JButton(); okButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton(); cancelButton = new javax.swing.JButton();
commentLabel = new javax.swing.JLabel(); commentLabel = new javax.swing.JLabel();
charactersRemainingLabel = new javax.swing.JLabel(); remainingCharactersLabel = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setSize(getPreferredSize()); setSize(getPreferredSize());
@ -249,7 +244,7 @@ final class CentralRepoCommentDialog extends javax.swing.JDialog {
.addComponent(commentLabel) .addComponent(commentLabel)
.addGap(0, 451, Short.MAX_VALUE)) .addGap(0, 451, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(charactersRemainingLabel) .addComponent(remainingCharactersLabel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(okButton, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -268,7 +263,7 @@ final class CentralRepoCommentDialog extends javax.swing.JDialog {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cancelButton) .addComponent(cancelButton)
.addComponent(okButton)) .addComponent(okButton))
.addComponent(charactersRemainingLabel)) .addComponent(remainingCharactersLabel))
.addContainerGap()) .addContainerGap())
); );
@ -291,7 +286,7 @@ final class CentralRepoCommentDialog extends javax.swing.JDialog {
private javax.swing.JButton cancelButton; private javax.swing.JButton cancelButton;
private javax.swing.JLabel commentLabel; private javax.swing.JLabel commentLabel;
private javax.swing.JTextArea commentTextArea; private javax.swing.JTextArea commentTextArea;
private javax.swing.JLabel charactersRemainingLabel; private javax.swing.JLabel remainingCharactersLabel;
private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JButton okButton; private javax.swing.JButton okButton;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables