mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-29 10:24:12 +01:00
add overloaded method to NotificationPopup to tune autoclose
This commit is contained in:
parent
a78a3ed6b5
commit
f96f1d321a
@ -60,10 +60,17 @@ import processing.app.Theme;
|
|||||||
public class NotificationPopup extends JDialog {
|
public class NotificationPopup extends JDialog {
|
||||||
|
|
||||||
private Timer autoCloseTimer = new Timer(false);
|
private Timer autoCloseTimer = new Timer(false);
|
||||||
|
private boolean autoClose = true;
|
||||||
|
|
||||||
public NotificationPopup(Frame parent, HyperlinkListener hyperlinkListener,
|
public NotificationPopup(Frame parent, HyperlinkListener hyperlinkListener,
|
||||||
String message) {
|
String message) {
|
||||||
|
this(parent, hyperlinkListener, message, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public NotificationPopup(Frame parent, HyperlinkListener hyperlinkListener,
|
||||||
|
String message, boolean _autoClose) {
|
||||||
super(parent, false);
|
super(parent, false);
|
||||||
|
autoClose = _autoClose;
|
||||||
setLayout(new FlowLayout());
|
setLayout(new FlowLayout());
|
||||||
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
|
||||||
setUndecorated(true);
|
setUndecorated(true);
|
||||||
@ -135,17 +142,21 @@ public class NotificationPopup extends JDialog {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close() {
|
||||||
autoCloseTimer.cancel();
|
if (autoClose) {
|
||||||
|
autoCloseTimer.cancel();
|
||||||
|
}
|
||||||
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
|
dispatchEvent(new WindowEvent(this, WindowEvent.WINDOW_CLOSING));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void begin() {
|
public void begin() {
|
||||||
autoCloseTimer.schedule(new TimerTask() {
|
if (autoClose) {
|
||||||
@Override
|
autoCloseTimer.schedule(new TimerTask() {
|
||||||
public void run() {
|
@Override
|
||||||
close();
|
public void run() {
|
||||||
}
|
close();
|
||||||
}, Constants.NOTIFICATION_POPUP_AUTOCLOSE_DELAY);
|
}
|
||||||
|
}, Constants.NOTIFICATION_POPUP_AUTOCLOSE_DELAY);
|
||||||
|
}
|
||||||
setVisible(true);
|
setVisible(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user