Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

how can i use 2 splitpanes with 3 components

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
ajayjain
Asked:
ajayjain
  • 3
  • 2
  • 2
1 Solution
 
OviCommented:
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
 
ajayjainAuthor Commented:
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
 
OviCommented:
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

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

What happended to ScrollPane3??
0
 
objectsCommented:
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
 
ajayjainAuthor Commented:
heyyy thanx "object"
Your idea  working.

regards
AJAY JAIN
0
 
objectsCommented:
good to hear :)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now