i am having problem adding a JScrollPane to a frame that has a panel and i want to keep layout of panel as null.
if i use any layout than JScrollPane appears but not when i use layout as null
this is my code :
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class make_time_table extends JFrame
{
Container c;
Choice subject [] = new Choice [40];
Choice teacher [] = new Choice [40];
JScrollPane scrollpane;
int x=50,y=10;
make_time_table()
{
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
init();
}
public void init()
{
JPanel p = new JPanel();
p.setSize(600, 400);
p.setLayout(null);
for(int i=0;i<40;i++)
{
subject[i] = new Choice();
//subject[i].add("HEllo");
p.add(subject[i]);
subject[i].setBounds(x,y,50,100);
x=x+100;
}
scrollpane = new JScrollPane(p);
getContentPane().add(scrollpane, BorderLayout.CENTER);
}
public static void main(String args[])
{
make_time_table obj = new make_time_table();
obj.setVisible(true);
obj.setExtendedState(JFrame.MAXIMIZED_BOTH);
obj.setTitle("make time table");
}
}
please tell me how to add JScrollPane to a null layout