JDK-4131528 : Blank Gaps around borders of panels added to JSplitPane's are undesirable
  • Type: Enhancement
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Won't Fix
  • OS: windows_nt
  • CPU: x86
  • Submitted: 1998-04-22
  • Updated: 1999-03-01
  • Resolved: 1999-03-01
Related Reports
Relates :  
Blank Gaps around borders of panels added to JSplitPane's are
undesirable...becomes very evident when several JSplitPane's are nested.

Using Swing 1.0.1 and JDK 1.1.5 - see attached test case.

To Reproduce: See the white gap below and to the right side of the
JSplitPane in the middle.  This Horizontal JSplitPane is the first
created in SplitPanePanel.java on lines 78-83.


middleSplitPane = new JSplitPane
                        (JSplitPane.HORIZONTAL_SPLIT, leftPanel, rightPanel);
middleSplitPane.getAccessibleContext().setAccessibleName("Middle Split Panes");

EVALUATION ralph.kar@Eng 1998-05-22 I cannot reproduce the problem from the testcase. I need a better description and possibly a smaller testcase that shows that something is wrong with JSplitPane. Yes I see border, but the testcase creates them and they only show in one of the split panes the user creates (existence of a bug is unlikely). I would like to see a plain JSplitPane test case that shows the problem (if there is a problem). jonathan.benoit@East 1998-06-01 Currently awaiting licensee feedback on engineering request for new test case. ralph.kar@Eng 1998-06-11 Jonathan got an answer today from the user. They also sent a new testcase which I modified to its simplest form. I do now see the problem, although those blank gaps are very tiny. The problem occurs because of the nesting of JSplitPanes. Every JSplitPane has its own border. Nesting the JSplitPanes also causes the borders to be nested, which makes them appear thicker for the innermost JSplitPane, since all borders there add up to one thick border. This hardly qualifies as a bug. The JSplitPane is designed to have a border. You could turn the border off with setBorder(null), but this looks very ugly on the divider. A separation of the border of the JSplitPane and the border of the divider would be a possible solution here. I will mark this report as an RFE. Here is the testcase: import com.sun.java.swing.*; import com.sun.java.swing.border.*; import java.awt.*; import java.awt.event.*; public class SplitPanes extends JFrame { JPanel panel1 = new JPanel(); JPanel panel2 = new JPanel(); JPanel panel3 = new JPanel(); JPanel panel4 = new JPanel(); JSplitPane middleSplitPane = null; JSplitPane topSplitPane = null; JSplitPane bottomSplitPane = null; public SplitPanes() { super("Testcase (4131528)"); panel1.setPreferredSize(new Dimension(500, 200)); panel2.setMinimumSize(new Dimension(50, 20)); panel2.setPreferredSize(new Dimension(300, 70)); panel3.setMinimumSize(new Dimension(50, 20)); panel4.setMinimumSize(new Dimension(50, 20)); panel4.setPreferredSize(new Dimension(500, 90)); middleSplitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, false, panel2, panel3); topSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false, panel1, middleSplitPane); bottomSplitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, false, topSplitPane, panel4); this.getContentPane().setLayout(new BorderLayout()); this.getContentPane().add(bottomSplitPane, "Center"); this.setBackground(Color.lightGray); this.setSize(630, 470); this.setVisible(true); } public static void main(String[] args) { new SplitPanes(); } } scott.violet 1999-03-01 I am closing this as will not fix. As Ralph points out, setting the borders to null does most of what is needed.

WORK AROUND ralph.kar@Eng 1998-07-08 The following code demonstrates a possible workaround for the problem. The idea is to set the border of the JSplitPane to null. Since the divider in a JSplitPane does not have its own border, it is necessary for the components within the JSplitPane to have a border. The example uses JButtons which all come with a border so this looks ok. If you try the same thing with JPanels which do not have a border it looks ugly and may be unusable in the Windows L&F. The workaround with those is to give them a border (e.g. JPanel.setBorder(new BevelBorder(BevelBorder.LOWERED)). import com.sun.java.swing.*; import java.awt.*; import java.awt.event.*; public class NestedSplitPanes extends JFrame { JButton[] arrB = new JButton[16]; JSplitPane[] arrS = new JSplitPane[15]; public NestedSplitPanes() { super("Nested JSplitPanes"); for (int i=0; i<16; i++) { arrB[i] = new JButton("Button " + (i + 1)); } for (int i=0; i<8; i++) { arrS[i] = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, arrB[i*2], arrB[i*2+1]); } for (int i=8; i<12; i++) { arrS[i] = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, arrS[(i-8)*2], arrS[(i-8)*2+1]); } arrS[12] = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, arrS[8], arrS[9]); arrS[13] = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, arrS[10], arrS[11]); arrS[14] = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, arrS[12], arrS[13]); for (int i=0; i<15; i++) { // The following works because the JButtons in the // JSplitPanes have their own Borders. // Borderless components would have to be given a // border before doing this, otherwise the whole thing // looks really ugly and would even be almost unusable // in the Windows L&F (e.g. try JPanels instead of // JButtons. // If you comment out the following line you can // observe the stacking border problem (4131528). arrS[i].setBorder(null); } this.getContentPane().add(arrS[14]); this.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent ev) { System.exit(0); } }); this.pack(); this.setVisible(true); } static public void main(String args[]) { new NestedSplitPanes(); } }

PUBLIC COMMENTS Blank Gaps around borders of panels added to JSplitPane's are undesirable scott.violet 1999-03-01 As Ralph points out, setting the borders to null does most of what is needed.