Search...
FAQs
Subscribe
Pie
FAQs
Recent topics
Flagged topics
Hot topics
Best topics
Search...
Search within Swing / AWT / SWT
Search Coderanch
Advance search
Google search
Register / Login
Forums
Register
Login
Java
»
Swing / AWT / SWT
JList and scrollpane issue
vijaya raghva naidu rambha
,
Greenhorn
Jun 18, 2008 13:07:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
i hava JList wich is having 1000 elements but when i put in a scroll pane i can see only 80 while scrolling can any one suggest where is the issue is .
Craig Wood
,
Ranch Hand
Jun 18, 2008 16:15:00
(0 cow)
(0 skulls)
+Pie
Number of slices to send:
Send
import java.awt.*; import javax.swing.*; public class ScrollList { private JScrollPane getContent() { // Copied from comments section of JList class api. // This list model has about 2^16 elements. Enjoy scrolling. JList bigDataList = new JList(bigData); // We don't want the JList implementation to compute the width // or height of all of the list cells, so we give it a string // that's as big as we'll need for any cell. It uses this to // compute values for the fixedCellWidth and fixedCellHeight // properties. bigDataList.setPrototypeCellValue("Index 1234567890"); return new JScrollPane(bigDataList); } // Copied from comments section of JList class api. ListModel bigData = new AbstractListModel() { public int getSize() { return Short.MAX_VALUE; } public Object getElementAt(int index) { return "Index " + index; } }; public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.add(new ScrollList().getContent()); f.setSize(200,200); f.setLocation(200,200); f.setVisible(true); } }
Post by:
autobot
Arch enemy? I mean, I don't like you, but I don't think you qualify as "arch enemy". Here, try this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
reply
This thread has been viewed 860 times.
Similar Threads
JList
JLIST Store and retreive data to Properties
Add text and image to JList
JList + Vector
Drag and Drop from JList to JTree
More...
All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 08:56:08
.