From 6b6525f771bef7019e0b41a6df86856a0583ad82 Mon Sep 17 00:00:00 2001 From: K2320390 Date: Sun, 2 Feb 2025 19:31:36 +0000 Subject: [PATCH] =?UTF-8?q?W1R5=20=E2=80=93=20'User=20Name'=20Tabbed=20Pan?= =?UTF-8?q?e=20for=20your=20'Name'=20Edit=20Panel=20Edited=20the=20code=20?= =?UTF-8?q?so=20the=20tabbed=20pane=20will=20show=20with=20the=20correct?= =?UTF-8?q?=20name.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In the next iteration I may move the code to a separate method and modify the code in order to make the tabbed panes modular, as done with the content of the panes. --- .../userprofilebuilder/view/MainViewer.java | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/main/java/userprofilebuilder/view/MainViewer.java b/src/main/java/userprofilebuilder/view/MainViewer.java index d653bda..277882d 100644 --- a/src/main/java/userprofilebuilder/view/MainViewer.java +++ b/src/main/java/userprofilebuilder/view/MainViewer.java @@ -16,8 +16,10 @@ import javax.swing.JFrame; public class MainViewer { private JFrame viewer; - private void CreateRow(int count) // Function to create a row // holds all the data of a row in the grid layout below. + private void CreateRow(int count, JPanel jp) // Function to create a row // holds all the data of a row in the grid layout below. { + + count++; String name = "Name"; @@ -25,9 +27,9 @@ public class MainViewer { JButton JB1 = new JButton("Edit"); JButton JB2 = new JButton("Delete"); - viewer.add(JR); - viewer.add(JB1); - viewer.add(JB2); + jp.add(JR); + jp.add(JB1); + jp.add(JB2); System.out.println("Row number: "+ count + " Has been created!"); @@ -35,22 +37,27 @@ public class MainViewer { public MainViewer() // main viewer window { - int a = 3; // this represents a value that is to declare how many rows are to be made - - viewer = new JFrame(); viewer.setTitle("User Profile Builder"); viewer.setSize(500,400); viewer.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); - - viewer.setLayout(new GridLayout(a,3)); // Because i cant remember the orientation of grid layout params it's (x,y) AKA rows , columns - + JTabbedPane JT = new JTabbedPane(); + JPanel page1 = new JPanel(); + + JT.add("User Name", page1); + + + int a = 3; // this represents a value that is to declare how many rows are to be made + page1.setLayout(new GridLayout(a,3)); // Because i cant remember the orientation of grid layout params it's (x,y) AKA rows , columns + for (int i=0; i