Skip to content

Commit 0ef6361

Browse files
Flossyclaude
andcommitted
fix: resolve AWT/Swing API mismatches in platform-swing-ui
- Replace AWT classes with Swing equivalents (Frame→JFrame, Panel→JPanel, etc.) - Fix missing JTable and JSeparator classes - Replace star imports with explicit imports - Remove redundant public modifier from package-private class constructor - All compilation and checkstyle violations resolved Fixes #342 Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent fdd07ee commit 0ef6361

2 files changed

Lines changed: 65 additions & 38 deletions

File tree

‎platform-swing-ui/src/main/java/org/flossware/platform/swing/DeployDialog.java‎

Lines changed: 29 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,21 @@
1717

1818
package org.flossware.platform.swing;
1919

20-
import java.awt.*;
21-
22-
import javax.swing.*;
20+
import java.awt.BorderLayout;
21+
import java.awt.Color;
22+
import java.awt.FlowLayout;
23+
import java.awt.GridBagConstraints;
24+
import java.awt.GridBagLayout;
25+
import java.awt.Insets;
26+
27+
import javax.swing.BorderFactory;
28+
import javax.swing.JButton;
29+
import javax.swing.JDialog;
30+
import javax.swing.JFrame;
31+
import javax.swing.JLabel;
32+
import javax.swing.JOptionPane;
33+
import javax.swing.JPanel;
34+
import javax.swing.JTextField;
2335

2436
/**
2537
* Dialog for collecting deployment information.
@@ -35,10 +47,10 @@
3547
*
3648
* @since 2.0
3749
*/
38-
class DeployDialog extends Dialog {
50+
class DeployDialog extends JDialog {
3951

40-
private final TextField applicationIdField;
41-
private final TextField mainClassField;
52+
private final JTextField applicationIdField;
53+
private final JTextField mainClassField;
4254
private boolean confirmed = false;
4355

4456
/**
@@ -47,15 +59,15 @@ class DeployDialog extends Dialog {
4759
* @param parent the parent frame
4860
* @param jarPath the path to the JAR file being deployed
4961
*/
50-
public DeployDialog(Frame parent, String jarPath) {
62+
DeployDialog(JFrame parent, String jarPath) {
5163
super(parent, "Deploy Application", true);
5264

5365
setLayout(new BorderLayout(10, 10));
5466
setSize(500, 250);
5567
setLocationRelativeTo(parent);
5668

5769
// Form panel
58-
Panel formPanel = new Panel(new GridBagLayout());
70+
JPanel formPanel = new JPanel(new GridBagLayout());
5971
formPanel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
6072
GridBagConstraints gbc = new GridBagConstraints();
6173
gbc.fill = GridBagConstraints.HORIZONTAL;
@@ -65,11 +77,11 @@ public DeployDialog(Frame parent, String jarPath) {
6577
gbc.gridx = 0;
6678
gbc.gridy = 0;
6779
gbc.weightx = 0.3;
68-
formPanel.add(new Label("JAR File:"), gbc);
80+
formPanel.add(new JLabel("JAR File:"), gbc);
6981

7082
gbc.gridx = 1;
7183
gbc.weightx = 0.7;
72-
TextField jarPathField = new TextField(jarPath);
84+
JTextField jarPathField = new JTextField(jarPath);
7385
jarPathField.setEditable(false);
7486
jarPathField.setBackground(Color.LIGHT_GRAY);
7587
formPanel.add(jarPathField, gbc);
@@ -78,30 +90,30 @@ public DeployDialog(Frame parent, String jarPath) {
7890
gbc.gridx = 0;
7991
gbc.gridy = 1;
8092
gbc.weightx = 0.3;
81-
formPanel.add(new Label("Application ID:"), gbc);
93+
formPanel.add(new JLabel("Application ID:"), gbc);
8294

8395
gbc.gridx = 1;
8496
gbc.weightx = 0.7;
85-
applicationIdField = new TextField();
97+
applicationIdField = new JTextField();
8698
formPanel.add(applicationIdField, gbc);
8799

88100
// Main class
89101
gbc.gridx = 0;
90102
gbc.gridy = 2;
91103
gbc.weightx = 0.3;
92-
formPanel.add(new Label("Main Class:"), gbc);
104+
formPanel.add(new JLabel("Main Class:"), gbc);
93105

94106
gbc.gridx = 1;
95107
gbc.weightx = 0.7;
96-
mainClassField = new TextField();
108+
mainClassField = new JTextField();
97109
formPanel.add(mainClassField, gbc);
98110

99111
add(formPanel, BorderLayout.CENTER);
100112

101113
// Button panel
102-
Panel buttonPanel = new Panel(new FlowLayout(FlowLayout.RIGHT));
103-
Button okButton = new Button("Deploy");
104-
Button cancelButton = new Button("Cancel");
114+
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
115+
JButton okButton = new JButton("Deploy");
116+
JButton cancelButton = new JButton("Cancel");
105117

106118
okButton.addActionListener(
107119
e -> {

‎platform-swing-ui/src/main/java/org/flossware/platform/swing/SwingConsole.java‎

Lines changed: 36 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717

1818
package org.flossware.platform.swing;
1919

20-
import java.awt.*;
20+
import java.awt.BorderLayout;
21+
import java.awt.Color;
22+
import java.awt.FlowLayout;
23+
import java.awt.Font;
2124
import java.awt.event.WindowAdapter;
2225
import java.awt.event.WindowEvent;
2326
import java.nio.file.Paths;
@@ -26,7 +29,19 @@
2629
import java.util.concurrent.ScheduledExecutorService;
2730
import java.util.concurrent.TimeUnit;
2831

29-
import javax.swing.*;
32+
import javax.swing.BorderFactory;
33+
import javax.swing.JButton;
34+
import javax.swing.JFileChooser;
35+
import javax.swing.JFrame;
36+
import javax.swing.JLabel;
37+
import javax.swing.JOptionPane;
38+
import javax.swing.JPanel;
39+
import javax.swing.JScrollPane;
40+
import javax.swing.JSeparator;
41+
import javax.swing.JTable;
42+
import javax.swing.ListSelectionModel;
43+
import javax.swing.SwingConstants;
44+
import javax.swing.SwingUtilities;
3045
import javax.swing.table.DefaultTableModel;
3146

3247
import org.flossware.platform.api.ApplicationState;
@@ -70,10 +85,10 @@ public class SwingConsole {
7085
private static final Logger LOGGER = LoggerFactory.getLogger(SwingConsole.class);
7186

7287
private final PlatformManager platformManager;
73-
private final Frame frame;
74-
private final Table applicationTable;
88+
private final JFrame frame;
89+
private final JTable applicationTable;
7590
private final DefaultTableModel tableModel;
76-
private final Label statusLabel;
91+
private final JLabel statusLabel;
7792
private final ScheduledExecutorService refreshExecutor;
7893

7994
/**
@@ -87,7 +102,7 @@ public SwingConsole(PlatformManager platformManager) {
87102
}
88103

89104
this.platformManager = platformManager;
90-
this.frame = new Frame("JPlatform Management Console");
105+
this.frame = new JFrame("JPlatform Management Console");
91106
this.tableModel =
92107
new DefaultTableModel(
93108
new String[] {"Application ID", "State", "CPU Time (ms)", "Heap (MB)", "Threads"}, 0) {
@@ -96,8 +111,8 @@ public boolean isCellEditable(int row, int column) {
96111
return false; // Read-only table
97112
}
98113
};
99-
this.applicationTable = new Table(tableModel);
100-
this.statusLabel = new Label("Ready");
114+
this.applicationTable = new JTable(tableModel);
115+
this.statusLabel = new JLabel("Ready");
101116
this.refreshExecutor =
102117
Executors.newSingleThreadScheduledExecutor(
103118
r -> {
@@ -126,29 +141,29 @@ public void windowClosed(WindowEvent e) {
126141
frame.setLayout(new BorderLayout());
127142

128143
// Title panel
129-
Panel titlePanel = new Panel();
144+
JPanel titlePanel = new JPanel();
130145
titlePanel.setBackground(new Color(41, 128, 185));
131-
Label titleLabel = new Label("JPlatform Management Console");
146+
JLabel titleLabel = new JLabel("JPlatform Management Console");
132147
titleLabel.setFont(new Font("Arial", Font.BOLD, 20));
133148
titleLabel.setForeground(Color.WHITE);
134149
titlePanel.add(titleLabel);
135150
frame.add(titlePanel, BorderLayout.NORTH);
136151

137152
// Center panel with table
138-
ScrollPane scrollPane = new ScrollPane(applicationTable);
153+
JScrollPane scrollPane = new JScrollPane(applicationTable);
139154
applicationTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
140155
applicationTable.setRowHeight(25);
141156
applicationTable.getTableHeader().setFont(new Font("Arial", Font.BOLD, 12));
142157
frame.add(scrollPane, BorderLayout.CENTER);
143158

144159
// Button panel
145-
Panel buttonPanel = new Panel(new FlowLayout(FlowLayout.LEFT));
160+
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
146161

147-
Button deployButton = new Button("Deploy");
148-
Button startButton = new Button("Start");
149-
Button stopButton = new Button("Stop");
150-
Button undeployButton = new Button("Undeploy");
151-
Button refreshButton = new Button("Refresh");
162+
JButton deployButton = new JButton("Deploy");
163+
JButton startButton = new JButton("Start");
164+
JButton stopButton = new JButton("Stop");
165+
JButton undeployButton = new JButton("Undeploy");
166+
JButton refreshButton = new JButton("Refresh");
152167

153168
deployButton.addActionListener(e -> deployApplication());
154169
startButton.addActionListener(e -> startSelectedApplication());
@@ -160,13 +175,13 @@ public void windowClosed(WindowEvent e) {
160175
buttonPanel.add(startButton);
161176
buttonPanel.add(stopButton);
162177
buttonPanel.add(undeployButton);
163-
buttonPanel.add(new Separator(SwingConstants.VERTICAL));
178+
buttonPanel.add(new JSeparator(SwingConstants.VERTICAL));
164179
buttonPanel.add(refreshButton);
165180

166181
frame.add(buttonPanel, BorderLayout.SOUTH);
167182

168183
// Status bar
169-
Panel statusPanel = new Panel(new BorderLayout());
184+
JPanel statusPanel = new JPanel(new BorderLayout());
170185
statusPanel.setBorder(BorderFactory.createEtchedBorder());
171186
statusLabel.setBorder(BorderFactory.createEmptyBorder(2, 5, 2, 5));
172187
statusPanel.add(statusLabel, BorderLayout.WEST);
@@ -415,7 +430,7 @@ public void shutdown() {
415430
*
416431
* @return the main frame
417432
*/
418-
Frame getFrame() {
433+
JFrame getFrame() {
419434
return frame;
420435
}
421436

@@ -433,7 +448,7 @@ DefaultTableModel getTableModel() {
433448
*
434449
* @return the status label
435450
*/
436-
Label getStatusLabel() {
451+
JLabel getStatusLabel() {
437452
return statusLabel;
438453
}
439454
}

0 commit comments

Comments
 (0)