diff --git a/src/main/java/userprofilebuilder/view/MainViewer.java b/src/main/java/userprofilebuilder/view/MainViewer.java index de1c687..68e768b 100644 --- a/src/main/java/userprofilebuilder/view/MainViewer.java +++ b/src/main/java/userprofilebuilder/view/MainViewer.java @@ -4,7 +4,6 @@ */ package userprofilebuilder.view; -import userprofilebuilder.model.User; import userprofilebuilder.model.UserGroup; import java.awt.*; @@ -13,7 +12,7 @@ import javax.swing.border.*; import javax.swing.filechooser.*; import java.awt.event.*; import java.io.*; -import java.util.ArrayList; +import java.util.*; /** * @@ -23,6 +22,7 @@ import java.util.ArrayList; public class MainViewer { public JFrame viewer; public String file = "userprofile.csv"; + public ArrayList radioButtons = new ArrayList<>(); public int a = 3; // this represents a value that is to declare how many rows are to be made -- to be changed by the amount of lines in csv. ROW COUNT @@ -88,7 +88,7 @@ public class MainViewer { jp.add(RowPanel); group.add(JR); - RadioGrouper(JR); + radioButtons.add(JR); System.out.println("Row number: "+ row + " Has been created!"); @@ -100,6 +100,7 @@ public class MainViewer { ActionListener RadioListener = e -> { System.out.println("Radio Button toggled for Row: " + row + "\n- with Radio Button Text as: " + JR.getText() + "\n- With state of radio button changed to: " + JR.isSelected() + "\n- For tab: " + Pname); + ButtonSelector(JR.isSelected(), row); }; JR.addActionListener(RadioListener); @@ -110,12 +111,6 @@ public class MainViewer { } - public void RadioGrouper(JRadioButton JR) - { - ArrayList radioButtons = new ArrayList<>(); - radioButtons.add(JR); - } - public void DialogueBox(String JRtext, JRadioButton JR, int row, String Pname){ @@ -181,6 +176,7 @@ public class MainViewer { viewer.setSize(800,500); viewer.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + radioButtons = new ArrayList<>(); JTabbedPane JT = new JTabbedPane(); JMenuBar menuBar = new JMenuBar(); @@ -229,6 +225,22 @@ public class MainViewer { viewer.setVisible(true); } - + + + public void ButtonSelector(Boolean j, int row) + { + JPanel mainPane = (JPanel) viewer.getContentPane(); + JTabbedPane jt = (JTabbedPane) mainPane.getComponent(0); + for (int i=0; i<3; i++) // 3 == the amount of tabs. + { + JPanel jp1 = (JPanel) jt.getComponentAt(i); // tab + JPanel jp2 = (JPanel) jp1.getComponent(row-1); // row + JRadioButton jr1 = (JRadioButton) jp2.getComponent(0); // always stays 0 --> selecting radio button + jr1.setSelected(j); + } + + + + } }