• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JScrollBar problem???

 
sharath kv
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I have added a JScrollBar,horizontally within a JTabbedPane.
The JTabbedPane contains JTextFields that are in a single line horizontally.Using the JScrollBar,I am unable to view all the Textfields that are out of the viewing area.
****************HERE'S MY SOURCE **********
public JTabbedPane nesTabs(JTabbedPane tabbedPane)
{
nesLabel = new JLabel[nesStr.length];
nesTextField = new JTextField[nesStr.length];
Nes = new JPanel();
Nes.setLayout(new BorderLayout());
JScrollBar scrollBar2 = new JScrollBar(JScrollBar.HORIZONTAL, 0, 5, 0, 100);
scrollBar2.setUnitIncrement(2);
scrollBar2.setBlockIncrement(1);
scrollBar2.addAdjustmentListener(this);
Nes.add(scrollBar2, BorderLayout.SOUTH);
tabbedPane.addTab(" MNN " ,null,Nes,"NES Table");
int al=10; int y_al=10;
for(int i=0;i<nesStr.length;i++)
{
nesLabel[i] = new JLabel(nesStr[i]);
nesLabel[i].setBounds( al, 15, 170, 20 );
Nes.add(nesLabel[i]);
nesTextField[i] = new JTextField();
nesTextField[i].setBounds(y_al,35,120,20);
Nes.add(nesTextField[i]);
al=al+140;
y_al = y_al+140;
}

for(int j=0;j<nesStr.length;j++)
{
nesTextField[j].setEditable(false);
}
return tabbedPane;
}
 
Chantal Ackermann
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
you should use JScrollPane: put the textfields on a JPanel and add it to a JScrollPane. If the panel fits in height into the viewport but not in width only the horizontal scrollbar will appear - that is what you want, isn't it?
chantal
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic