Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / August 2006

Tip: Looking for answers? Try searching our database.

Design with two JScrollPanes

Thread view: 
Pawel Stawicki - 04 Aug 2006 21:31 GMT
I want to display two JScrollPanes (left and right). I want the left one
to change it's width when window is resized, right one to have fixed
width. In both scrollpanes I want to have many smaller components, laid
out by FlowLayout (I think this would be the best), but this components
are added and removed as application works. In right scrollpane I want
to have it all in one fixed-width column, in left I want components to
be laid out in rows, as in FlowLayout.

Problem is with JScrollPanes, I don't know how to design it all. I was
trying with many layout managers and many settings, but when JPanel with
FlowLayout is in JScrollPane, it lays out everything in one row and
there is just horizontal scroll bar added.

Any ideas?

Regards
Pawel Stawicki
Andrew Thompson - 05 Aug 2006 07:54 GMT
...
> Problem is with JScrollPanes, I don't know how to design it all. I was
> trying with many layout managers and many settings, but when JPanel with
> FlowLayout is in JScrollPane, it lays out everything in one row and
> there is just horizontal scroll bar added.

This might help get you started...
<sscce>
import java.awt.*;
import javax.swing.*;

class SpitFlowTest {
 public static void main(String[] args) {
   JFrame f = new JFrame();

   JPanel p = new JPanel();
   p.setPreferredSize( new Dimension(100,200) );

   for(int ii=0; ii<10; ii++) {
     p.add(new JLabel("label " + ii));
   }

   JScrollPane scrollp = new JScrollPane(p,
     ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED,
     ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER );

   JSplitPane sp = new JSplitPane(
     JSplitPane.HORIZONTAL_SPLIT,
     scrollp, new JLabel("Hi!"));
   f.getContentPane().add(sp);

   f.pack();
   f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
   f.setVisible(true);
 }
}
</sscce>

HTH

Andrew T.
Pawel Stawicki - 05 Aug 2006 09:31 GMT
Well, I don't want to have JSplitPane. And I can't set preferred size,
because size is changing as I am adding and removing components. I was
trying to override getPreferredSize and compute it depending on
components I have to display, but it didn't help :( Looks like it
behaves differently in JSplitPane, but again, I don't have JSplitPane.

Regards
Pawel Stawicki
Andrew Thompson - 05 Aug 2006 11:06 GMT
> Well, I don't want to have JSplitPane. ..

Now that I reread your question, I note you haven't.
I don't know where I got the idea you were dealing
with split panes!

I'll reread it and see if I can understand what you're after..
Dont suppose you have a screenshot/drawing/example?
A picture speaks a thousand words.

Andrew T.
Pawel Stawicki - 05 Aug 2006 11:51 GMT
> I'll reread it and see if I can understand what you're after..
> Dont suppose you have a screenshot/drawing/example?
> A picture speaks a thousand words.

You're right. Here's screenshot: http://www.amorfis.yoyo.pl/screenshot.jpg

Can you see "markets" going to the right and passing the edge? There is
FlowLayout on this panel, and I would like it to go to next row, like it
happens in FlowLayout panel if it is not in JScrollPane.

Thanks in advance

Regards
Pawel Stawicki


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.