Skip to content

Commit f96f1d3

Browse files
committed
add overloaded method to NotificationPopup to tune autoclose
1 parent a78a3ed commit f96f1d3

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

app/src/cc/arduino/view/NotificationPopup.java

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,17 @@
6060
public class NotificationPopup extends JDialog {
6161

6262
private Timer autoCloseTimer = new Timer(false);
63+
private boolean autoClose = true;
6364

6465
public NotificationPopup(Frame parent, HyperlinkListener hyperlinkListener,
6566
String message) {
67+
this(parent, hyperlinkListener, message, true);
68+
}
69+
70+
public NotificationPopup(Frame parent, HyperlinkListener hyperlinkListener,
71+
String message, boolean _autoClose) {
6672
super(parent, false);
73+
autoClose = _autoClose;
6774
setLayout(new FlowLayout());
6875
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
6976
setUndecorated(true);
@@ -135,17 +142,21 @@ private void updateLocation(Frame parent) {
135142
}
136143

137144
public void close() {
138-
autoCloseTimer.cancel();
145+
if (autoClose) {
146+
autoCloseTimer.cancel();
147+
}
139148
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
140149
}
141150

142151
public void begin() {
143-
autoCloseTimer.schedule(new TimerTask() {
144-
@Override
145-
public void run() {
146-
close();
147-
}
148-
}, Constants.NOTIFICATION_POPUP_AUTOCLOSE_DELAY);
152+
if (autoClose) {
153+
autoCloseTimer.schedule(new TimerTask() {
154+
@Override
155+
public void run() {
156+
close();
157+
}
158+
}, Constants.NOTIFICATION_POPUP_AUTOCLOSE_DELAY);
159+
}
149160
setVisible(true);
150161
}
151162
}

0 commit comments

Comments
 (0)