Skip to content

Commit 617ef12

Browse files
author
extremq
committed
Bring up the window on front when timers end.
1 parent db1167c commit 617ef12

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@
44
This is a Pomodoro-type app made in Java using Swift UI.
55

66
# TODO
7-
- Add Break.
8-
- Add more comments.
7+
- ~~Add Break.~~
8+
- ~~Add more comments.~~
99
- (Undecided) Store sessions and create graphs and statistics.

src/com/codebind/App.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class App {
1717
private JLabel labelTimer;
1818
private JPanel panelButtons;
1919
private long focusMinutes;
20+
private static final JFrame frame = new JFrame("App");
2021

2122
enum State {
2223
BOOTED,
@@ -119,6 +120,7 @@ private void endFocusPeriod() {
119120
setEnableButtonStop(false);
120121
setTimerStopped(false);
121122
setLabelTimer("00:00");
123+
flashWindow();
122124

123125
JOptionPane.showMessageDialog(null, Locale.FOCUS_DONE_MESSAGE_ALERT);
124126
}
@@ -138,9 +140,16 @@ private void endBreakPeriod() {
138140
setEnableButtonStop(false);
139141
setTimerStopped(false);
140142
setLabelTimer("00:00");
143+
flashWindow();
141144

142145
JOptionPane.showMessageDialog(null, Locale.BREAK_DONE_MESSAGE_ALERT);
146+
}
143147

148+
private static void flashWindow() {
149+
frame.setAlwaysOnTop(true);
150+
frame.toFront();
151+
frame.requestFocus();
152+
frame.setAlwaysOnTop(false);
144153
}
145154

146155
public App() {
@@ -198,9 +207,8 @@ public void actionPerformed(ActionEvent e) {
198207
}
199208

200209
public static void main(String[] args) {
201-
JFrame frame = new JFrame("App");
202-
203210
// Init settings
211+
frame.toFront();
204212
frame.setContentPane(new App().panelMain);
205213
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
206214
frame.pack();

0 commit comments

Comments
 (0)