Hi Folks,
I'm still getting used to layout managers etc, I have a JPanel that is quite large in size, I'm wanting to add another panel to it that looks something like below (the contents of the frame)
However when I add this Panel to a bigger Panel, it screws it
And here's the pretty simple test code I've been using
I'm still getting used to layout managers etc, I have a JPanel that is quite large in size, I'm wanting to add another panel to it that looks something like below (the contents of the frame)

However when I add this Panel to a bigger Panel, it screws it

And here's the pretty simple test code I've been using
Code:
public class ProfileTest extends JPanel {
public ProfileTest() {
super(new BorderLayout());
JPanel profilePanel = new JPanel(new BorderLayout());
JPanel buttonsPanel = new JPanel(new GridLayout(2,2));
JLabel optBatchLabel = new JLabel("Optimum Batch Size");
JTextField tf = new JTextField();
JRadioButton pagesRadio = new JRadioButton("Pages",true);
JRadioButton notificationsRadio = new JRadioButton("Notifications",false);
buttonsPanel.add(pagesRadio);
buttonsPanel.add(tf);
buttonsPanel.add(notificationsRadio);
buttonsPanel.setPreferredSize(new Dimension(100,100)); //Thought this might have worked but no
profilePanel.add(optBatchLabel,BorderLayout.NORTH);
profilePanel.add(buttonsPanel,BorderLayout.CENTER);
profilePanel.setPreferredSize(new Dimension(900,900));
add(profilePanel,BorderLayout.CENTER);
}
private static void initLayout() {
JFrame frame = new JFrame("Simple Profile");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ProfileTest newContentPane = new ProfileTest();
newContentPane.setOpaque(true);
frame.setContentPane(newContentPane);
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
javax.swing.SwingUtilities.invokeLater(new Runnable() {
public void run() {
initLayout();
}
});
}
}