the panel is set to null layout and using setBounds i am adding the components to panel.Ths added components are some other JPanel.
when i use this code,i am not able view bottom portion of panel.
JFrame jfr = new JFrame("Frame");
//create a jpanel with null layout//
JPanel jpn = new JPanel();
jpn.setLayout(null);
//create two label and add inside the jpanel, one at top and one at bottom
JLabel label1, label2,label3;
label1 = new JLabel("Label 1"); label1.setBounds(2, 2, 100, 25);
label2 = new JLabel("Label 2"); label2.setBounds(2, 300, 100, 25);
label3 = new JLabel("Label 3"); label3.setBounds(250, 350, 100, 25);
jpn.add(label1); jpn.add(label2);
jpn.add(label3);
//set jpanel size[viewable] to 180 x 350
jpn.setPreferredSize(new Dimension(300, 400));
//create scrollable component and assign jpanel to be view
JScrollPane jsp = new JScrollPane(jpn);
//set jscrollpane size to 200x150
jsp.setBounds(2, 2, 200, 150);
jfr.setContentPane(jsp);
jfr.setSize(210, 180);
jfr.setVisible(true);
I have a similar problem in regards to jTabbedPane and jScrollPane with additional jtable.
Here’s partial of my codes.
jTable1 = new javax.swing.JTable();
jScrollPane1 = new javax.swing.JScrollPane(jTable1);
jtp = new JTabbedPane();
getContentPane().add(jtp);
jp1 = new JPanel();
jtp.addTab("Tab1",jp1);
jScrollPane1.setViewportView(jTable1);
Problem now is the jTabbedPane is not displayed out =(
Please help