-
Bug
-
Resolution: Not an Issue
-
P4
-
None
-
1.3.0
-
generic
-
generic
Name: yyT116575 Date: 09/28/2000
java version "1.2.2"
Classic VM (build JDK-1.2.2_005, native threads, symcjit)
My application has a vertical layout, and I need a split-pane to show up
beneath a header (Currently implemented as a JPanel. Adding a JSplitPane
to the same component which has a JPanel added causes the JSplitPane to be
reduced in visible width, which is unacceptable for my application. This
bug doesn't manifest itself if I use a JLabel or a JButton instead of a
JPanel, but it does with everything else I could think of substituting
including a Panel, Canvas, JComponent, Component, Button or Label. I don't
personally have the option of using either a button or a label, because I
can't center them above my split-pane without wrapping them in another
container.
To reproduce the problem compile and execute the code which follows. This
is just a GUI problem, so there are no error messages or trace information.
However, the BoxLayout is not working as advertised in this instance. The
workaround for me was to put a JSplitPane within a JSplitPane, obviating the
need for a BoxLayout. Here's the Code:
import java.awt.*; //Container, Dimension, Color, FlowLayout
import java.awt.event.*;
import javax.swing.*; //JFrame, JPanel, JScrollPane, JSplitPane, BoxLayout
public class BugSplit extends JFrame
{
public BugSplit()//Constructor
{
super("Bug Split Example");
Container content = getContentPane();
content.setLayout(new BoxLayout(content, 1));
Dimension hd = new Dimension(200, 40); //The header size
Dimension pd = new Dimension(300, 300); //The panels' size
Dimension sd = new Dimension(200, 200); //The split pane's size
JPanel Header = new JPanel();
Header.setPreferredSize(hd);
Header.setBackground(Color.blue); //To differentiate it.
//Make some panels to scroll
JPanel PRed = new JPanel(), PGreen = new JPanel();
PRed. setBackground(Color.red); PRed. setPreferredSize(pd);
PGreen.setBackground(Color.green); PGreen.setPreferredSize(pd);
//create JSplitPane which contains scrolling panels
JScrollPane Top = new JScrollPane(PRed), Bottom = new JScrollPane(PGreen);
JSplitPane jsp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, Top, Bottom);
jsp.setPreferredSize(sd);
//Now add the header, and the split pane. (Order doesn't matter)
//Splitpane is shown in diminished size.
content.add(Header);
content.add(jsp);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
pack();
setVisible(true);
}
public static void main(String[] s)
{ new BugSplit();}
}
(Review ID: 109491)
======================================================================
- relates to
-
JDK-4143672 BoxLayout not giving enough space to non-panel components
-
- Closed
-
-
JDK-4156284 BoxLayout w/JButton - ignores minimum and preferred sizes
-
- Closed
-
-
JDK-4188874 BoxLayout not aligning mixed components correctly
-
- Closed
-
-
JDK-4352274 BoxLayout misaligns JLabel when used together with JComboBox
-
- Closed
-