Solved

set the border for JSplitPane divider

Posted on 2002-04-30
7
1,456 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
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!

 
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

Independent Software Vendors: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Configure a Bean in an XML file 4 48
Running JavaFX on the Raspberry Pi 27 123
program arguments vs VM arguments 4 25
Where to place postgres JDBC driver jar on tomcat 8 24
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 …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
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.

735 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