mirror of
https://github.com/openjdk/jdk23u.git
synced 2025-12-12 00:08:58 -06:00
8340799: Add border inside instruction frame in PassFailJFrame
Backport-of: 520060f79a3cedb8f93e6bbd0e9b2823eaabf79a
This commit is contained in:
parent
167d346708
commit
126d9c0c28
@ -24,6 +24,7 @@
|
|||||||
import java.awt.AWTException;
|
import java.awt.AWTException;
|
||||||
import java.awt.BorderLayout;
|
import java.awt.BorderLayout;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.FlowLayout;
|
||||||
import java.awt.Font;
|
import java.awt.Font;
|
||||||
import java.awt.GraphicsConfiguration;
|
import java.awt.GraphicsConfiguration;
|
||||||
import java.awt.GraphicsDevice;
|
import java.awt.GraphicsDevice;
|
||||||
@ -69,6 +70,7 @@ import javax.swing.JScrollPane;
|
|||||||
import javax.swing.JSplitPane;
|
import javax.swing.JSplitPane;
|
||||||
import javax.swing.JTextArea;
|
import javax.swing.JTextArea;
|
||||||
import javax.swing.Timer;
|
import javax.swing.Timer;
|
||||||
|
import javax.swing.border.Border;
|
||||||
import javax.swing.text.JTextComponent;
|
import javax.swing.text.JTextComponent;
|
||||||
import javax.swing.text.html.HTMLEditorKit;
|
import javax.swing.text.html.HTMLEditorKit;
|
||||||
import javax.swing.text.html.StyleSheet;
|
import javax.swing.text.html.StyleSheet;
|
||||||
@ -655,6 +657,8 @@ public final class PassFailJFrame {
|
|||||||
boolean addLogArea,
|
boolean addLogArea,
|
||||||
int logAreaRows) {
|
int logAreaRows) {
|
||||||
JPanel main = new JPanel(new BorderLayout());
|
JPanel main = new JPanel(new BorderLayout());
|
||||||
|
main.setBorder(createFrameBorder());
|
||||||
|
|
||||||
timeoutHandlerPanel = new TimeoutHandlerPanel(testTimeOut);
|
timeoutHandlerPanel = new TimeoutHandlerPanel(testTimeOut);
|
||||||
main.add(timeoutHandlerPanel, BorderLayout.NORTH);
|
main.add(timeoutHandlerPanel, BorderLayout.NORTH);
|
||||||
|
|
||||||
@ -664,7 +668,7 @@ public final class PassFailJFrame {
|
|||||||
text.setEditable(false);
|
text.setEditable(false);
|
||||||
|
|
||||||
JPanel textPanel = new JPanel(new BorderLayout());
|
JPanel textPanel = new JPanel(new BorderLayout());
|
||||||
textPanel.setBorder(createEmptyBorder(4, 0, 0, 0));
|
textPanel.setBorder(createEmptyBorder(GAP, 0, GAP, 0));
|
||||||
textPanel.add(new JScrollPane(text), BorderLayout.CENTER);
|
textPanel.add(new JScrollPane(text), BorderLayout.CENTER);
|
||||||
|
|
||||||
main.add(textPanel, BorderLayout.CENTER);
|
main.add(textPanel, BorderLayout.CENTER);
|
||||||
@ -681,7 +685,8 @@ public final class PassFailJFrame {
|
|||||||
timeoutHandlerPanel.stop();
|
timeoutHandlerPanel.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
JPanel buttonsPanel = new JPanel();
|
JPanel buttonsPanel = new JPanel(new FlowLayout(FlowLayout.CENTER,
|
||||||
|
GAP, 0));
|
||||||
buttonsPanel.add(btnPass);
|
buttonsPanel.add(btnPass);
|
||||||
buttonsPanel.add(btnFail);
|
buttonsPanel.add(btnFail);
|
||||||
|
|
||||||
@ -692,10 +697,12 @@ public final class PassFailJFrame {
|
|||||||
if (addLogArea) {
|
if (addLogArea) {
|
||||||
logArea = new JTextArea(logAreaRows, columns);
|
logArea = new JTextArea(logAreaRows, columns);
|
||||||
logArea.setEditable(false);
|
logArea.setEditable(false);
|
||||||
|
logArea.setBorder(createTextBorder());
|
||||||
|
|
||||||
Box buttonsLogPanel = Box.createVerticalBox();
|
Box buttonsLogPanel = Box.createVerticalBox();
|
||||||
|
|
||||||
buttonsLogPanel.add(buttonsPanel);
|
buttonsLogPanel.add(buttonsPanel);
|
||||||
|
buttonsLogPanel.add(Box.createVerticalStrut(GAP));
|
||||||
buttonsLogPanel.add(new JScrollPane(logArea));
|
buttonsLogPanel.add(new JScrollPane(logArea));
|
||||||
|
|
||||||
main.add(buttonsLogPanel, BorderLayout.SOUTH);
|
main.add(buttonsLogPanel, BorderLayout.SOUTH);
|
||||||
@ -713,7 +720,7 @@ public final class PassFailJFrame {
|
|||||||
JTextArea text = new JTextArea(instructions, rows, columns);
|
JTextArea text = new JTextArea(instructions, rows, columns);
|
||||||
text.setLineWrap(true);
|
text.setLineWrap(true);
|
||||||
text.setWrapStyleWord(true);
|
text.setWrapStyleWord(true);
|
||||||
text.setBorder(createEmptyBorder(4, 4, 4, 4));
|
text.setBorder(createTextBorder());
|
||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -735,6 +742,29 @@ public final class PassFailJFrame {
|
|||||||
return text;
|
return text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** A default gap between components. */
|
||||||
|
private static final int GAP = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a default border for frames or dialogs.
|
||||||
|
* It uses the default gap of {@value GAP}.
|
||||||
|
*
|
||||||
|
* @return the border for frames and dialogs
|
||||||
|
*/
|
||||||
|
private static Border createFrameBorder() {
|
||||||
|
return createEmptyBorder(GAP, GAP, GAP, GAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a border set to text area.
|
||||||
|
* It uses the default gap of {@value GAP}.
|
||||||
|
*
|
||||||
|
* @return the border for text area
|
||||||
|
*/
|
||||||
|
private static Border createTextBorder() {
|
||||||
|
return createEmptyBorder(GAP, GAP, GAP, GAP);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a test UI window.
|
* Creates a test UI window.
|
||||||
@ -1086,26 +1116,30 @@ public final class PassFailJFrame {
|
|||||||
* Requests the description of the test failure reason from the tester.
|
* Requests the description of the test failure reason from the tester.
|
||||||
*/
|
*/
|
||||||
private static void requestFailureReason() {
|
private static void requestFailureReason() {
|
||||||
final JDialog dialog = new JDialog(frame, "Test Failure ", true);
|
final JDialog dialog = new JDialog(frame, "Failure reason", true);
|
||||||
dialog.setTitle("Failure reason");
|
|
||||||
JPanel jPanel = new JPanel(new BorderLayout());
|
JTextArea reason = new JTextArea(5, 20);
|
||||||
JTextArea jTextArea = new JTextArea(5, 20);
|
reason.setBorder(createTextBorder());
|
||||||
|
|
||||||
JButton okButton = new JButton("OK");
|
JButton okButton = new JButton("OK");
|
||||||
okButton.addActionListener((ae) -> {
|
okButton.addActionListener((ae) -> {
|
||||||
String text = jTextArea.getText();
|
String text = reason.getText();
|
||||||
setFailureReason(FAILURE_REASON
|
setFailureReason(FAILURE_REASON
|
||||||
+ (!text.isEmpty() ? text : EMPTY_REASON));
|
+ (!text.isEmpty() ? text : EMPTY_REASON));
|
||||||
dialog.setVisible(false);
|
dialog.setVisible(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
jPanel.add(new JScrollPane(jTextArea), BorderLayout.CENTER);
|
JPanel okayBtnPanel = new JPanel(new FlowLayout(FlowLayout.CENTER,
|
||||||
|
GAP, 0));
|
||||||
JPanel okayBtnPanel = new JPanel();
|
okayBtnPanel.setBorder(createEmptyBorder(GAP, 0, 0, 0));
|
||||||
okayBtnPanel.add(okButton);
|
okayBtnPanel.add(okButton);
|
||||||
|
|
||||||
jPanel.add(okayBtnPanel, BorderLayout.SOUTH);
|
JPanel main = new JPanel(new BorderLayout());
|
||||||
dialog.add(jPanel);
|
main.setBorder(createFrameBorder());
|
||||||
|
main.add(new JScrollPane(reason), BorderLayout.CENTER);
|
||||||
|
main.add(okayBtnPanel, BorderLayout.SOUTH);
|
||||||
|
|
||||||
|
dialog.add(main);
|
||||||
dialog.setLocationRelativeTo(frame);
|
dialog.setLocationRelativeTo(frame);
|
||||||
dialog.pack();
|
dialog.pack();
|
||||||
dialog.setVisible(true);
|
dialog.setVisible(true);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user