W1R3 – Add Specified Components to the Edit Panel.

Added a for loop to initialise the creation of the rows.
In my next iteration i aim to create a max size for the buttons and a max spacing for the buttons.
created a method specifically to create and populate a row.
This commit is contained in:
K2320390 committed 2025-02-02 18:59:38 +00:00
1 parent 28b94caf67
commit 0dd754d933
1 file changed
+16 -5
@@ -18,26 +18,37 @@ public class MainViewer {
public MainViewer()
{
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 FlowLayout());
viewer.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();
}
viewer.setVisible(true);
}
private void CreateRow() // Function To create rows of radio button , button x2
{
String name = "Name";
JRadioButton JR = new JRadioButton(name);
JButton JB1 = new JButton("Edit");
JButton JB2 = new JButton("Delete");
viewer.add(JR);
viewer.add(JB1);
viewer.add(JB2);
viewer.setVisible(true);
}
}