Solved

set the border for JSplitPane divider

Posted on 2002-04-30
7
1,475 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
[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
  • 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
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
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

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.

Question has a verified solution.

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

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

688 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