?
Solved

how can i use 2 splitpanes with 3 components

Posted on 2003-03-20
7
Medium Priority
?
254 Views
Last Modified: 2010-03-31
dear,
 
i want to use 2 SplitPanes for spliting 3 components at a time . The code will make it more clear.

ScrollPane1,ScrollPane2,ScrollPane3 are 3 scrollPanes having 3 components added to it.

sp1,sp2 are 2 SplitPanes.
panel is JPanel.

/* code*/
 
sp1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,scrollPane,scrollPane1);
sp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,scrollPane1,scrollPane2);
panel1.add(sp1);
panel2.add(sp2);

Means i need to share scrollPane1 between 2 SplitPanes.

PROBLEM OCCURING : 2 SplitPanes are appered properly but only 1 is enabled which is added later i.e. splitPane2.

please give me the appropriate suggetions.
thanx in Advance

regards
AJAY JAIN



0
Comment
Question by:ajayjain
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 9

Expert Comment

by:Ovi
ID: 8173767
Yes, that's the normal behaviour. You cannot add a component in two different locations on the screen (application). Use cloned scrollPane or another one synchronized with the original.
0
 

Author Comment

by:ajayjain
ID: 8173828
Ya that's okkai.

To sove this problem wt i did is :

i added the mouse LIstener to both these  SplitPanes.So that if i m using 1st splitPane then i must remove the scrollPane 1 from another SplitPane. and vise versa .

Means i dynamically trying to use scrollPane1 with both the SplitPane.

PROBLEM OCCURING : The mouse click event not able to detect the devider .

is there any way so that i could know which SplitPane devider is in use currently .

regards

AJAY JAIN
0
 
LVL 9

Expert Comment

by:Ovi
ID: 8173896
The scrollPane and the holding splitpane will not receive mouse events because the events will be captured by the component contained by the scrollPane. You couls trick this if you will use something like this:

1. create a JPanel called scrollPaneHolder
2. set the layout to BorderLayout
3. Add to north a JLabel called titleLabel
4. Add to center the scrollPane

You will have as result a component which looks like a window, and you can use the JLabel (title), as mouseEvent notification component. When you click on the "window" in the left side, you will move the scrollPane from the right scrollPaneHolder. When you click on right you'll move'it from left. You could set some active/innactive collors to the JLabel and so you'll make a pretty intuitive and user friendly component.

Hope it will help you.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 92

Expert Comment

by:objects
ID: 8177067
> ScrollPane1,ScrollPane2,ScrollPane3 are 3 scrollPanes having 3 components added to it.

What happended to ScrollPane3??
0
 
LVL 92

Accepted Solution

by:
objects earned 200 total points
ID: 8177075
try adding one of the split panes into the other split pane something like:

sp1 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,scrollPane1,scrollPane2);
sp2 = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT,sp1,scrollPane3);
panel2.add(sp2);
0
 

Author Comment

by:ajayjain
ID: 8178907
heyyy thanx "object"
Your idea  working.

regards
AJAY JAIN
0
 
LVL 92

Expert Comment

by:objects
ID: 8178942
good to hear :)
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Suggested Courses
Course of the Month8 days, 8 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question