Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
J
jdk17u
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
einsteinathome
openjdk
jdk17u
Commits
95ca457e
Commit
95ca457e
authored
Feb 26, 2024
by
Andrew Lu
Browse files
Options
Downloads
Patches
Plain Diff
8294158: HTML formatting for PassFailJFrame instructions
Backport-of: 14090ef6039ff2f3064f397a75219b2bc715cc27
parent
5de649a6
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/jdk/java/awt/regtesthelpers/PassFailJFrame.java
+40
-5
40 additions, 5 deletions
test/jdk/java/awt/regtesthelpers/PassFailJFrame.java
with
40 additions
and
5 deletions
test/jdk/java/awt/regtesthelpers/PassFailJFrame.java
+
40
−
5
View file @
95ca457e
...
...
@@ -51,6 +51,7 @@ import javax.swing.JButton;
import
javax.swing.JComboBox
;
import
javax.swing.JComponent
;
import
javax.swing.JDialog
;
import
javax.swing.JEditorPane
;
import
javax.swing.JFrame
;
import
javax.swing.JLabel
;
import
javax.swing.JOptionPane
;
...
...
@@ -58,6 +59,9 @@ import javax.swing.JPanel;
import
javax.swing.JScrollPane
;
import
javax.swing.JTextArea
;
import
javax.swing.Timer
;
import
javax.swing.text.JTextComponent
;
import
javax.swing.text.html.HTMLEditorKit
;
import
javax.swing.text.html.StyleSheet
;
import
static
javax
.
swing
.
SwingUtilities
.
invokeAndWait
;
import
static
javax
.
swing
.
SwingUtilities
.
isEventDispatchThread
;
...
...
@@ -81,8 +85,11 @@ public class PassFailJFrame {
private
static
volatile
boolean
failed
;
private
static
volatile
boolean
timeout
;
private
static
volatile
String
testFailedReason
;
private
static
final
AtomicInteger
imgCounter
=
new
AtomicInteger
(
0
);
private
static
JFrame
frame
;
private
static
Robot
robot
;
public
enum
Position
{
HORIZONTAL
,
VERTICAL
,
TOP_LEFT_CORNER
}
...
...
@@ -187,9 +194,11 @@ public class PassFailJFrame {
boolean
enableScreenCapture
)
{
frame
=
new
JFrame
(
title
);
frame
.
setLayout
(
new
BorderLayout
());
JTextArea
instructionsText
=
new
JTextArea
(
instructions
,
rows
,
columns
);
instructionsText
.
setEditable
(
false
);
instructionsText
.
setLineWrap
(
true
);
JTextComponent
text
=
instructions
.
startsWith
(
"<html>"
)
?
configureHTML
(
instructions
,
rows
,
columns
)
:
configurePlainText
(
instructions
,
rows
,
columns
);
text
.
setEditable
(
false
);
long
tTimeout
=
TimeUnit
.
MINUTES
.
toMillis
(
testTimeOut
);
...
...
@@ -210,7 +219,7 @@ public class PassFailJFrame {
});
timer
.
start
();
frame
.
add
(
testTimeoutLabel
,
BorderLayout
.
NORTH
);
frame
.
add
(
new
JScrollPane
(
instructionsT
ext
),
BorderLayout
.
CENTER
);
frame
.
add
(
new
JScrollPane
(
t
ext
),
BorderLayout
.
CENTER
);
JButton
btnPass
=
new
JButton
(
"Pass"
);
btnPass
.
addActionListener
((
e
)
->
{
...
...
@@ -249,6 +258,32 @@ public class PassFailJFrame {
windowList
.
add
(
frame
);
}
private
static
JTextComponent
configurePlainText
(
String
instructions
,
int
rows
,
int
columns
)
{
JTextArea
text
=
new
JTextArea
(
instructions
,
rows
,
columns
);
text
.
setLineWrap
(
true
);
text
.
setWrapStyleWord
(
true
);
return
text
;
}
private
static
JTextComponent
configureHTML
(
String
instructions
,
int
rows
,
int
columns
)
{
JEditorPane
text
=
new
JEditorPane
(
"text/html"
,
instructions
);
text
.
putClientProperty
(
JEditorPane
.
HONOR_DISPLAY_PROPERTIES
,
Boolean
.
TRUE
);
// Set preferred size as if it were JTextArea
text
.
setPreferredSize
(
new
JTextArea
(
rows
,
columns
).
getPreferredSize
());
HTMLEditorKit
kit
=
(
HTMLEditorKit
)
text
.
getEditorKit
();
StyleSheet
styles
=
kit
.
getStyleSheet
();
// 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 }"
);
return
text
;
}
private
static
JComponent
createCapturePanel
()
{
JComboBox
<
CaptureType
>
screenShortType
=
new
JComboBox
<>(
CaptureType
.
values
());
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment