-
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added GUI zoom button, made default zoom level 150% instead of 200%
Minor gui refactoring
- Loading branch information
Showing
2 changed files
with
108 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package io.eiren.gui; | ||
|
||
import java.util.Timer; | ||
import java.util.TimerTask; | ||
|
||
import javax.swing.AbstractButton; | ||
|
||
public class ButtonTimer { | ||
|
||
private static Timer timer = new Timer(); | ||
|
||
public static void runTimer(AbstractButton button, int seconds, String defaultText, Runnable runnable) { | ||
if(seconds <= 0) { | ||
button.setText(defaultText); | ||
runnable.run(); | ||
} else { | ||
button.setText(String.valueOf(seconds)); | ||
timer.schedule(new ButtonTimerTask(button, seconds - 1, defaultText, runnable), 1000); | ||
} | ||
} | ||
|
||
private static class ButtonTimerTask extends TimerTask { | ||
|
||
private final AbstractButton button; | ||
private final int seconds; | ||
private final String defaultText; | ||
private final Runnable runnable; | ||
|
||
private ButtonTimerTask(AbstractButton button, int seconds, String defaultText, Runnable runnable) { | ||
this.button = button; | ||
this.seconds = seconds; | ||
this.defaultText = defaultText; | ||
this.runnable = runnable; | ||
} | ||
|
||
@Override | ||
public void run() { | ||
runTimer(button, seconds, defaultText, runnable); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters