Solved

set the border for JSplitPane divider

Posted on 2002-04-30
7
1,399 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_
Comment Utility
did you tried following code ?

splitPane.setBorder(null);
0
 
LVL 4

Author Comment

by:sanjay_thakur
Comment Utility
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_
Comment Utility
> the splitpane has Panels

post some sample code that we can work on (small compilable example please)
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 4

Author Comment

by:sanjay_thakur
Comment Utility
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
Comment Utility
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_
Comment Utility
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
Comment Utility
Hi,

This worked fine for me

Thanks
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
endX challenge 2 48
count11 challenge 6 47
where is session ID cache stored 1 38
Running Jira on Raspberry PI 2? 3 117
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
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 theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now