Reputation: 124
I've a Frame which has two internal frames. I create a 'Board' object which is an instance of Board class. Board class extends JPanel.
class Layout extends JFrame{
Dimension dimen=Toolkit.getDefaultToolkit().getScreenSize();
public initializeWindows(){
JInternalFrame dev=new JInternalFrame("Devices",true,true,false,false);
JInternalFrame cir=new JInternalFrame("Circuit",true,true,false,false);
Board b=new Board();
cir.add(b);
JScrollPane scroll=new JScrollPane(b);
this.add(dev);
this.add(cir);
dev.setVisible(true);
dev.setSize(150,650);
dev.setLocation(0,100);
dev.pack();
inf.setVisible(true);
inf.setPreferredSize(new Dimension((int)(dimen.width*0.88),(int)(dimen.height*0.75)));
inf.setLocation(150,100);
inf.setBackground(Color.WHITE);
inf.pack();
}
But the scrollpane does not appear. Why is tat??
Upvotes: 0
Views: 746
Reputation: 2339
please set cir.setVisible(true)
and cir.add(scroll)
instead of cir.add(b);
If you want your scroll bars to be visible all times you can use
scroll = JScrollPane(b,
ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS)
Upvotes: 1
Reputation: 133669
Because you are not adding the JScrollPane
to the internal frame.
You are actually adding the Board
to the JInternalFrame cir
and to the JScrollPane
while you should do something like
JInternalFrame cir=new JInternalFrame("Circuit",true,true,false,false);
Board b=new Board();
JScrollPane scroll=new JScrollPane(b);
cir.add(scroll)
this.add(cir);
Upvotes: 1