File tree 1 file changed +18
-7
lines changed 1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change 60
60
public class NotificationPopup extends JDialog {
61
61
62
62
private Timer autoCloseTimer = new Timer (false );
63
+ private boolean autoClose = true ;
63
64
64
65
public NotificationPopup (Frame parent , HyperlinkListener hyperlinkListener ,
65
66
String message ) {
67
+ this (parent , hyperlinkListener , message , true );
68
+ }
69
+
70
+ public NotificationPopup (Frame parent , HyperlinkListener hyperlinkListener ,
71
+ String message , boolean _autoClose ) {
66
72
super (parent , false );
73
+ autoClose = _autoClose ;
67
74
setLayout (new FlowLayout ());
68
75
setDefaultCloseOperation (WindowConstants .DISPOSE_ON_CLOSE );
69
76
setUndecorated (true );
@@ -135,17 +142,21 @@ private void updateLocation(Frame parent) {
135
142
}
136
143
137
144
public void close () {
138
- autoCloseTimer .cancel ();
145
+ if (autoClose ) {
146
+ autoCloseTimer .cancel ();
147
+ }
139
148
dispatchEvent (new WindowEvent (this , WindowEvent .WINDOW_CLOSING ));
140
149
}
141
150
142
151
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
+ }
149
160
setVisible (true );
150
161
}
151
162
}
You can’t perform that action at this time.
0 commit comments