Skip to content
Snippets Groups Projects
Commit eb464423 authored by Goetz Lindenmaier's avatar Goetz Lindenmaier
Browse files

8340799: Add border inside instruction frame in PassFailJFrame

Backport-of: 520060f79a3cedb8f93e6bbd0e9b2823eaabf79a
parent d1be3c9f
No related branches found
No related tags found
No related merge requests found
...@@ -24,6 +24,7 @@ ...@@ -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; ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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 { ...@@ -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);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment