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:
1 parent
6b6525f771
commit
0bd73df134
1 file changed
+28
-12
@@ -16,6 +16,9 @@ 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.
|
||||
{
|
||||
|
||||
@@ -33,6 +36,26 @@ 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
|
||||
@@ -43,21 +66,14 @@ public class MainViewer {
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user