Skip to content

Commit cd1573a

Browse files
committed
Improve Bootstrap prompt UI
1 parent c7bb09a commit cd1573a

1 file changed

Lines changed: 36 additions & 25 deletions

File tree

  • EOCV-Sim/src/bootstrap/java/com/github/serivesmejia/eocvsim

EOCV-Sim/src/bootstrap/java/com/github/serivesmejia/eocvsim/Bootstrap.java

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,13 @@ public static void main(String[] args) throws Exception {
7171

7272
// ---------------- UI ----------------
7373

74-
private static File promptUser(File detected, int currentJava) {
74+
public static final class PromptTest {
75+
public static void main(String[] args) {
76+
promptUser(new File("C:/Program Files/Java/jdk-25"), 17);
77+
}
78+
}
79+
80+
static File promptUser(File detected, int currentJava) {
7581

7682
boolean hasDetected = detected != null;
7783

@@ -112,7 +118,7 @@ private static File promptUser(File detected, int currentJava) {
112118
StringBuilder text = new StringBuilder();
113119
text.append("EOCV-Sim was started with Java ")
114120
.append(currentJava)
115-
.append(", but requires Java 25 or newer to run.\n\n");
121+
.append(", but requires Java 25 or newer to run.\n");
116122
if (!hasDetected) {
117123
text.append("No compatible Java installation was found automatically.\n\n");
118124
}
@@ -121,26 +127,20 @@ private static File promptUser(File detected, int currentJava) {
121127
info.setMaximumSize(new Dimension(420, 120));
122128

123129
// ---------------- DETECTED AREAS ----------------
124-
JTextArea detectedLabel = null;
125-
JTextArea detectedPath = null;
130+
JLabel detectedLabel = null;
131+
JLabel detectedPath = null;
126132

127133
if (hasDetected) {
128-
detectedLabel = new JTextArea("Autodetected installation:");
129-
detectedLabel.setEditable(false);
130-
detectedLabel.setOpaque(false);
131-
detectedLabel.setFocusable(false);
134+
detectedLabel = new JLabel("Autodetected installation:");
132135
detectedLabel.setFont(info.getFont().deriveFont(Font.BOLD));
133136
detectedLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
137+
detectedLabel.setHorizontalAlignment(SwingConstants.CENTER);
134138

135-
detectedPath = new JTextArea(detected.getAbsolutePath());
136-
detectedPath.setEditable(false);
137-
detectedPath.setOpaque(false);
138-
detectedPath.setFocusable(false);
139+
detectedPath = new JLabel("<html><div style='text-align:center;'>" + detected.getAbsolutePath() + "</div></html>");
139140
detectedPath.setFont(info.getFont().deriveFont(Font.BOLD));
140141
detectedPath.setForeground(new Color(0, 120, 215));
141142
detectedPath.setAlignmentX(Component.CENTER_ALIGNMENT);
142-
detectedPath.setLineWrap(true);
143-
detectedPath.setWrapStyleWord(true);
143+
detectedPath.setHorizontalAlignment(SwingConstants.CENTER);
144144
}
145145

146146
// ---------------- BUTTONS ----------------
@@ -217,17 +217,28 @@ public void windowClosed(WindowEvent e) {
217217

218218
root.add(Box.createVerticalStrut(12));
219219

220-
JPanel row1 = new JPanel(new FlowLayout(FlowLayout.CENTER, 10, 0));
221-
row1.add(selectBtn);
222-
row1.add(exitBtn);
223-
224-
JPanel row2 = new JPanel(new FlowLayout(FlowLayout.CENTER, 0, 8));
225-
row2.add(continueBtn);
226-
227-
JPanel buttonBlock = new JPanel();
228-
buttonBlock.setLayout(new BoxLayout(buttonBlock, BoxLayout.Y_AXIS));
229-
buttonBlock.add(row1);
230-
buttonBlock.add(row2);
220+
JPanel buttonBlock = new JPanel(new GridBagLayout());
221+
buttonBlock.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 8));
222+
buttonBlock.setAlignmentX(Component.CENTER_ALIGNMENT);
223+
GridBagConstraints gbc = new GridBagConstraints();
224+
gbc.insets = new Insets(0, 8, 8, 8);
225+
gbc.fill = GridBagConstraints.HORIZONTAL;
226+
gbc.weightx = 1.0;
227+
228+
// Row 0: Select and Exit
229+
gbc.gridx = 0;
230+
gbc.gridy = 0;
231+
buttonBlock.add(selectBtn, gbc);
232+
233+
gbc.gridx = 1;
234+
buttonBlock.add(exitBtn, gbc);
235+
236+
// Row 1: Continue with detected (spans both columns, centered)
237+
gbc.gridx = 0;
238+
gbc.gridy = 1;
239+
gbc.gridwidth = 2;
240+
gbc.anchor = GridBagConstraints.CENTER;
241+
buttonBlock.add(continueBtn, gbc);
231242

232243
root.add(buttonBlock);
233244

0 commit comments

Comments
 (0)