The reason the JRadioButtons don't show up is because you are adding them to this
(the JFrame) which puts them in the center of its BorderLayout, then they get replaced by the mainPanel
, since BorderLayout only allows one component in each of its regions.
You're right: they need to be in a panel of their own. Add a new field, orderTypesPanel
, then alter GroupButton()
to this:
private void GroupButton() {
orderTypesPanel = new JPanel(new GridLayout(3, 1));
orderTypesPanel.setOpaque(false);
// declare 3 JRadioButton variables
JRadioButton rInstall = new JRadioButton("Installation");
JRadioButton rProject = new JRadioButton("Project");
JRadioButton rMaintain = new JRadioButton("Maintenance");
rInstall.setForeground(Color.white);
rInstall.setOpaque(false);
rProject.setForeground(Color.white);
rProject.setOpaque(false);
rMaintain.setForeground(Color.white);
rMaintain.setOpaque(false);
orderTypesPanel.add(rInstall);
orderTypesPanel.add(rProject);
orderTypesPanel.add(rMaintain);
// declare new ButtonGroup
ButtonGroup butgro = new ButtonGroup();
// add three buttons to ButtonGroup
butgro.add(rInstall);
butgro.add(rProject);
butgro.add(rMaintain);
}
Then in orderPanel()
, add that one third:
orderPanel.add(probLabel);
orderPanel.add(scriptLabel);
orderPanel.add(orderTypesPanel);
orderPanel.add(vert_scroll);
I think that's what you want.