• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JScrollBar problem???

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;
}
 
Ranch Hand
Posts: 508
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
There are no more "hours", it's centi-days. They say it's better, but this tiny ad says it's stupid:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic