W1R5 – 'User Name' Tabbed Pane for your 'Name' Edit Panel

Edited the code so the tabbed pane will show with the correct name.

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.
This commit is contained in:
K2320390 committed 2025-02-02 19:31:36 +00:00
1 parent d386b5ceec
commit 6b6525f771
1 file changed
+18 -11
@@ -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<a; i++)
{
CreateRow(i);
CreateRow(i, page1);
}
viewer.add(JT);
viewer.setVisible(true);
}