From bb55882d6738d270b0f581f219b7b73ae9050eb4 Mon Sep 17 00:00:00 2001 From: Hesam Ghorayshi Date: Sun, 18 May 2025 20:35:04 +0330 Subject: [PATCH 1/2] done --- part-1/E1.java | 0 part-2/E2.java | 0 part-3/E3.java | 0 part-4/E4.java | 0 4 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 part-1/E1.java delete mode 100644 part-2/E2.java delete mode 100644 part-3/E3.java delete mode 100644 part-4/E4.java diff --git a/part-1/E1.java b/part-1/E1.java deleted file mode 100644 index e69de29..0000000 diff --git a/part-2/E2.java b/part-2/E2.java deleted file mode 100644 index e69de29..0000000 diff --git a/part-3/E3.java b/part-3/E3.java deleted file mode 100644 index e69de29..0000000 diff --git a/part-4/E4.java b/part-4/E4.java deleted file mode 100644 index e69de29..0000000 From 4eb90459772d126b8f8957482988dd18a50abb90 Mon Sep 17 00:00:00 2001 From: Hesam Ghorayshi Date: Sun, 18 May 2025 20:40:54 +0330 Subject: [PATCH 2/2] done --- .idea/.gitignore | 8 ++ .idea/.name | 1 + .idea/JavaSwingSimpleExercise.iml | 9 ++ .idea/modules.xml | 8 ++ .idea/vcs.xml | 6 + part-1/ClickCounterApp.java/.gitignore | 29 +++++ part-1/ClickCounterApp.java/.idea/.gitignore | 8 ++ part-1/ClickCounterApp.java/.idea/misc.xml | 6 + part-1/ClickCounterApp.java/.idea/modules.xml | 8 ++ .../ClickCounterApp.java.iml | 11 ++ .../src/ClickCounterApp.java | 49 ++++++++ part-2/GreetingFormApp.java/.gitignore | 29 +++++ part-2/GreetingFormApp.java/.idea/.gitignore | 8 ++ part-2/GreetingFormApp.java/.idea/misc.xml | 6 + part-2/GreetingFormApp.java/.idea/modules.xml | 8 ++ .../GreetingFormApp.java.iml | 11 ++ .../src/GreetingFormApp.java | 60 ++++++++++ part-3/ThemeColorSelectorApp/.gitignore | 29 +++++ part-3/ThemeColorSelectorApp/.idea/.gitignore | 8 ++ part-3/ThemeColorSelectorApp/.idea/misc.xml | 6 + .../ThemeColorSelectorApp/.idea/modules.xml | 8 ++ .../ThemeColorSelectorApp.iml | 11 ++ .../src/ThemeColorSelectorApp.java | 59 +++++++++ part-4/RegistrationFormApp/.gitignore | 29 +++++ part-4/RegistrationFormApp/.idea/.gitignore | 8 ++ part-4/RegistrationFormApp/.idea/misc.xml | 6 + part-4/RegistrationFormApp/.idea/modules.xml | 8 ++ .../RegistrationFormApp.iml | 11 ++ .../src/RegistrationFormApp.java | 112 ++++++++++++++++++ 29 files changed, 560 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 .idea/.name create mode 100644 .idea/JavaSwingSimpleExercise.iml create mode 100644 .idea/modules.xml create mode 100644 .idea/vcs.xml create mode 100644 part-1/ClickCounterApp.java/.gitignore create mode 100644 part-1/ClickCounterApp.java/.idea/.gitignore create mode 100644 part-1/ClickCounterApp.java/.idea/misc.xml create mode 100644 part-1/ClickCounterApp.java/.idea/modules.xml create mode 100644 part-1/ClickCounterApp.java/ClickCounterApp.java.iml create mode 100644 part-1/ClickCounterApp.java/src/ClickCounterApp.java create mode 100644 part-2/GreetingFormApp.java/.gitignore create mode 100644 part-2/GreetingFormApp.java/.idea/.gitignore create mode 100644 part-2/GreetingFormApp.java/.idea/misc.xml create mode 100644 part-2/GreetingFormApp.java/.idea/modules.xml create mode 100644 part-2/GreetingFormApp.java/GreetingFormApp.java.iml create mode 100644 part-2/GreetingFormApp.java/src/GreetingFormApp.java create mode 100644 part-3/ThemeColorSelectorApp/.gitignore create mode 100644 part-3/ThemeColorSelectorApp/.idea/.gitignore create mode 100644 part-3/ThemeColorSelectorApp/.idea/misc.xml create mode 100644 part-3/ThemeColorSelectorApp/.idea/modules.xml create mode 100644 part-3/ThemeColorSelectorApp/ThemeColorSelectorApp.iml create mode 100644 part-3/ThemeColorSelectorApp/src/ThemeColorSelectorApp.java create mode 100644 part-4/RegistrationFormApp/.gitignore create mode 100644 part-4/RegistrationFormApp/.idea/.gitignore create mode 100644 part-4/RegistrationFormApp/.idea/misc.xml create mode 100644 part-4/RegistrationFormApp/.idea/modules.xml create mode 100644 part-4/RegistrationFormApp/RegistrationFormApp.iml create mode 100644 part-4/RegistrationFormApp/src/RegistrationFormApp.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 0000000..bd73dd9 --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +E2.java \ No newline at end of file diff --git a/.idea/JavaSwingSimpleExercise.iml b/.idea/JavaSwingSimpleExercise.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/.idea/JavaSwingSimpleExercise.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..2d16929 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..35eb1dd --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/part-1/ClickCounterApp.java/.gitignore b/part-1/ClickCounterApp.java/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/part-1/ClickCounterApp.java/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/part-1/ClickCounterApp.java/.idea/.gitignore b/part-1/ClickCounterApp.java/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/part-1/ClickCounterApp.java/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/part-1/ClickCounterApp.java/.idea/misc.xml b/part-1/ClickCounterApp.java/.idea/misc.xml new file mode 100644 index 0000000..f03c948 --- /dev/null +++ b/part-1/ClickCounterApp.java/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/part-1/ClickCounterApp.java/.idea/modules.xml b/part-1/ClickCounterApp.java/.idea/modules.xml new file mode 100644 index 0000000..a153132 --- /dev/null +++ b/part-1/ClickCounterApp.java/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/part-1/ClickCounterApp.java/ClickCounterApp.java.iml b/part-1/ClickCounterApp.java/ClickCounterApp.java.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/part-1/ClickCounterApp.java/ClickCounterApp.java.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/part-1/ClickCounterApp.java/src/ClickCounterApp.java b/part-1/ClickCounterApp.java/src/ClickCounterApp.java new file mode 100644 index 0000000..08d836c --- /dev/null +++ b/part-1/ClickCounterApp.java/src/ClickCounterApp.java @@ -0,0 +1,49 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +public class ClickCounterApp extends JFrame implements ActionListener { + + private JLabel counterLabel; + private JButton clickButton; + private JButton resetButton; + private int count = 0; + + public ClickCounterApp() { + setTitle("Click Counter"); + setSize(300, 200); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setLocationRelativeTo(null); + + counterLabel = new JLabel("Clicks: 0", SwingConstants.CENTER); + counterLabel.setFont(new Font("Arial", Font.BOLD, 24)); + + clickButton = new JButton("Click Me"); + clickButton.addActionListener(this); + + resetButton = new JButton("Reset"); + resetButton.addActionListener(e -> { + count = 0; + counterLabel.setText("Clicks: 0"); + }); + + JPanel buttonPanel = new JPanel(); + buttonPanel.setLayout(new FlowLayout()); + buttonPanel.add(clickButton); + buttonPanel.add(resetButton); + + setLayout(new BorderLayout()); + add(counterLabel, BorderLayout.CENTER); + add(buttonPanel, BorderLayout.SOUTH); + } + + @Override + public void actionPerformed(ActionEvent e) { + count++; + counterLabel.setText("Clicks: " + count); + } + + public static void main(String[] args) { + SwingUtilities.invokeLater(() -> new ClickCounterApp().setVisible(true)); + } +} diff --git a/part-2/GreetingFormApp.java/.gitignore b/part-2/GreetingFormApp.java/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/part-2/GreetingFormApp.java/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/part-2/GreetingFormApp.java/.idea/.gitignore b/part-2/GreetingFormApp.java/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/part-2/GreetingFormApp.java/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/part-2/GreetingFormApp.java/.idea/misc.xml b/part-2/GreetingFormApp.java/.idea/misc.xml new file mode 100644 index 0000000..f03c948 --- /dev/null +++ b/part-2/GreetingFormApp.java/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/part-2/GreetingFormApp.java/.idea/modules.xml b/part-2/GreetingFormApp.java/.idea/modules.xml new file mode 100644 index 0000000..01cba22 --- /dev/null +++ b/part-2/GreetingFormApp.java/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/part-2/GreetingFormApp.java/GreetingFormApp.java.iml b/part-2/GreetingFormApp.java/GreetingFormApp.java.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/part-2/GreetingFormApp.java/GreetingFormApp.java.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/part-2/GreetingFormApp.java/src/GreetingFormApp.java b/part-2/GreetingFormApp.java/src/GreetingFormApp.java new file mode 100644 index 0000000..1cd019c --- /dev/null +++ b/part-2/GreetingFormApp.java/src/GreetingFormApp.java @@ -0,0 +1,60 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +public class GreetingFormApp extends JFrame implements ActionListener { + private JTextField nameField; + private JButton greetButton; + private JButton resetButton; + private JLabel messageLabel; + + public GreetingFormApp() { + setTitle("Greeting Form"); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + setSize(400, 200); + setLocationRelativeTo(null); + + nameField = new JTextField(15); + greetButton = new JButton("Greet"); + resetButton = new JButton("Reset"); + messageLabel = new JLabel("Enter your name and press Greet.", SwingConstants.CENTER); + + greetButton.addActionListener(this); + resetButton.addActionListener(this); + + + JPanel inputPanel = new JPanel(); + inputPanel.add(new JLabel("Name:")); + inputPanel.add(nameField); + inputPanel.add(greetButton); + inputPanel.add(resetButton); + + setLayout(new BorderLayout()); + add(inputPanel, BorderLayout.NORTH); + add(messageLabel, BorderLayout.CENTER); + } + + @Override + public void actionPerformed(ActionEvent e) { + Object source = e.getSource(); + + if (source == greetButton) { + String name = nameField.getText().trim(); + if (name.isEmpty()) { + messageLabel.setText("Please enter a name."); + } else { + messageLabel.setText("Hello, " + name + "!"); + } + } else if (source == resetButton) { + nameField.setText(""); + messageLabel.setText("Enter your name and press Greet."); + } + } + + public static void main(String[] args) { + SwingUtilities.invokeLater(() -> { + GreetingFormApp app = new GreetingFormApp(); + app.setVisible(true); + }); + } +} diff --git a/part-3/ThemeColorSelectorApp/.gitignore b/part-3/ThemeColorSelectorApp/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/part-3/ThemeColorSelectorApp/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/part-3/ThemeColorSelectorApp/.idea/.gitignore b/part-3/ThemeColorSelectorApp/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/part-3/ThemeColorSelectorApp/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/part-3/ThemeColorSelectorApp/.idea/misc.xml b/part-3/ThemeColorSelectorApp/.idea/misc.xml new file mode 100644 index 0000000..f03c948 --- /dev/null +++ b/part-3/ThemeColorSelectorApp/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/part-3/ThemeColorSelectorApp/.idea/modules.xml b/part-3/ThemeColorSelectorApp/.idea/modules.xml new file mode 100644 index 0000000..cc44f1b --- /dev/null +++ b/part-3/ThemeColorSelectorApp/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/part-3/ThemeColorSelectorApp/ThemeColorSelectorApp.iml b/part-3/ThemeColorSelectorApp/ThemeColorSelectorApp.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/part-3/ThemeColorSelectorApp/ThemeColorSelectorApp.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/part-3/ThemeColorSelectorApp/src/ThemeColorSelectorApp.java b/part-3/ThemeColorSelectorApp/src/ThemeColorSelectorApp.java new file mode 100644 index 0000000..ccddce3 --- /dev/null +++ b/part-3/ThemeColorSelectorApp/src/ThemeColorSelectorApp.java @@ -0,0 +1,59 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +public class ThemeColorSelectorApp extends JFrame implements ActionListener { + private JPanel mainPanel; + private JButton redButton; + private JButton greenButton; + private JButton blueButton; + + public ThemeColorSelectorApp() { + setTitle("Theme Color Selector"); + + mainPanel = new JPanel(); + + redButton = new JButton("Red"); + greenButton = new JButton("Green"); + blueButton = new JButton("Blue"); + + redButton.setActionCommand("RED"); + greenButton.setActionCommand("GREEN"); + blueButton.setActionCommand("BLUE"); + + redButton.addActionListener(this); + greenButton.addActionListener(this); + blueButton.addActionListener(this); + + JPanel buttonPanel = new JPanel(); + buttonPanel.add(redButton); + buttonPanel.add(greenButton); + buttonPanel.add(blueButton); + + setLayout(new BorderLayout()); + add(buttonPanel, BorderLayout.NORTH); + add(mainPanel, BorderLayout.CENTER); + + setSize(400, 300); + setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + } + + @Override + public void actionPerformed(ActionEvent e) { + switch (e.getActionCommand()) { + case "RED": + mainPanel.setBackground(Color.RED); + break; + case "GREEN": + mainPanel.setBackground(Color.GREEN); + break; + case "BLUE": + mainPanel.setBackground(Color.BLUE); + break; + } + } + + public static void main(String[] args) { + SwingUtilities.invokeLater(() -> new ThemeColorSelectorApp().setVisible(true)); + } +} diff --git a/part-4/RegistrationFormApp/.gitignore b/part-4/RegistrationFormApp/.gitignore new file mode 100644 index 0000000..f68d109 --- /dev/null +++ b/part-4/RegistrationFormApp/.gitignore @@ -0,0 +1,29 @@ +### IntelliJ IDEA ### +out/ +!**/src/main/**/out/ +!**/src/test/**/out/ + +### Eclipse ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache +bin/ +!**/src/main/**/bin/ +!**/src/test/**/bin/ + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ + +### VS Code ### +.vscode/ + +### Mac OS ### +.DS_Store \ No newline at end of file diff --git a/part-4/RegistrationFormApp/.idea/.gitignore b/part-4/RegistrationFormApp/.idea/.gitignore new file mode 100644 index 0000000..13566b8 --- /dev/null +++ b/part-4/RegistrationFormApp/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/part-4/RegistrationFormApp/.idea/misc.xml b/part-4/RegistrationFormApp/.idea/misc.xml new file mode 100644 index 0000000..f03c948 --- /dev/null +++ b/part-4/RegistrationFormApp/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/part-4/RegistrationFormApp/.idea/modules.xml b/part-4/RegistrationFormApp/.idea/modules.xml new file mode 100644 index 0000000..da414db --- /dev/null +++ b/part-4/RegistrationFormApp/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/part-4/RegistrationFormApp/RegistrationFormApp.iml b/part-4/RegistrationFormApp/RegistrationFormApp.iml new file mode 100644 index 0000000..c90834f --- /dev/null +++ b/part-4/RegistrationFormApp/RegistrationFormApp.iml @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/part-4/RegistrationFormApp/src/RegistrationFormApp.java b/part-4/RegistrationFormApp/src/RegistrationFormApp.java new file mode 100644 index 0000000..170608e --- /dev/null +++ b/part-4/RegistrationFormApp/src/RegistrationFormApp.java @@ -0,0 +1,112 @@ +import javax.swing.*; +import java.awt.*; +import java.awt.event.*; + +public class RegistrationFormApp extends JFrame implements ActionListener { + private final JTextField txtName; + private final JTextField txtEmail; + private final JPasswordField txtPassword; + private final JRadioButton rbMale, rbFemale; + private final JCheckBox cbJava, cbPython, cbCpp; + private final JButton btnSubmit; + private final GridBagConstraints gbc; + + public RegistrationFormApp() { + setTitle("User Registration"); + setSize(500, 350); + setDefaultCloseOperation(EXIT_ON_CLOSE); + setLocationRelativeTo(null); // Center the window + + JPanel panel = new JPanel(new GridBagLayout()); + gbc = new GridBagConstraints(); + gbc.insets = new Insets(5, 5, 5, 5); // Margin between components + gbc.fill = GridBagConstraints.HORIZONTAL; + + // Row 0: Name + gbc.gridx = 0; + gbc.gridy = 0; + panel.add(new JLabel("Name:"), gbc); + gbc.gridx = 1; + txtName = new JTextField(20); + panel.add(txtName, gbc); + + // Row 1: Email + gbc.gridx = 0; + gbc.gridy = 1; + panel.add(new JLabel("Email:"), gbc); + gbc.gridx = 1; + txtEmail = new JTextField(20); + panel.add(txtEmail, gbc); + + // Row 2: Password + gbc.gridx = 0; + gbc.gridy = 2; + panel.add(new JLabel("Password:"), gbc); + gbc.gridx = 1; + txtPassword = new JPasswordField(20); + panel.add(txtPassword, gbc); + + // Row 3: Gender + gbc.gridx = 0; + gbc.gridy = 3; + panel.add(new JLabel("Gender:"), gbc); + gbc.gridx = 1; + rbMale = new JRadioButton("Male"); + rbFemale = new JRadioButton("Female"); + ButtonGroup bg = new ButtonGroup(); + bg.add(rbMale); + bg.add(rbFemale); + JPanel genderPanel = new JPanel(); + genderPanel.add(rbMale); + genderPanel.add(rbFemale); + panel.add(genderPanel, gbc); + + // Row 4: Interests + gbc.gridx = 0; + gbc.gridy = 4; + panel.add(new JLabel("Interests:"), gbc); + gbc.gridx = 1; + cbJava = new JCheckBox("Java"); + cbPython = new JCheckBox("Python"); + cbCpp = new JCheckBox("C++"); + JPanel interestPanel = new JPanel(); + interestPanel.add(cbJava); + interestPanel.add(cbPython); + interestPanel.add(cbCpp); + panel.add(interestPanel, gbc); + + // Row 5: Submit button + gbc.gridx = 1; + gbc.gridy = 5; + gbc.anchor = GridBagConstraints.CENTER; + btnSubmit = new JButton("Submit"); + btnSubmit.addActionListener(this); + panel.add(btnSubmit, gbc); + + add(panel); + } + + @Override + public void actionPerformed(ActionEvent e) { + String name = txtName.getText(); + String email = txtEmail.getText(); + String gender = rbMale.isSelected() ? "Male" : + rbFemale.isSelected() ? "Female" : "Unspecified"; + String interests = ""; + if (cbJava.isSelected()) interests += "Java "; + if (cbPython.isSelected()) interests += "Python "; + if (cbCpp.isSelected()) interests += "C++ "; + + JOptionPane.showMessageDialog(this, + "Name: " + name + "\n" + + "Email: " + email + "\n" + + "Gender: " + gender + "\n" + + "Interests: " + interests, + "Registration Details", + JOptionPane.INFORMATION_MESSAGE); + } + + public static void main(String[] args) { + SwingUtilities.invokeLater(() -> new RegistrationFormApp().setVisible(true)); + } +}