Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion test/jdk/java/awt/regtesthelpers/PassFailJFrame.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import javax.swing.JSplitPane;
import javax.swing.JTextArea;
import javax.swing.Timer;
import javax.swing.event.HyperlinkListener;
import javax.swing.text.JTextComponent;
import javax.swing.text.html.HTMLEditorKit;
import javax.swing.text.html.StyleSheet;
Expand Down Expand Up @@ -402,6 +403,7 @@ private static void createUI(String title, String instructions,
frame.add(createInstructionUIPanel(instructions,
testTimeOut,
rows, columns,
null,
enableScreenCapture,
false, 0),
BorderLayout.CENTER);
Expand All @@ -420,6 +422,7 @@ private static void createUI(Builder builder) {
createInstructionUIPanel(builder.instructions,
builder.testTimeOut,
builder.rows, builder.columns,
builder.hyperlinkListener,
builder.screenCapture,
builder.addLogArea,
builder.logAreaRows);
Expand All @@ -441,6 +444,7 @@ private static void createUI(Builder builder) {
private static JComponent createInstructionUIPanel(String instructions,
long testTimeOut,
int rows, int columns,
HyperlinkListener hyperlinkListener,
boolean enableScreenCapture,
boolean addLogArea,
int logAreaRows) {
Expand All @@ -453,6 +457,9 @@ private static JComponent createInstructionUIPanel(String instructions,
JTextComponent text = instructions.startsWith("<html>")
? configureHTML(instructions, rows, columns)
: configurePlainText(instructions, rows, columns);
if (hyperlinkListener != null && text instanceof JEditorPane) {
((JEditorPane) text).addHyperlinkListener(hyperlinkListener);
}
text.setEditable(false);

main.add(new JScrollPane(text), BorderLayout.CENTER);
Expand Down Expand Up @@ -517,7 +524,7 @@ private static JTextComponent configureHTML(String instructions,
// Reduce the default margins
styles.addRule("ol, ul { margin-left-ltr: 20; margin-left-rtl: 20 }");
// Make the size of code blocks the same as other text
styles.addRule("code { font-size: inherit }");
styles.addRule("code { font-size: inherit; background: #DDD; }");

return text;
}
Expand Down Expand Up @@ -1111,6 +1118,7 @@ public static final class Builder {
private int rows;
private int columns;
private boolean screenCapture;
private HyperlinkListener hyperlinkListener;
private boolean addLogArea;
private int logAreaRows = 10;

Expand Down Expand Up @@ -1149,6 +1157,18 @@ public Builder columns(int columns) {
return this;
}

/**
* Sets a {@link HyperlinkListener} for navigating links inside
* the instructions pane.
*
* @param hyperlinkListener the listener
* @return this builder
*/
public Builder hyperlinkListener(HyperlinkListener hyperlinkListener) {
this.hyperlinkListener = hyperlinkListener;
return this;
}

public Builder screenCapture() {
this.screenCapture = true;
return this;
Expand Down