Skip to content

Commit

Permalink
Update frame title on change only
Browse files Browse the repository at this point in the history
  • Loading branch information
RetGal committed Nov 10, 2023
1 parent ae83051 commit 836c897
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/main/java/mpo/dayon/common/gui/common/BaseFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ public abstract class BaseFrame extends JFrame {

private StatusBar statusBar;

private Locale locale;

protected BaseFrame() {
setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
setIconImage(ImageUtilities.getOrCreateIcon(ImageNames.APP).getImage());
Expand Down Expand Up @@ -65,17 +67,16 @@ protected void setFrameType(FrameType frameType) {
this.dimension = new Dimension(Math.max(configuration.getWidth(), frameType.getMinWidth()),
Math.max(configuration.getHeight(), frameType.getMinHeight()));
this.setSize(dimension.width, dimension.height);
updateTitle(translate(frameType.getPrefix()), Version.get());
}

private void updateTitle(String titleString, Version version) {
setTitle(titleString, version);
new Timer(5000, e -> setTitle(titleString, version)).start();
setTitle();
new Timer(5000, e -> setTitle()).start();
}

private void setTitle(String titleString, Version version) {
Locale locale = InputContext.getInstance().getLocale();
setTitle(format("Dayon! (%s) %s %s", titleString, version, locale != null ? locale.toString() : ""));
private void setTitle() {
Locale currentLocale = InputContext.getInstance().getLocale();
if (currentLocale != locale) {
locale = currentLocale;
setTitle(format("Dayon! (%s) %s %s", translate(frameType.getPrefix()), Version.get(), locale != null ? locale.toString() : ""));
}
}

protected void setupToolBar(ToolBar toolBar) {
Expand Down

0 comments on commit 836c897

Please sign in to comment.