1
1
/*
2
- * Copyright (c) 2018, 2019 , Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2018, 2021 , Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
23
23
24
24
/*
25
25
* @test
26
- * @bug 8153732 8212202 8221263 8221412 8222108
26
+ * @bug 8153732 8212202 8221263 8221412 8222108 8263311
27
27
* @requires (os.family == "Windows")
28
28
* @summary Windows remote printer changes do not reflect in lookupPrintServices()
29
- * @run main/manual/othervm -Dsun.java2d.print.minRefreshTime=120 RemotePrinterStatusRefresh
29
+ * @run main/manual RemotePrinterStatusRefresh
30
30
*/
31
31
32
32
import java .awt .BorderLayout ;
63
63
64
64
public class RemotePrinterStatusRefresh extends WindowAdapter {
65
65
66
- private static final long DEFAULT_REFRESH_TIME = 240L ;
67
- private static final long MINIMAL_REFRESH_TIME = 120L ;
68
-
69
- private static final long refreshTime = getRefreshTime ();
70
-
71
- private static final long TIMEOUT = refreshTime * 4 + 60 ;
66
+ private static final long TIMEOUT = 15L * 60 ;
72
67
73
68
74
69
private static final CountDownLatch latch = new CountDownLatch (1 );
@@ -86,7 +81,6 @@ public class RemotePrinterStatusRefresh extends WindowAdapter {
86
81
private final ServiceItemListModel beforeList ;
87
82
private final ServiceItemListModel afterList ;
88
83
89
- private JTextField nextRefresh ;
90
84
private JTextField timeLeft ;
91
85
92
86
private final Timer timer ;
@@ -184,22 +178,18 @@ public Component getListCellRendererComponent(JList<?> list,
184
178
+ "configured printers.\n "
185
179
+ "Step 1: Add or Remove a network printer using "
186
180
+ "Windows Control Panel.\n "
187
- + "Step 2: Wait for 2\u2013 4 minutes after adding or removing.\n "
188
- + " \" Next printer refresh in\" gives you a "
189
- + "rough estimation on when update will happen.\n "
190
- + "Step 3: Click Refresh."
181
+ + "Step 2: Click Refresh."
191
182
+ "\" After\" list is populated with updated list "
192
183
+ "of printers.\n "
193
- + "Step 4 : Compare the list of printers in \" Before\" and "
184
+ + "Step 3 : Compare the list of printers in \" Before\" and "
194
185
+ "\" After\" lists.\n "
195
186
+ " Added printers are highlighted with "
196
187
+ "green color, removed ones \u2014 with "
197
188
+ "red color.\n "
198
- + "Step 5 : Click Pass if the list of printers is correctly "
189
+ + "Step 4 : Click Pass if the list of printers is correctly "
199
190
+ "updated.\n "
200
- + "Step 6: If the list is not updated, wait for another "
201
- + "2\u2013 4 minutes, and then click Refresh again.\n "
202
- + "Step 7: If the list does not update, click Fail.\n "
191
+ + "Step 5: If the list is not updated, click Refresh again.\n "
192
+ + "Step 6: If the list does not update, click Fail.\n "
203
193
+ "\n "
204
194
+ "You have to click Refresh to enable Pass and Fail buttons. "
205
195
+ "If no button is pressed,\n "
@@ -216,18 +206,6 @@ public static void main(String[] args) throws Exception {
216
206
}
217
207
}
218
208
219
- private static long getRefreshTime () {
220
- String refreshTime =
221
- System .getProperty ("sun.java2d.print.minRefreshTime" ,
222
- Long .toString (DEFAULT_REFRESH_TIME ));
223
- try {
224
- long value = Long .parseLong (refreshTime );
225
- return value < MINIMAL_REFRESH_TIME ? MINIMAL_REFRESH_TIME : value ;
226
- } catch (NumberFormatException e ) {
227
- return DEFAULT_REFRESH_TIME ;
228
- }
229
- }
230
-
231
209
private static void createUI () {
232
210
test = new RemotePrinterStatusRefresh ();
233
211
}
@@ -278,31 +256,6 @@ private JPanel createInfoPanel() {
278
256
javaVersion .setEditable (false );
279
257
javaLabel .setLabelFor (javaVersion );
280
258
281
- JLabel refreshTimeLabel = new JLabel ("Refresh interval:" );
282
- long minutes = refreshTime / 60 ;
283
- long seconds = refreshTime % 60 ;
284
- String interval = String .format ("%1$d seconds%2$s" ,
285
- refreshTime ,
286
- minutes > 0
287
- ? String .format (" (%1$d %2$s%3$s)" ,
288
- minutes ,
289
- minutes > 1 ? "minutes" : "minute" ,
290
- seconds > 0
291
- ? String .format (" %1$d %2$s" ,
292
- seconds ,
293
- seconds > 1 ? "seconds" : "second" )
294
- : "" )
295
- : ""
296
- );
297
- JTextField refreshInterval = new JTextField (interval );
298
- refreshInterval .setEditable (false );
299
- refreshTimeLabel .setLabelFor (refreshInterval );
300
-
301
- JLabel nextRefreshLabel = new JLabel ("Next printer refresh in:" );
302
- nextRefresh = new JTextField ();
303
- nextRefresh .setEditable (false );
304
- nextRefreshLabel .setLabelFor (nextRefresh );
305
-
306
259
JLabel timeoutLabel = new JLabel ("Time left:" );
307
260
timeLeft = new JTextField ();
308
261
timeLeft .setEditable (false );
@@ -317,14 +270,10 @@ private JPanel createInfoPanel() {
317
270
layout .createSequentialGroup ()
318
271
.addGroup (layout .createParallelGroup (GroupLayout .Alignment .LEADING )
319
272
.addComponent (javaLabel )
320
- .addComponent (refreshTimeLabel )
321
- .addComponent (nextRefreshLabel )
322
273
.addComponent (timeoutLabel )
323
274
)
324
275
.addGroup (layout .createParallelGroup (GroupLayout .Alignment .LEADING , true )
325
276
.addComponent (javaVersion )
326
- .addComponent (refreshInterval )
327
- .addComponent (nextRefresh )
328
277
.addComponent (timeLeft )
329
278
)
330
279
);
@@ -334,12 +283,6 @@ private JPanel createInfoPanel() {
334
283
.addComponent (javaLabel )
335
284
.addComponent (javaVersion )
336
285
)
337
- .addGroup (layout .createParallelGroup (GroupLayout .Alignment .BASELINE )
338
- .addComponent (refreshTimeLabel )
339
- .addComponent (refreshInterval ))
340
- .addGroup (layout .createParallelGroup (GroupLayout .Alignment .BASELINE )
341
- .addComponent (nextRefreshLabel )
342
- .addComponent (nextRefresh ))
343
286
.addGroup (layout .createParallelGroup (GroupLayout .Alignment .BASELINE )
344
287
.addComponent (timeoutLabel )
345
288
.addComponent (timeLeft ))
@@ -493,7 +436,6 @@ private void updateTimeLeft(ActionEvent e) {
493
436
disposeUI ();
494
437
}
495
438
timeLeft .setText (formatTime (left ));
496
- nextRefresh .setText (formatTime (refreshTime - (elapsed % refreshTime )));
497
439
}
498
440
499
441
private static String formatTime (final long seconds ) {
0 commit comments