8290469: Add new positioning options to PassFailJFrame test framework
Reviewed-by: prr, aivanov
This commit is contained in:
parent
69448f9c1a
commit
568be58e85
test/jdk
java/awt
Dialog/ModalDialogTest
TrayIcon
print/PrinterJob
regtesthelpers
javax/swing
JRadioButton
JTabbedPane/4209065
JTable
text/html
@ -47,6 +47,7 @@ import java.awt.event.MouseMotionListener;
|
|||||||
import java.awt.event.WindowEvent;
|
import java.awt.event.WindowEvent;
|
||||||
import java.awt.event.WindowListener;
|
import java.awt.event.WindowListener;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
@ -210,7 +211,9 @@ class WindowPanel extends Panel {
|
|||||||
win.add(center, BorderLayout.CENTER);
|
win.add(center, BorderLayout.CENTER);
|
||||||
win.add(bottom, BorderLayout.SOUTH);
|
win.add(bottom, BorderLayout.SOUTH);
|
||||||
win.pack();
|
win.pack();
|
||||||
win.setVisible(true);
|
if (windows != 0) {
|
||||||
|
win.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
PassFailJFrame.addTestWindow(win);
|
PassFailJFrame.addTestWindow(win);
|
||||||
}
|
}
|
||||||
@ -344,16 +347,20 @@ public class ModalDialogTest {
|
|||||||
PassFailJFrame passFailJFrame = new PassFailJFrame("ModalDialogTest " +
|
PassFailJFrame passFailJFrame = new PassFailJFrame("ModalDialogTest " +
|
||||||
"Instructions", getInstructions(), 10, 20, 60);
|
"Instructions", getInstructions(), 10, 20, 60);
|
||||||
|
|
||||||
WindowPanel.buildAndShowWindow(
|
SwingUtilities.invokeAndWait(() ->{
|
||||||
frame,
|
WindowPanel.buildAndShowWindow(
|
||||||
new Label("Owner: none"),
|
frame,
|
||||||
new TestPanel(new TextArea(10, 30)),
|
new Label("Owner: none"),
|
||||||
new WindowPanel()
|
new TestPanel(new TextArea(10, 30)),
|
||||||
);
|
new WindowPanel()
|
||||||
|
);
|
||||||
|
|
||||||
|
// adding only the root frame to be positioned
|
||||||
|
// w.r.t instruction frame
|
||||||
|
passFailJFrame.positionTestWindow(frame, PassFailJFrame.Position.HORIZONTAL);
|
||||||
|
frame.setVisible(true);
|
||||||
|
});
|
||||||
|
|
||||||
// adding only the root frame to be positioned
|
|
||||||
// w.r.t instruction frame
|
|
||||||
passFailJFrame.positionTestWindow(frame, PassFailJFrame.Position.HORIZONTAL);
|
|
||||||
passFailJFrame.awaitAndCheck();
|
passFailJFrame.awaitAndCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,6 +81,10 @@ public class TrayIconScalingTest {
|
|||||||
PassFailJFrame passFailJFrame = new PassFailJFrame("TrayIcon " +
|
PassFailJFrame passFailJFrame = new PassFailJFrame("TrayIcon " +
|
||||||
"Test Instructions", INSTRUCTIONS, 8, 18, 85);
|
"Test Instructions", INSTRUCTIONS, 8, 18, 85);
|
||||||
createAndShowGUI();
|
createAndShowGUI();
|
||||||
|
// does not have a test window,
|
||||||
|
// hence only the instruction frame is positioned
|
||||||
|
PassFailJFrame.positionTestWindow(null,
|
||||||
|
PassFailJFrame.Position.HORIZONTAL);
|
||||||
try {
|
try {
|
||||||
passFailJFrame.awaitAndCheck();
|
passFailJFrame.awaitAndCheck();
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -59,6 +59,7 @@ import static java.awt.EventQueue.invokeAndWait;
|
|||||||
public class ClippedImages {
|
public class ClippedImages {
|
||||||
|
|
||||||
private static ClippedImageCanvas c;
|
private static ClippedImageCanvas c;
|
||||||
|
private static Frame frame;
|
||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException,
|
public static void main(String[] args) throws InterruptedException,
|
||||||
InvocationTargetException {
|
InvocationTargetException {
|
||||||
@ -100,7 +101,7 @@ public class ClippedImages {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void createTestUI() {
|
public static void createTestUI() {
|
||||||
Frame frame = new Frame("Clipped Src Area Image Printing Test");
|
frame = new Frame("Clipped Src Area Image Printing Test");
|
||||||
c = new ClippedImageCanvas();
|
c = new ClippedImageCanvas();
|
||||||
frame.add(c, BorderLayout.CENTER);
|
frame.add(c, BorderLayout.CENTER);
|
||||||
|
|
||||||
@ -123,10 +124,10 @@ public class ClippedImages {
|
|||||||
frame.add(p, BorderLayout.SOUTH);
|
frame.add(p, BorderLayout.SOUTH);
|
||||||
frame.setLocationRelativeTo(null);
|
frame.setLocationRelativeTo(null);
|
||||||
frame.pack();
|
frame.pack();
|
||||||
frame.setVisible(true);
|
|
||||||
|
|
||||||
PassFailJFrame.addTestWindow(frame);
|
PassFailJFrame.addTestWindow(frame);
|
||||||
PassFailJFrame.positionTestWindow(frame, PassFailJFrame.Position.HORIZONTAL);
|
PassFailJFrame.positionTestWindow(frame, PassFailJFrame.Position.HORIZONTAL);
|
||||||
|
frame.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void printOne() {
|
private static void printOne() {
|
||||||
|
@ -34,13 +34,11 @@ import java.awt.BorderLayout;
|
|||||||
import java.awt.Button;
|
import java.awt.Button;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Component;
|
import java.awt.Component;
|
||||||
import java.awt.Dialog;
|
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.Frame;
|
import java.awt.Frame;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
import java.awt.Label;
|
|
||||||
import java.awt.font.FontRenderContext;
|
import java.awt.font.FontRenderContext;
|
||||||
import java.awt.font.GlyphVector;
|
import java.awt.font.GlyphVector;
|
||||||
import java.awt.geom.Point2D;
|
import java.awt.geom.Point2D;
|
||||||
@ -51,6 +49,7 @@ import java.awt.print.PrinterException;
|
|||||||
import java.awt.print.PrinterJob;
|
import java.awt.print.PrinterJob;
|
||||||
|
|
||||||
public class PrintGlyphVectorTest extends Component implements Printable {
|
public class PrintGlyphVectorTest extends Component implements Printable {
|
||||||
|
private static Frame f;
|
||||||
|
|
||||||
private static final String INSTRUCTIONS = """
|
private static final String INSTRUCTIONS = """
|
||||||
Note: You must have a printer installed for this test.
|
Note: You must have a printer installed for this test.
|
||||||
@ -128,7 +127,7 @@ public class PrintGlyphVectorTest extends Component implements Printable {
|
|||||||
PassFailJFrame.forcePass();
|
PassFailJFrame.forcePass();
|
||||||
}
|
}
|
||||||
|
|
||||||
Frame f = new Frame("Test PrintGlyphVector");
|
f = new Frame("Test PrintGlyphVector");
|
||||||
PrintGlyphVectorTest pvt = new PrintGlyphVectorTest();
|
PrintGlyphVectorTest pvt = new PrintGlyphVectorTest();
|
||||||
f.add(pvt, BorderLayout.CENTER);
|
f.add(pvt, BorderLayout.CENTER);
|
||||||
|
|
||||||
@ -149,13 +148,13 @@ public class PrintGlyphVectorTest extends Component implements Printable {
|
|||||||
|
|
||||||
f.add(printButton, BorderLayout.SOUTH);
|
f.add(printButton, BorderLayout.SOUTH);
|
||||||
f.pack();
|
f.pack();
|
||||||
f.setVisible(true);
|
|
||||||
|
|
||||||
// add the test frame to dispose
|
// add the test frame to dispose
|
||||||
PassFailJFrame.addTestWindow(f);
|
PassFailJFrame.addTestWindow(f);
|
||||||
|
|
||||||
// Arrange the test instruction frame and test frame side by side
|
// Arrange the test instruction frame and test frame side by side
|
||||||
PassFailJFrame.positionTestWindow(f, PassFailJFrame.Position.HORIZONTAL);
|
PassFailJFrame.positionTestWindow(f, PassFailJFrame.Position.HORIZONTAL);
|
||||||
|
f.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] arg) throws Exception {
|
public static void main(String[] arg) throws Exception {
|
||||||
|
@ -74,8 +74,6 @@ public class PrintLatinCJKTest implements Printable {
|
|||||||
});
|
});
|
||||||
frame.getContentPane().add(b, BorderLayout.SOUTH);
|
frame.getContentPane().add(b, BorderLayout.SOUTH);
|
||||||
frame.pack();
|
frame.pack();
|
||||||
frame.setLocationRelativeTo(null);
|
|
||||||
frame.setVisible(true);
|
|
||||||
|
|
||||||
// add the test frame to dispose
|
// add the test frame to dispose
|
||||||
PassFailJFrame.addTestWindow(frame);
|
PassFailJFrame.addTestWindow(frame);
|
||||||
@ -83,6 +81,7 @@ public class PrintLatinCJKTest implements Printable {
|
|||||||
// Arrange the test instruction frame and test frame side by side
|
// Arrange the test instruction frame and test frame side by side
|
||||||
PassFailJFrame.positionTestWindow(frame,
|
PassFailJFrame.positionTestWindow(frame,
|
||||||
PassFailJFrame.Position.HORIZONTAL);
|
PassFailJFrame.Position.HORIZONTAL);
|
||||||
|
frame.setVisible(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +99,7 @@ public class PrintLatinCJKTest implements Printable {
|
|||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException, InvocationTargetException {
|
public static void main(String[] args) throws InterruptedException, InvocationTargetException {
|
||||||
PassFailJFrame passFailJFrame = new PassFailJFrame("Test Instruction" +
|
PassFailJFrame passFailJFrame = new PassFailJFrame("Test Instruction" +
|
||||||
"Frame", info, 10, 40, 5);
|
"Frame", info, 10, 10, 45);
|
||||||
showFrame();
|
showFrame();
|
||||||
passFailJFrame.awaitAndCheck();
|
passFailJFrame.awaitAndCheck();
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,10 @@
|
|||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.GraphicsConfiguration;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
|
import java.awt.Insets;
|
||||||
|
import java.awt.Rectangle;
|
||||||
import java.awt.Toolkit;
|
import java.awt.Toolkit;
|
||||||
import java.awt.Window;
|
import java.awt.Window;
|
||||||
import java.awt.event.WindowAdapter;
|
import java.awt.event.WindowAdapter;
|
||||||
@ -41,6 +45,7 @@ import javax.swing.JScrollPane;
|
|||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
|
|
||||||
|
|
||||||
import static javax.swing.SwingUtilities.invokeAndWait;
|
import static javax.swing.SwingUtilities.invokeAndWait;
|
||||||
import static javax.swing.SwingUtilities.isEventDispatchThread;
|
import static javax.swing.SwingUtilities.isEventDispatchThread;
|
||||||
|
|
||||||
@ -60,7 +65,7 @@ public class PassFailJFrame {
|
|||||||
private static volatile String testFailedReason;
|
private static volatile String testFailedReason;
|
||||||
private static JFrame frame;
|
private static JFrame frame;
|
||||||
|
|
||||||
public enum Position {HORIZONTAL, VERTICAL}
|
public enum Position {HORIZONTAL, VERTICAL, TOP_LEFT_CORNER}
|
||||||
|
|
||||||
public PassFailJFrame(String instructions) throws InterruptedException,
|
public PassFailJFrame(String instructions) throws InterruptedException,
|
||||||
InvocationTargetException {
|
InvocationTargetException {
|
||||||
@ -171,7 +176,6 @@ public class PassFailJFrame {
|
|||||||
frame.add(buttonsPanel, BorderLayout.SOUTH);
|
frame.add(buttonsPanel, BorderLayout.SOUTH);
|
||||||
frame.pack();
|
frame.pack();
|
||||||
frame.setLocationRelativeTo(null);
|
frame.setLocationRelativeTo(null);
|
||||||
frame.setVisible(true);
|
|
||||||
windowList.add(frame);
|
windowList.add(frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,31 +261,116 @@ public class PassFailJFrame {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Position the instruction frame with testWindow (testcase created
|
* Approximately positions the instruction frame relative to the test
|
||||||
* window) by the specified position.
|
* window as specified by the {@code position} parameter. If {@code testWindow}
|
||||||
* Note: This method should be invoked from the method that creates
|
* is {@code null}, only the instruction frame is positioned according to
|
||||||
* testWindow.
|
* {@code position} parameter.
|
||||||
|
* <p>This method should be called before making the test window visible
|
||||||
|
* to avoid flickering.</p>
|
||||||
*
|
*
|
||||||
* @param testWindow test window that the test is created
|
* @param testWindow test window that the test created.
|
||||||
* @param position position can be either HORIZONTAL (both test
|
* May be {@code null}.
|
||||||
* instruction frame and test window as arranged
|
*
|
||||||
* side by side) or VERTICAL (both test instruction
|
* @param position position must be one of:
|
||||||
* frame and test window as arranged up and down)
|
* <ul>
|
||||||
|
* <li>{@code HORIZONTAL} - the test instruction frame is positioned
|
||||||
|
* such that its right edge aligns with screen's horizontal center
|
||||||
|
* and the test window (if not {@code null}) is placed to the right
|
||||||
|
* of the instruction frame.</li>
|
||||||
|
*
|
||||||
|
* <li>{@code VERTICAL} - the test instruction frame is positioned
|
||||||
|
* such that its bottom edge aligns with the screen's vertical center
|
||||||
|
* and the test window (if not {@code null}) is placed below the
|
||||||
|
* instruction frame.</li>
|
||||||
|
*
|
||||||
|
* <li>{@code TOP_LEFT_CORNER} - the test instruction frame is positioned
|
||||||
|
* such that its top left corner is at the top left corner of the screen
|
||||||
|
* and the test window (if not {@code null}) is placed to the right of
|
||||||
|
* the instruction frame.</li>
|
||||||
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public static void positionTestWindow(Window testWindow, Position position) {
|
public static void positionTestWindow(Window testWindow, Position position) {
|
||||||
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
|
|
||||||
|
// Get the screen insets to position the frame by taking into
|
||||||
|
// account the location of taskbar/menubars on screen.
|
||||||
|
GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment()
|
||||||
|
.getDefaultScreenDevice().getDefaultConfiguration();
|
||||||
|
Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(gc);
|
||||||
|
|
||||||
if (position.equals(Position.HORIZONTAL)) {
|
if (position.equals(Position.HORIZONTAL)) {
|
||||||
int newX = ((screenSize.width / 2) - frame.getWidth());
|
int newX = ((screenSize.width / 2) - frame.getWidth());
|
||||||
frame.setLocation(newX, frame.getY());
|
frame.setLocation((newX + screenInsets.left),
|
||||||
|
(frame.getY() + screenInsets.top));
|
||||||
testWindow.setLocation((frame.getLocation().x + frame.getWidth() + 5), frame.getY());
|
syncLocationToWindowManager();
|
||||||
|
if (testWindow != null) {
|
||||||
|
testWindow.setLocation((frame.getX() + frame.getWidth() + 5),
|
||||||
|
frame.getY());
|
||||||
|
}
|
||||||
} else if (position.equals(Position.VERTICAL)) {
|
} else if (position.equals(Position.VERTICAL)) {
|
||||||
int newY = ((screenSize.height / 2) - frame.getHeight());
|
int newY = ((screenSize.height / 2) - frame.getHeight());
|
||||||
frame.setLocation(frame.getX(), newY);
|
frame.setLocation((frame.getX() + screenInsets.left),
|
||||||
|
(newY + screenInsets.top));
|
||||||
testWindow.setLocation(frame.getX(),
|
syncLocationToWindowManager();
|
||||||
(frame.getLocation().y + frame.getHeight() + 5));
|
if (testWindow != null) {
|
||||||
|
testWindow.setLocation(frame.getX(),
|
||||||
|
(frame.getY() + frame.getHeight() + 5));
|
||||||
|
}
|
||||||
|
} else if (position.equals(Position.TOP_LEFT_CORNER)) {
|
||||||
|
frame.setLocation(screenInsets.left, screenInsets.top);
|
||||||
|
syncLocationToWindowManager();
|
||||||
|
if (testWindow != null) {
|
||||||
|
testWindow.setLocation((frame.getX() + frame.getWidth() + 5),
|
||||||
|
frame.getY());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// make instruction frame visible after updating
|
||||||
|
// frame & window positions
|
||||||
|
frame.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensures the frame location is updated by the window manager
|
||||||
|
* if it adjusts the frame location after {@code setLocation}.
|
||||||
|
*
|
||||||
|
* @see #positionTestWindow
|
||||||
|
*/
|
||||||
|
private static void syncLocationToWindowManager() {
|
||||||
|
Toolkit.getDefaultToolkit().sync();
|
||||||
|
try {
|
||||||
|
Thread.sleep(500);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the current position and size of the test instruction frame.
|
||||||
|
* This method can be used in scenarios when custom positioning of
|
||||||
|
* multiple test windows w.r.t test instruction frame is necessary,
|
||||||
|
* at test-case level and the desired configuration is not available
|
||||||
|
* as a {@code Position} option.
|
||||||
|
*
|
||||||
|
* @return Rectangle bounds of test instruction frame
|
||||||
|
* @see #positionTestWindow
|
||||||
|
*
|
||||||
|
* @throws InterruptedException exception thrown when thread is
|
||||||
|
* interrupted
|
||||||
|
* @throws InvocationTargetException if an exception is thrown while
|
||||||
|
* obtaining frame bounds on EDT
|
||||||
|
*/
|
||||||
|
public static Rectangle getInstructionFrameBounds()
|
||||||
|
throws InterruptedException, InvocationTargetException {
|
||||||
|
final Rectangle[] bounds = {null};
|
||||||
|
|
||||||
|
if (isEventDispatchThread()) {
|
||||||
|
bounds[0] = frame != null ? frame.getBounds() : null;
|
||||||
|
} else {
|
||||||
|
invokeAndWait(() -> {
|
||||||
|
bounds[0] = frame != null ? frame.getBounds() : null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
return bounds[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,15 +20,6 @@
|
|||||||
* or visit www.oracle.com if you need additional information or have any
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
/* @test
|
|
||||||
* @bug 4380543
|
|
||||||
* @key headful
|
|
||||||
* @library /java/awt/regtesthelpers
|
|
||||||
* @build PassFailJFrame
|
|
||||||
* @summary setMargin() does not work for AbstractButton
|
|
||||||
* @run main/manual bug4380543
|
|
||||||
*/
|
|
||||||
|
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
@ -45,6 +36,14 @@ import javax.swing.SwingUtilities;
|
|||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.UnsupportedLookAndFeelException;
|
import javax.swing.UnsupportedLookAndFeelException;
|
||||||
|
|
||||||
|
/* @test
|
||||||
|
* @bug 4380543
|
||||||
|
* @key headful
|
||||||
|
* @library /java/awt/regtesthelpers
|
||||||
|
* @build PassFailJFrame
|
||||||
|
* @summary setMargin() does not work for AbstractButton
|
||||||
|
* @run main/manual bug4380543
|
||||||
|
*/
|
||||||
public class bug4380543 {
|
public class bug4380543 {
|
||||||
static TestFrame testObj;
|
static TestFrame testObj;
|
||||||
static String instructions
|
static String instructions
|
||||||
@ -62,17 +61,16 @@ public class bug4380543 {
|
|||||||
|
|
||||||
public static void main(String[] args) throws Exception {
|
public static void main(String[] args) throws Exception {
|
||||||
|
|
||||||
SwingUtilities.invokeAndWait(new Runnable() {
|
SwingUtilities.invokeAndWait(() -> {
|
||||||
public void run() {
|
try {
|
||||||
try {
|
passFailJFrame = new PassFailJFrame(instructions);
|
||||||
passFailJFrame = new PassFailJFrame(instructions);
|
testObj = new TestFrame();
|
||||||
testObj = new TestFrame();
|
//Adding the Test Frame to handle dispose
|
||||||
//Adding the Test Frame to handle dispose
|
PassFailJFrame.addTestWindow(testObj);
|
||||||
PassFailJFrame.addTestWindow(testObj);
|
PassFailJFrame.positionTestWindow(testObj, PassFailJFrame.Position.HORIZONTAL);
|
||||||
PassFailJFrame.positionTestWindow(testObj, PassFailJFrame.Position.HORIZONTAL);
|
testObj.setVisible(true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
passFailJFrame.awaitAndCheck();
|
passFailJFrame.awaitAndCheck();
|
||||||
@ -111,9 +109,7 @@ class TestFrame extends JFrame implements ActionListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
getContentPane().add(p,BorderLayout.SOUTH);
|
getContentPane().add(p,BorderLayout.SOUTH);
|
||||||
|
|
||||||
setSize(500, 300);
|
setSize(500, 300);
|
||||||
setVisible(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setLookAndFeel(String laf) {
|
private static void setLookAndFeel(String laf) {
|
||||||
|
@ -21,6 +21,13 @@
|
|||||||
* questions.
|
* questions.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
|
||||||
|
import javax.swing.JFrame;
|
||||||
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JTabbedPane;
|
||||||
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 4209065
|
* @bug 4209065
|
||||||
@ -30,14 +37,6 @@
|
|||||||
* @run main/manual bug4209065
|
* @run main/manual bug4209065
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
|
|
||||||
import javax.swing.JFrame;
|
|
||||||
import javax.swing.JLabel;
|
|
||||||
import javax.swing.JTabbedPane;
|
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
|
|
||||||
|
|
||||||
public final class bug4209065 {
|
public final class bug4209065 {
|
||||||
|
|
||||||
private static JFrame frame;
|
private static JFrame frame;
|
||||||
@ -47,37 +46,32 @@ public final class bug4209065 {
|
|||||||
" text may be larger\nthan the tab height but this is OK" +
|
" text may be larger\nthan the tab height but this is OK" +
|
||||||
" and NOT a failure.";
|
" and NOT a failure.";
|
||||||
|
|
||||||
public static void createAndShowGUI() throws InterruptedException,
|
public static void createAndShowGUI() {
|
||||||
InvocationTargetException {
|
|
||||||
SwingUtilities.invokeAndWait(() -> {
|
|
||||||
frame = new JFrame("JTabbedPane");
|
|
||||||
|
|
||||||
JTabbedPane tp = new JTabbedPane();
|
frame = new JFrame("JTabbedPane");
|
||||||
|
JTabbedPane tp = new JTabbedPane();
|
||||||
|
|
||||||
tp.addTab("<html><center><font size=+3>big</font></center></html>",
|
tp.addTab("<html><center><font size=+3>big</font></center></html>",
|
||||||
new JLabel());
|
new JLabel());
|
||||||
tp.addTab("<html><center><font color=red>red</font></center></html>",
|
tp.addTab("<html><center><font color=red>red</font></center></html>",
|
||||||
new JLabel());
|
new JLabel());
|
||||||
tp.addTab("<html><center><em><b>Bold Italic!</b></em></center></html>",
|
tp.addTab("<html><center><em><b>Bold Italic!</b></em></center></html>",
|
||||||
new JLabel());
|
new JLabel());
|
||||||
|
|
||||||
frame.getContentPane().add(tp);
|
frame.getContentPane().add(tp);
|
||||||
frame.setSize(400, 400);
|
frame.setSize(400, 400);
|
||||||
frame.setLocationRelativeTo(null);
|
|
||||||
frame.setVisible(true);
|
|
||||||
|
|
||||||
|
PassFailJFrame.addTestWindow(frame);
|
||||||
PassFailJFrame.addTestWindow(frame);
|
PassFailJFrame.positionTestWindow(frame,
|
||||||
PassFailJFrame.positionTestWindow(frame,
|
PassFailJFrame.Position.HORIZONTAL);
|
||||||
PassFailJFrame.Position.HORIZONTAL);
|
frame.setVisible(true);
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) throws InterruptedException,
|
public static void main(String[] args) throws InterruptedException,
|
||||||
InvocationTargetException {
|
InvocationTargetException {
|
||||||
PassFailJFrame passFailJFrame = new PassFailJFrame("JTabbedPane " +
|
PassFailJFrame passFailJFrame = new PassFailJFrame("JTabbedPane " +
|
||||||
"Test Instructions", text, 5, 19, 35);
|
"Test Instructions", text, 5, 19, 35);
|
||||||
createAndShowGUI();
|
SwingUtilities.invokeAndWait(bug4209065::createAndShowGUI);
|
||||||
passFailJFrame.awaitAndCheck();
|
passFailJFrame.awaitAndCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -65,25 +65,21 @@ public class PrintAllPagesTest {
|
|||||||
|
|
||||||
SwingUtilities.invokeAndWait(() -> {
|
SwingUtilities.invokeAndWait(() -> {
|
||||||
printAllPagesTest();
|
printAllPagesTest();
|
||||||
});
|
// add the test frame to dispose
|
||||||
|
PassFailJFrame.addTestWindow(f);
|
||||||
|
|
||||||
// add the test frame to dispose
|
// Arrange the test instruction frame and test frame side by side
|
||||||
PassFailJFrame.addTestWindow(f);
|
PassFailJFrame.positionTestWindow(f, PassFailJFrame.Position.HORIZONTAL);
|
||||||
|
f.setVisible(true);
|
||||||
// Arrange the test instruction frame and test frame side by side
|
|
||||||
PassFailJFrame.positionTestWindow(f, PassFailJFrame.Position.HORIZONTAL);
|
|
||||||
|
|
||||||
SwingUtilities.invokeAndWait(() -> {
|
|
||||||
try {
|
try {
|
||||||
ret = table.print();
|
ret = table.print();
|
||||||
} catch (PrinterException ex) {
|
} catch (PrinterException ex) {
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
|
if (!ret) {
|
||||||
|
throw new RuntimeException("Printing cancelled/failed");
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!ret) {
|
|
||||||
throw new RuntimeException("Printing cancelled/failed");
|
|
||||||
}
|
|
||||||
passFailJFrame.awaitAndCheck();
|
passFailJFrame.awaitAndCheck();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -107,11 +103,11 @@ public class PrintAllPagesTest {
|
|||||||
};
|
};
|
||||||
table = new JTable(dataModel);
|
table = new JTable(dataModel);
|
||||||
JScrollPane scrollpane = new JScrollPane(table);
|
JScrollPane scrollpane = new JScrollPane(table);
|
||||||
table.scrollRectToVisible(table.getCellRect(table.getRowCount() - 1, 0, false));
|
table.scrollRectToVisible(table.getCellRect(table.getRowCount() - 1,
|
||||||
|
0, false));
|
||||||
|
|
||||||
f = new JFrame("Table test");
|
f = new JFrame("Table test");
|
||||||
f.add(scrollpane);
|
f.add(scrollpane);
|
||||||
f.setSize(1000, 800);
|
f.setSize(1000, 800);
|
||||||
f.setVisible(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,13 +63,12 @@ public class HtmlScriptTagParserTest {
|
|||||||
|
|
||||||
frame = new JFrame();
|
frame = new JFrame();
|
||||||
frame.getContentPane().add(scroll);
|
frame.getContentPane().add(scroll);
|
||||||
frame.setVisible(true);
|
|
||||||
frame.pack();
|
frame.pack();
|
||||||
frame.setLocationRelativeTo(null);
|
|
||||||
|
|
||||||
PassFailJFrame.addTestWindow(frame);
|
PassFailJFrame.addTestWindow(frame);
|
||||||
PassFailJFrame.positionTestWindow(frame,
|
PassFailJFrame.positionTestWindow(frame,
|
||||||
PassFailJFrame.Position.HORIZONTAL);
|
PassFailJFrame.Position.HORIZONTAL);
|
||||||
|
frame.setVisible(true);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,7 +80,6 @@ public class HtmlScriptTagParserTest {
|
|||||||
"\n\nHTML Used:\n" + htmlText, 5);
|
"\n\nHTML Used:\n" + htmlText, 5);
|
||||||
|
|
||||||
createAndShowGUI();
|
createAndShowGUI();
|
||||||
|
|
||||||
pfjFrame.awaitAndCheck();
|
pfjFrame.awaitAndCheck();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user