-
Advice needed for adding a JScrollPane to JPanel
What I've done is added a JScrollPane to a JPanel and everything worked fine until I changed the JPanel's layout from GridLayout to null. I am adding a lot of JButtons to this panel and changed the layout to null so I have more control over how the buttons look. The problem is that now the JPanel doesn't scroll. The scrollbars are there but they do nothing.
To summarize: How do I had a JScrollPane to a JPanel who's layout is null?
secondary question: If a JButton thinks there isn't enough room to display it's label, is it possible to force it to paint it anyway instead of '...'?
Thanks!
-
you mean you added a panel to a scrollpane? you'd have to override the preferredSize method of the panel and calculate the size you want manually. No layout, it doesn't know how big to make the component. So it'll default to the size of the space its given. Scrollpane only kicks in basically when that component extends beyond visible bounds.
-
setting layout to null will generate problems, since the jscrollpane will not know, how big the underlying pane is.
if you want to control the positions of your components by yourself, you will have to write your own layoutmanager, that will calculate its preffered size by wvaluation position and size information of included components.
Instead use the absolutepositioninglayoutmanager provided at my blog:
http://narcanti.keyboardsamurais.de/...es-layout.html
it allows you to set the components wherever you want, and calculates correct sizes for min and preferred size.
Similar Threads
-
Replies: 2
Last Post: 03-22-2006, 03:10 AM
-
Replies: 1
Last Post: 04-08-2005, 10:36 AM
-
By Dan Newman in forum ASP.NET
Replies: 0
Last Post: 12-12-2001, 05:20 PM
-
By Munchkin in forum Java
Replies: 3
Last Post: 03-16-2001, 04:58 PM
-
By Sudhakar in forum Java
Replies: 1
Last Post: 05-08-2000, 04:12 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks