I am currently working on nesting a jPanel inside of a jPanel, the code for which is
jPanel1 is the master pane with "panel" being used inside, as you can see from the SetPreferredSize I am trying to restrict the size of the internal panel but neither that, with dimension, or SetSize (int/Dimension) seem to be working correctly - the panel still fills the entire of jPanel1. Am I missing something obvious?
I am aware my naming conventions are poor but this is a simple demo program for playing around with the interface.
Thanks in advance,
Border loweredetched = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
jPanel1.setLayout(new GridLayout(0, 1, 0, 0));
JPanel panel = new JPanel();
panel.setBackground(Color.yellow);
panel.setLayout(new GridLayout(0, 1, 0, 0));
JLabel someLabel = new JLabel("To: ");
JLabel someLabel2 = new JLabel("From: ");
JLabel someLabel3 = new JLabel("Date: ");
JLabel someLabel14 = new JLabel("Email ");
panel.add(someLabel);
panel.add(someLabel2);
panel.add(someLabel3);
panel.add(new JSeparator());
panel.add(someLabel14);
panel.setBorder(loweredetched);
panel.setPreferredSize((new Dimension(20,50)));
panel.validate();
jPanel1.add(panel);
jPanel1.revalidate();
jPanel1 is the master pane with "panel" being used inside, as you can see from the SetPreferredSize I am trying to restrict the size of the internal panel but neither that, with dimension, or SetSize (int/Dimension) seem to be working correctly - the panel still fills the entire of jPanel1. Am I missing something obvious?
I am aware my naming conventions are poor but this is a simple demo program for playing around with the interface.
Thanks in advance,