Solved

set the border for JSplitPane divider

Posted on 2002-04-30
7
1,432 Views
Last Modified: 2012-06-27
Hi,

How do I set the border for the JSPlitPane divider

I know that the border of the components placed
in the SplitPane acts as the divider border

But If I just want to set the border for the divider
irrespective of the border of the components

How do I do this?

Please help
0
Comment
Question by:sanjay_thakur
  • 4
  • 3
7 Comments
 
LVL 16

Expert Comment

by:heyhey_
ID: 6985895
did you tried following code ?

splitPane.setBorder(null);
0
 
LVL 4

Author Comment

by:sanjay_thakur
ID: 6986784
Hi,

I tried it but this wont help me to set a border
just for the divider.

the splitpane has Panels and the divider just takes the
borders set for the panels

There is no specific way to set the border just
for the divider

Please help
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 6991248
> the splitpane has Panels

post some sample code that we can work on (small compilable example please)
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 4

Author Comment

by:sanjay_thakur
ID: 6991439
Hi
This is a test code

How do I set the border specifically for the divider
without setting the border for the panels
contained in it?

import javax.swing.JFrame;
import javax.swing.*;

import java.awt.BorderLayout;
import java.awt.Dimension;


class Test
{
    // Instance attributes used in this example
    private JPanel topPanel;
    private JPanel bottomPanel;
    private JSplitPane sp;
    private JFrame frame;

    // Constructor of main frame
    public Test()
    {

        try
        {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        }
        catch (Exception e)
        {
        }
        finally
        {
        }


        // Set the frame characteristics
        frame = new JFrame();


        // Create a panel to hold all other components
        topPanel = new JPanel();
        topPanel.setLayout(new BorderLayout());

        bottomPanel = new JPanel();
        topPanel.setLayout(new BorderLayout());


        JSplitPane sp = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, topPanel, bottomPanel);
        sp.setBorder(null);
        sp.setPreferredSize(new Dimension(500, 500));
        sp.setDividerSize(10);
        //add the components
        frame.getContentPane().setLayout(new BorderLayout());
        frame.getContentPane().add(sp, BorderLayout.CENTER);

        frame.pack();
        frame.show();

    }


    // Main entry point for this example
    public static void main(String args[])
    {
        // Create an instance of the test application
        Test mainFrame = new Test();

    }


}


There is nothing like  "setDividerBorder()" API

What  if I want to have a custom border for the divider?

Thanks

0
 
LVL 16

Accepted Solution

by:
heyhey_ earned 50 total points
ID: 6994393
adding this line at the very beggining of the main method will make all SplitPaneDivider borders empty. does this help you ?

UIManager.put("SplitPaneDivider.border", BorderFactory.createEmptyBorder());
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 6994411
another option is to go through all JSplitPane children, find the Divider component and set it's border only.

       Component comps[] = sp.getComponents();
       for (int i = 0; i  < comps.length; i++)
       {
         System.out.println("" + i + " " + comps[i]);
       }
0
 
LVL 4

Author Comment

by:sanjay_thakur
ID: 6996803
Hi,

This worked fine for me

Thanks
0

Featured Post

MIM Survival Guide for Service Desk Managers

Major incidents can send mastered service desk processes into disorder. Systems and tools produce the data needed to resolve these incidents, but your challenge is getting that information to the right people fast. Check out the Survival Guide and begin bringing order to chaos.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How do I remove an object from a 3 28
String array comparison 4 34
printf performancy 11 45
Notify sent to other threads in Java 9 17
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
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.

825 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