wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Multi panels in JScrollPane Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Multi panels in JScrollPane" Watch "Multi panels in JScrollPane" New topic
Author

Multi panels in JScrollPane

saar nag
Greenhorn

Joined: Jun 08, 2004
Posts: 1
Hi,

My program:
I'm trying to build a Task application.
Each task, is represented in a JPanel with its own information.

What I'm trying to accomplish:
If I have many tasks, I want the user to be able, to scroll through the task and manage each and every one.

How I try to accomplish it:
I creates a JScrollPane, and added a JPanel to it with Vertical Flow Layout (That defined in JDeveloper IDE).
Visually, each new Task, is created under the last one.

The problam:
1. Every time I add the New TaskPanel to the JPanel in the JScrollPane, I can't see the new Task In it, only after exiting and executing the program again.
2. It seems, that when there are to many Tasks to display in the JPanel, there is no scoll availiable, as if the JScrollPane is not aware of that information.

Other thoughts:
Is there a way to change the LayoutManager of the JScrollPane, so it can recieve more then 1 Panel. Or Am I stack with a Panel container that can handle multiple TaskPanels.


I hope my question is clear enough

Thanks Sa'ar
Jose Botella
Ranch Hand

Joined: Jul 03, 2001
Posts: 2120
Welcome to the Ranch saar!

If Vertical flow layout doesn't suit you, change it for BoxLayout, GridLayout, or GridBagLayout. All of them are good ones to show a column of components.

No, it is not wise to change the layout of a scroll pane. This is from JScrollPane.setLayout

This method overrides setLayout in java.awt.Container to ensure that only LayoutManagers which are subclasses of ScrollPaneLayout can be used in a JScrollPane.


For a completely different behaviour than the one provided by ScrollPaneLayout consider using a JDesktopPane and each task an instance of JInternalFrame for letting the user to interact with them.


SCJP2. Please Indent your code using UBB Code
 
jQuery in Action, 2nd edition
 
subject: Multi panels in JScrollPane
 
Similar Threads
adding JPanel to a JScrollPane
JScrollerPane
Newbie Question on dependency execution
JScrollPane for JPanel
Need to dynamically add checkBoxes in a GUI