• 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

getting a JScrollPane to display its scrollbars

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public Object [] showDeleteTableOptions() {
Vector listData = getListData();// This retrieves a vector containing the options
listData.trimToSize();
int size = listData.size();

JCheckBox [] checkBoxes = new JCheckBox[size];

JPanel panel = new JPanel();
panel.setLayout(new GridLayout(size, 1));

for (int i=0; i< size; i++) {
checkBoxes[i] = new JCheckBox(listData.get(i).toString());
panel.add(checkBoxes[i]);
}
int dialogResult = JOptionPane.showOptionDialog(this, new JScrollPane(panel), " Select table(s) to delete",
JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, okAllCancel, okAllCancel[0]);

if (dialogResult ==0 ) {// Process...}
}

Question. Why doesn't the JScrollPane's scrollbar show when the panel contains a large list which is almost the height of the screen.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to Swing forum...
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
run this as is, then comment out the indicated line, and uncomment the block
run it again, then uncomment the preferredSize() line, and run it again

 
chinomso ikwuagwu
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks! Learnt something new.
reply
    Bookmark Topic Watch Topic
  • New Topic