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

-- added a function to create tabs. making it easier to make them modular.
This commit is contained in:
k2320390 committed 2025-02-03 12:06:57 +00:00
1 parent 6b6525f771
commit 0bd73df134
1 file changed
+33 -17
@@ -15,7 +15,10 @@ import javax.swing.JFrame;
*/
public class MainViewer {
private JFrame viewer;
public int a = 3; // this represents a value that is to declare how many rows are to be made
private void CreateRow(int count, JPanel jp) // Function to create a row // holds all the data of a row in the grid layout below.
{
@@ -34,30 +37,43 @@ public class MainViewer {
System.out.println("Row number: "+ count + " Has been created!");
}
public void TabMaker(String Pname, JTabbedPane JT)
{
JPanel page = new JPanel();
page.setLayout(new GridLayout(a,3)); // Because i cant remember the orientation of grid layout params it's (x,y) AKA rows , columns
JT.addTab(Pname, page);
for (int i=0; i<a; i++)
{
CreateRow(i, page);
}
}
public MainViewer() // main viewer window
{
viewer = new JFrame();
viewer.setTitle("User Profile Builder");
viewer.setSize(500,400);
viewer.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
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, page1);
}
TabMaker("User Name", JT);
TabMaker("Test1", JT);
TabMaker("Tab2", JT);
viewer.add(JT);
JT.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
viewer.setVisible(true);
}