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
posted Mar 28, 2006 18:42:00
0
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.
subject: getting a JScrollPane to display its scrollbars