File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes getting a JScrollPane to display its scrollbars Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "getting a JScrollPane to display its scrollbars" Watch "getting a JScrollPane to display its scrollbars" New topic
Author

getting a JScrollPane to display its scrollbars

chinomso ikwuagwu
Greenhorn

Joined: Mar 28, 2006
Posts: 11
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.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Moving to Swing forum...


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
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

Joined: Mar 28, 2006
Posts: 11
Thanks! Learnt something new.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: getting a JScrollPane to display its scrollbars