From 463edee561dd55b2909700aea95b4e309367458a Mon Sep 17 00:00:00 2001 From: mudabbir-ahmad Date: Tue, 4 Feb 2025 19:05:22 +0000 Subject: [PATCH] =?UTF-8?q?W2R3=20=E2=80=93=20Update=20the=20JRadioButton?= =?UTF-8?q?=20name?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/userprofilebuilder/view/MainViewer.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/userprofilebuilder/view/MainViewer.java b/src/main/java/userprofilebuilder/view/MainViewer.java index 3962ea1..3411ba5 100644 --- a/src/main/java/userprofilebuilder/view/MainViewer.java +++ b/src/main/java/userprofilebuilder/view/MainViewer.java @@ -67,15 +67,22 @@ public class MainViewer { panel.add(JT); - JOptionPane pane = new JOptionPane(panel, 3, 2); // content of dialogue box + //JOptionPane pane = new JOptionPane(panel, 3, 2); // content of dialogue box + JOptionPane pane = new JOptionPane(panel, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dialog = pane.createDialog("Rename Dialogue Box"); // title of dialogue box dialog.setVisible(true); // changed boiler plate code from .show() to .setVisible(true) because apparently IDE says it's better!! // actions. + int choice = (int) pane.getValue(); - - + if (choice == JOptionPane.OK_OPTION) + { + System.out.println("OK option pressed."); + JR.setText(JT.getText()); + } else if (choice == JOptionPane.CANCEL_OPTION) { + dialog.dispose(); + } }