how to layout from left to right, no wrapping, no vertical scrollbar
I have a JPanel, and will drag several components to this JPanel when the program is running.
What i want is:
the JPanel has a given height (for instance 200 pixel),
the width of the JPanel will increase when I drag and drop several componens to it.
I want a special layout manager like the flowlayout: arrange all of the componentsfrom left to right, no wrapping.no verticalscrollbar, butthe horizontalscrollbar will display when needed
Idon't want to add a JScrollPane to this JPanel,just layout manager can do.
thank you for anyone who can give me some tips!
[660 byte] By [
bert_suna] at [2007-10-3 3:35:51]

- use a FlowLayout on your panel
- place the panel in a scroll pane with vertical and horizontal scroll bar policies of 'never' and 'as needed' respectively
- that's probably enough but you _may_ need to use a bespoke Viewport subclass to control its minimum size; suck it and see
can you give me some example,
the panel i use has intialized with a special layoutmanager,
but after i change the layout manager to be flowlayout
the components in it seem to layout from left to right then go to next line, then from left to right again.
but i just want all the components always layout from left to right, no line break
thanks
> Oh, ok, FlowLayout won't work then :o)
No, FlowLayout will work the way the user wants. A more common complaint about the FlowLayout is that is "won't wrap" to the next line. The OP must be setting the preferred width of the container. In this case the components will wrap.
If you just create a panel, add the panel to a scrollpane and keep adding components to the panel they will go on horizontally forever.
If the OP needs further help then you need to create a [url http://homepage1.nifty.com/algafield/sscce.html]Short, Self Contained, Compilable and Executable, Example Program[/url] that demonstrates the incorrect behaviour, because I can't guess exactly what you are doing based on the information provided.
And don't forget to use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags[/url] so the code retains its original formatting.