posted 18 years ago
Hi
I am having problems in getting the scrollpane in a tabbed pane with each tab being a JPanel with Null layout .
In detail , I am having a JTabbedPane where each Tab is a JPanel with layout set to null using panel.setLayout(null) and all the components are added using the Bounds ...and i am wrapping the each panel in a JscrollPane . But the scroll pane is not coming . But the same works fine when i add the components to the panel using a borderlayout instead of null layout
here is the code
JPanel toPanel = new JPanel();
toPanel.setLayout(new BorderLayout());
JTabbedPane pane = new JTabbedPane();
JPanel panel = new JPanel();
// panel.setLayout(new GridBagLayout());(Works fine if i use this)
panel.setLayout(null);
panel.setBounds(0,0,965,150);
JLabel label = new JLabel("asjfdashjsfjfgasfsasjfdashjsfjfgasfsasjfdashjsfjfgasfsasjfdashjsfjfgasfsasjfdashjsfjfgasfsasjfdashjsfjfgasfsasjfdashjsfjfgasfs");
label.setBounds(10,10,831,81);
panel.add(label);
JTextField field = new JTextField(10);
field.setBounds(861,10,94,18);
panel.add(field);
JScrollPane scroll = new JScrollPane(panel);
pane.add(scroll, "test");
toPanel.add(pane);
Can any one let me know how this can be avoided ?? I must use null layout only as the bounds will come from some other application