File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change 6060public 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}
You can’t perform that action at this time.
0 commit comments