Forums Register Login

setSize()

+Pie Number of slices to send: Send
Why is it that whenever I use this method on a component (JPanel, JScrollPane, JList etc.), it makes not one iota of a difference to its actual size?
Paul
+Pie Number of slices to send: Send
Try setPreferredSize. When doing layout, prefer methods defined in swing components (e.g. javax.swing.JComponent) over those in awt components (e.g. java.awt.Component).
Now, don't expect all layout managers to respect the preferred size of a component. You may want to use setMinimumSize and/or setMaximumSize, if that is really what you want to do. Don't use those just to set the initial size.
Bill
+Pie Number of slices to send: Send
Thanks Bill. I'm kinda going back to my original question about JList. I want to display a box that contains nothing but could contain a rapidly increasing list of strings.
I want the box to look something like the thing I'm typing into now but I have no idea how to get the thing to display unless I add a vector containing information - and I still have no control over the size of it.
How do I display a box, which never changes its size whether there's data in it or not?
Paul
+Pie Number of slices to send: Send
How are you adding data to the JList?
I think the problem may be more with your layout manager than your component or data. What layout manager are you using?
For example, if you used BorderLayout and added the JList, in a JScrollPane, to your panel at BorderLayout.CENTER, it should stretch in both directions.
Bill
yeah, but ... what would PIE do? Especially concerning this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 874 times.
Similar Threads
component size
ensureIndexIsVisible() - Please Help
JList, clicking empty space selects last item
Clearing Request Parameters ?
visualising the contents of the frame without resizing[urgent]
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 20:22:29.