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
6a3c646b
Commit
6a3c646b
authored
9 months ago
by
Goetz Lindenmaier
Browse files
Options
Downloads
Patches
Plain Diff
8325762: Use PassFailJFrame.Builder.splitUI() in PrintLatinCJKTest.java
Backport-of: 41242cbe5d01fc6e19859626dd08f6191e7486fb
parent
9000e17a
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/jdk/java/awt/print/PrinterJob/PrintLatinCJKTest.java
+56
-49
56 additions, 49 deletions
test/jdk/java/awt/print/PrinterJob/PrintLatinCJKTest.java
with
56 additions
and
49 deletions
test/jdk/java/awt/print/PrinterJob/PrintLatinCJKTest.java
+
56
−
49
View file @
6a3c646b
/*
/*
* Copyright (c) 2013, 202
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013, 202
4
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -31,7 +31,6 @@
...
@@ -31,7 +31,6 @@
* @run main/manual PrintLatinCJKTest
* @run main/manual PrintLatinCJKTest
*/
*/
import
java.awt.BorderLayout
;
import
java.awt.Font
;
import
java.awt.Font
;
import
java.awt.Graphics
;
import
java.awt.Graphics
;
import
java.awt.print.PageFormat
;
import
java.awt.print.PageFormat
;
...
@@ -39,51 +38,57 @@ import java.awt.print.Printable;
...
@@ -39,51 +38,57 @@ import java.awt.print.Printable;
import
java.awt.print.PrinterException
;
import
java.awt.print.PrinterException
;
import
java.awt.print.PrinterJob
;
import
java.awt.print.PrinterJob
;
import
java.lang.reflect.InvocationTargetException
;
import
java.lang.reflect.InvocationTargetException
;
import
javax.swing.JButton
;
import
javax.swing.JFrame
;
import
static
javax
.
swing
.
SwingUtilities
.
invokeAndWait
;
import
javax.swing.BorderFactory
;
import
javax.swing.Box
;
import
javax.swing.JButton
;
import
javax.swing.JComponent
;
import
javax.swing.JOptionPane
;
public
class
PrintLatinCJKTest
implements
Printable
{
public
class
PrintLatinCJKTest
implements
Printable
{
private
static
PrintLatinCJKTest
testInstance
=
new
PrintLatinCJKTest
();
private
static
final
String
TEXT
=
"\u4e00\u4e01\u4e02\u4e03\u4e04English"
;
private
static
JFrame
frame
;
private
static
final
String
info
=
"""
private
static
final
String
INFO
=
"""
You need a printer for this test. If you have none, let
Press Print, send the output to the printer and examine it.
the test pass. If there is a printer, press Print, send
The printout should have text looking like this:
the output to the printer, and examine it. It should have
text looking like this : \u4e00\u4e01\u4e02\u4e03\u4e04English
"""
+
TEXT
+
"""
Press Pass if the text is printed correctly.
If Japanese and English text overlap, press Fail.
To test 8022536, if a remote printer is the system default,
To test 8022536, if a remote printer is the system default,
it should show in the dialog as the selected printer.
it should show in the dialog as the selected printer.
"""
;
"""
;
public
static
void
showFrame
()
throws
InterruptedException
,
InvocationTargetException
{
private
static
JComponent
createTestUI
()
{
invokeAndWait
(
()
->
{
frame
=
new
JFrame
(
"Test Frame"
);
JButton
b
=
new
JButton
(
"Print"
);
JButton
b
=
new
JButton
(
"Print"
);
b
.
addActionListener
((
ae
)
->
{
b
.
addActionListener
((
ae
)
->
{
try
{
try
{
PrinterJob
job
=
PrinterJob
.
getPrinterJob
();
PrinterJob
job
=
PrinterJob
.
getPrinterJob
();
job
.
setPrintable
(
testInstance
);
job
.
setPrintable
(
new
PrintLatinCJKTest
()
);
if
(
job
.
printDialog
())
{
if
(
job
.
printDialog
())
{
job
.
print
();
job
.
print
();
}
}
}
catch
(
PrinterException
ex
)
{
}
catch
(
PrinterException
ex
)
{
ex
.
printStackTrace
();
ex
.
printStackTrace
();
String
msg
=
"PrinterException: "
+
ex
.
getMessage
();
JOptionPane
.
showMessageDialog
(
b
,
msg
,
"Error occurred"
,
JOptionPane
.
ERROR_MESSAGE
);
PassFailJFrame
.
forceFail
(
msg
);
}
}
});
});
frame
.
getContentPane
().
add
(
b
,
BorderLayout
.
SOUTH
);
frame
.
pack
();
// add the test frame to dispose
Box
main
=
Box
.
createHorizontalBox
();
PassFailJFrame
.
addTestWindow
(
frame
);
main
.
setBorder
(
BorderFactory
.
createEmptyBorder
(
8
,
8
,
8
,
8
));
main
.
add
(
Box
.
createHorizontalGlue
());
// Arrange the test instruction frame and test frame side by side
main
.
add
(
b
);
PassFailJFrame
.
positionTestWindow
(
frame
,
main
.
add
(
Box
.
createHorizontalGlue
());
PassFailJFrame
.
Position
.
HORIZONTAL
);
return
main
;
frame
.
setVisible
(
true
);
});
}
}
@Override
@Override
...
@@ -93,22 +98,24 @@ public class PrintLatinCJKTest implements Printable {
...
@@ -93,22 +98,24 @@ public class PrintLatinCJKTest implements Printable {
return
Printable
.
NO_SUCH_PAGE
;
return
Printable
.
NO_SUCH_PAGE
;
}
}
g
.
translate
((
int
)
pf
.
getImageableX
(),
(
int
)
pf
.
getImageableY
());
g
.
translate
((
int
)
pf
.
getImageableX
(),
(
int
)
pf
.
getImageableY
());
g
.
setFont
(
new
Font
(
"Dialog"
,
Font
.
PLAIN
,
36
));
g
.
setFont
(
new
Font
(
Font
.
DIALOG
,
Font
.
PLAIN
,
36
));
g
.
drawString
(
"\u4e00\u4e01\u4e02\u4e03\u4e04English"
,
20
,
100
);
g
.
drawString
(
TEXT
,
20
,
100
);
return
Printable
.
PAGE_EXISTS
;
return
Printable
.
PAGE_EXISTS
;
}
}
public
static
void
main
(
String
[]
args
)
throws
InterruptedException
,
InvocationTargetException
{
public
static
void
main
(
String
[]
args
)
throws
InterruptedException
,
InvocationTargetException
{
PassFailJFrame
passFailJFrame
=
new
PassFailJFrame
.
Builder
()
if
(
PrinterJob
.
lookupPrintServices
().
length
==
0
)
{
.
title
(
"Test Instructions Frame"
)
throw
new
RuntimeException
(
"Printer not configured or available."
);
.
instructions
(
info
)
}
PassFailJFrame
.
builder
()
.
title
(
"Print Latin CJK Test"
)
.
instructions
(
INFO
)
.
testTimeOut
(
10
)
.
testTimeOut
(
10
)
.
rows
(
1
0
)
.
rows
(
1
2
)
.
columns
(
45
)
.
columns
(
30
)
.
build
();
.
splitUI
(
PrintLatinCJKTest:
:
createTestUI
)
showFrame
()
;
.
build
()
passFailJFrame
.
awaitAndCheck
();
.
awaitAndCheck
();
}
}
}
}
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
register
or
sign in
to comment