@@ -213,90 +213,172 @@ public final class PassFailJFrame {
213213
214214 public enum Position {HORIZONTAL , VERTICAL , TOP_LEFT_CORNER }
215215
216- public PassFailJFrame (String instructions ) throws InterruptedException ,
217- InvocationTargetException {
216+ /**
217+ * Constructs a frame which displays test instructions and
218+ * the <i>Pass</i> / <i>Fail</i> buttons with the given instructions, and
219+ * the default timeout of {@value #TEST_TIMEOUT} minutes,
220+ * the default title of {@value #TITLE} and
221+ * the default values of {@value #ROWS} and {@value #COLUMNS}
222+ * for rows and columns.
223+ * <p>
224+ * See {@link #PassFailJFrame(String,String,long,int,int,boolean)} for
225+ * more details.
226+ *
227+ * @param instructions the instructions for the tester
228+ *
229+ * @throws InterruptedException if the current thread is interrupted
230+ * while waiting for EDT to finish creating UI components
231+ * @throws InvocationTargetException if an exception is thrown while
232+ * creating UI components on EDT
233+ */
234+ public PassFailJFrame (String instructions )
235+ throws InterruptedException , InvocationTargetException {
218236 this (instructions , TEST_TIMEOUT );
219237 }
220238
221- public PassFailJFrame (String instructions , long testTimeOut ) throws
222- InterruptedException , InvocationTargetException {
239+ /**
240+ * Constructs a frame which displays test instructions and
241+ * the <i>Pass</i> / <i>Fail</i> buttons
242+ * with the given instructions and timeout as well as
243+ * the default title of {@value #TITLE}
244+ * and the default values of {@value #ROWS} and {@value #COLUMNS}
245+ * for rows and columns.
246+ * <p>
247+ * See {@link #PassFailJFrame(String,String,long,int,int,boolean)} for
248+ * more details.
249+ *
250+ * @param instructions the instructions for the tester
251+ * @param testTimeOut the test timeout in minutes
252+ *
253+ * @throws InterruptedException if the current thread is interrupted
254+ * while waiting for EDT to finish creating UI components
255+ * @throws InvocationTargetException if an exception is thrown while
256+ * creating UI components on EDT
257+ */
258+ public PassFailJFrame (String instructions , long testTimeOut )
259+ throws InterruptedException , InvocationTargetException {
223260 this (TITLE , instructions , testTimeOut );
224261 }
225262
263+ /**
264+ * Constructs a frame which displays test instructions and
265+ * the <i>Pass</i> / <i>Fail</i> buttons
266+ * with the given title, instructions and timeout as well as
267+ * the default values of {@value #ROWS} and {@value #COLUMNS}
268+ * for rows and columns.
269+ * The screenshot feature is not enabled, if you use this constructor.
270+ * <p>
271+ * See {@link #PassFailJFrame(String,String,long,int,int,boolean)} for
272+ * more details.
273+ *
274+ * @param title the title of the instruction frame
275+ * @param instructions the instructions for the tester
276+ * @param testTimeOut the test timeout in minutes
277+ *
278+ * @throws InterruptedException if the current thread is interrupted
279+ * while waiting for EDT to finish creating UI components
280+ * @throws InvocationTargetException if an exception is thrown while
281+ * creating UI components on EDT
282+ */
226283 public PassFailJFrame (String title , String instructions ,
227- long testTimeOut ) throws InterruptedException ,
228- InvocationTargetException {
284+ long testTimeOut )
285+ throws InterruptedException , InvocationTargetException {
229286 this (title , instructions , testTimeOut , ROWS , COLUMNS );
230287 }
231288
232289 /**
233- * Constructs a JFrame with a given title & serves as test instructional
234- * frame where the user follows the specified test instruction in order
235- * to test the test case & mark the test pass or fail. If the expected
236- * result is seen then the user click on the 'Pass' button else click
237- * on the 'Fail' button and the reason for the failure should be
238- * specified in the JDialog JTextArea.
290+ * Constructs a frame which displays test instructions and
291+ * the <i>Pass</i> / <i>Fail</i> buttons
292+ * with the given title, instructions, timeout, number of rows and columns.
293+ * The screenshot feature is not enabled, if you use this constructor.
294+ * <p>
295+ * See {@link #PassFailJFrame(String,String,long,int,int,boolean)} for
296+ * more details.
239297 *
240- * @param title title of the Frame.
241- * @param instructions the instruction for the tester on how to test
242- * and what is expected (pass) and what is not
243- * expected (fail).
244- * @param testTimeOut test timeout where time is specified in minutes.
245- * @param rows number of visible rows of the JTextArea where the
246- * instruction is show.
247- * @param columns Number of columns of the instructional
248- * JTextArea
249- * @throws InterruptedException exception thrown when thread is
250- * interrupted
298+ * @param title the title of the instruction frame
299+ * @param instructions the instructions for the tester
300+ * @param testTimeOut the test timeout in minutes
301+ * @param rows the number of rows for the text component
302+ * which displays test instructions
303+ * @param columns the number of columns for the text component
304+ * which displays test instructions
305+ *
306+ * @throws InterruptedException if the current thread is interrupted
307+ * while waiting for EDT to finish creating UI components
251308 * @throws InvocationTargetException if an exception is thrown while
252- * creating the test instruction frame on
253- * EDT
309+ * creating UI components on EDT
254310 */
255- public PassFailJFrame (String title , String instructions , long testTimeOut ,
256- int rows , int columns ) throws InterruptedException ,
257- InvocationTargetException {
311+ public PassFailJFrame (String title , String instructions ,
312+ long testTimeOut ,
313+ int rows , int columns )
314+ throws InterruptedException , InvocationTargetException {
258315 this (title , instructions , testTimeOut , rows , columns , false );
259316 }
260317
261318 /**
262- * Constructs a JFrame with a given title & serves as test instructional
263- * frame where the user follows the specified test instruction in order
264- * to test the test case & mark the test pass or fail. If the expected
265- * result is seen then the user click on the 'Pass' button else click
266- * on the 'Fail' button and the reason for the failure should be
267- * specified in the JDialog JTextArea.
319+ * Constructs a frame which displays test instructions and
320+ * the <i>Pass</i> / <i>Fail</i> buttons
321+ * as well as supporting UI components with the given title, instructions,
322+ * timeout, number of rows and columns,
323+ * and screen capture functionality.
324+ * All the UI components are created on the EDT, so it is safe to call
325+ * the constructor on the main thread.
268326 * <p>
269- * The test instruction frame also provides a way for the tester to take
270- * a screenshot (full screen or individual frame) if this feature
271- * is enabled by passing {@code true} as {@code enableScreenCapture}
272- * parameter.
327+ * After you create a test UI window, register the window using
328+ * {@link #addTestWindow(Window) addTestWindow} for disposal, and
329+ * position it close to the instruction frame using
330+ * {@link #positionTestWindow(Window, Position) positionTestWindow}.
331+ * As the last step, make your test UI window visible.
332+ * <p>
333+ * Call the {@link #awaitAndCheck() awaitAndCheck} method on the instance
334+ * of {@code PassFailJFrame} when you set up the testing environment.
335+ * <p>
336+ * If the tester clicks the <i>Fail</i> button, a dialog prompting for
337+ * a description of the problem is displayed, and then an exception
338+ * is thrown which fails the test.
339+ * If the tester clicks the <i>Pass</i> button, the test completes
340+ * successfully.
341+ * If the timeout occurs or the instruction frame is closed,
342+ * the test fails.
343+ * <p>
344+ * The {@code rows} and {@code columns} parameters control
345+ * the size of a text component which displays the instructions.
346+ * The preferred size of the instructions is calculated by
347+ * creating {@code new JTextArea(rows, columns)}.
348+ * <p>
349+ * If you enable screenshots by setting the {@code screenCapture}
350+ * parameter to {@code true}, a <i>Screenshot</i> button is added.
351+ * Clicking the <i>Screenshot</i> button takes screenshots of
352+ * all the monitors or all the windows registered with
353+ * {@code PassFailJFrame}.
273354 *
274- * @param title title of the Frame.
275- * @param instructions the instruction for the tester on how to test
276- * and what is expected (pass) and what is not
277- * expected (fail).
278- * @param testTimeOut test timeout where time is specified in minutes.
279- * @param rows number of visible rows of the JTextArea where the
280- * instruction is show.
281- * @param columns Number of columns of the instructional
282- * JTextArea
283- * @param enableScreenCapture if set to true, 'Capture Screen' button & its
284- * associated UIs are added to test instruction
285- * frame
286- * @throws InterruptedException exception thrown when thread is
287- * interrupted
355+ * @param title the title of the instruction frame
356+ * @param instructions the instructions for the tester
357+ * @param testTimeOut the test timeout in minutes
358+ * @param rows the number of rows for the text component
359+ * which displays test instructions
360+ * @param columns the number of columns for the text component
361+ * which displays test instructions
362+ * @param screenCapture if set to {@code true}, enables screen capture
363+ * functionality
364+ *
365+ * @throws InterruptedException if the current thread is interrupted
366+ * while waiting for EDT to finish creating UI components
288367 * @throws InvocationTargetException if an exception is thrown while
289- * creating the test instruction frame on
290- * EDT
368+ * creating UI components on EDT
369+ *
370+ * @see JTextArea#JTextArea(int,int) JTextArea(int rows, int columns)
371+ * @see Builder Builder
291372 */
292- public PassFailJFrame (String title , String instructions , long testTimeOut ,
373+ public PassFailJFrame (String title , String instructions ,
374+ long testTimeOut ,
293375 int rows , int columns ,
294- boolean enableScreenCapture )
376+ boolean screenCapture )
295377 throws InterruptedException , InvocationTargetException {
296378 invokeOnEDT (() -> createUI (title , instructions ,
297379 testTimeOut ,
298380 rows , columns ,
299- enableScreenCapture ));
381+ screenCapture ));
300382 }
301383
302384 /**
0 commit comments