Skip to content

Instantly share code, notes, and snippets.

@ggalmazor
Created March 20, 2018 06:26
Show Gist options
  • Save ggalmazor/5bd3ace358b4f1827c8f04c0f4ef3ccf to your computer and use it in GitHub Desktop.
Save ggalmazor/5bd3ace358b4f1827c8f04c0f4ef3ccf to your computer and use it in GitHub Desktop.
Indirection without abstraction - Snippet 3
public class ExportPanelForm {
private static final String EXPORTING = "Exporting";
private static final String DOT = ".";
private JLabel exportingLabel;
public void updateExportingLabel() {
String newText = cycle(exportingLabel.getText(), 19);
exportingLabel.setText(newText);
}
public void showExporting() {
exportingLabel.setText(EXPORTING + DOT);
exportingLabel.setVisible(true);
}
private static String cycle(String currentText, int maxLength) {
return currentText.length() == maxLength
? EXPORTING + DOT
: currentText + DOT;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment