-
Bug
-
Resolution: Duplicate
-
P4
-
None
-
1.2.0
-
x86
-
generic, windows_95, windows_nt
If you have a JSplitPane containing a JScrollPane containing a JTree,
the scrollbar of the scrollpane disappears when you press the down
button on the divider, followed by the up button.
See test case below: (with JDK1.2FCS L)
1. Select 3 on the tabbed pane --> JTree is shown with scrollbar
2. Click down button on divider --> scrollbar disappears (OK)
3. Click up button on divider --> scrollbar should reappear
If you manually adjust the divider then the scrollbar reappears,
so the problem only appears to be with the one touch expandable
actions.
-----------------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.plaf.TreeUI;
import javax.swing.tree.*;
import javax.accessibility.*;
public class scrolltree extends JPanel {
// Instantiate JtabbedPane, JScrollPane and JTree
JTabbedPane tabbedPane = new JTabbedPane();
JScrollPane msgScrollPane;
JTree msgListPane;
JButton red = new JButton("RED");
JButton blue = new JButton("BLUE");
Color clr;
public scrolltree() {
// Create default Tree and add to scollpane
msgListPane = new JTree();
JScrollPane msgScrollPane = new JScrollPane(msgListPane);
msgScrollPane.setBackground(Color.green);
tabbedPane.setBackground(Color.yellow);
// Add panels to tabbedpane
Component panel1 = makeTextPanel("One");
tabbedPane.addTab("1", panel1);
tabbedPane.setSelectedIndex(0);
Component panel2 = makeTextPanel("Two");
tabbedPane.addTab("2", panel2);
Component panel3 = msgScrollPane;
tabbedPane.addTab("3", panel3);
JPanel p = new JPanel(new GridLayout(1,0));
// Add listeners for buttons
red.addActionListener(new RedListener());
blue.addActionListener(new BlueListener());
p.add(red);
p.add(blue);
JSplitPane jsp = new JSplitPane();
jsp.setOneTouchExpandable( true );
jsp.setOrientation( JSplitPane.VERTICAL_SPLIT );
jsp.setLeftComponent( tabbedPane );
jsp.setRightComponent( p );
setLayout(new GridLayout(1,0));
add( jsp );
}
protected Component makeTextPanel(String text) {
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
public static void main(String[] args) {
JFrame frame = new JFrame("Color Tester");
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
frame.addWindowListener(l);
frame.getContentPane().add(new scrolltree(), BorderLayout.CENTER);
frame.setSize(400,180);
frame.show();
}
class RedListener implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
msgListPane.setBackground(Color.red);
clr = msgListPane.getBackground();
System.out.println("Background color = " + clr);
}
}
class BlueListener implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
msgListPane.setBackground(Color.blue);
clr = msgListPane.getBackground();
System.out.println("Background color = " + clr);
}
}
}
the scrollbar of the scrollpane disappears when you press the down
button on the divider, followed by the up button.
See test case below: (with JDK1.2FCS L)
1. Select 3 on the tabbed pane --> JTree is shown with scrollbar
2. Click down button on divider --> scrollbar disappears (OK)
3. Click up button on divider --> scrollbar should reappear
If you manually adjust the divider then the scrollbar reappears,
so the problem only appears to be with the one touch expandable
actions.
-----------------------------------------------
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.plaf.TreeUI;
import javax.swing.tree.*;
import javax.accessibility.*;
public class scrolltree extends JPanel {
// Instantiate JtabbedPane, JScrollPane and JTree
JTabbedPane tabbedPane = new JTabbedPane();
JScrollPane msgScrollPane;
JTree msgListPane;
JButton red = new JButton("RED");
JButton blue = new JButton("BLUE");
Color clr;
public scrolltree() {
// Create default Tree and add to scollpane
msgListPane = new JTree();
JScrollPane msgScrollPane = new JScrollPane(msgListPane);
msgScrollPane.setBackground(Color.green);
tabbedPane.setBackground(Color.yellow);
// Add panels to tabbedpane
Component panel1 = makeTextPanel("One");
tabbedPane.addTab("1", panel1);
tabbedPane.setSelectedIndex(0);
Component panel2 = makeTextPanel("Two");
tabbedPane.addTab("2", panel2);
Component panel3 = msgScrollPane;
tabbedPane.addTab("3", panel3);
JPanel p = new JPanel(new GridLayout(1,0));
// Add listeners for buttons
red.addActionListener(new RedListener());
blue.addActionListener(new BlueListener());
p.add(red);
p.add(blue);
JSplitPane jsp = new JSplitPane();
jsp.setOneTouchExpandable( true );
jsp.setOrientation( JSplitPane.VERTICAL_SPLIT );
jsp.setLeftComponent( tabbedPane );
jsp.setRightComponent( p );
setLayout(new GridLayout(1,0));
add( jsp );
}
protected Component makeTextPanel(String text) {
JPanel panel = new JPanel(false);
JLabel filler = new JLabel(text);
filler.setHorizontalAlignment(JLabel.CENTER);
panel.setLayout(new GridLayout(1, 1));
panel.add(filler);
return panel;
}
public static void main(String[] args) {
JFrame frame = new JFrame("Color Tester");
WindowListener l = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
frame.addWindowListener(l);
frame.getContentPane().add(new scrolltree(), BorderLayout.CENTER);
frame.setSize(400,180);
frame.show();
}
class RedListener implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
msgListPane.setBackground(Color.red);
clr = msgListPane.getBackground();
System.out.println("Background color = " + clr);
}
}
class BlueListener implements ActionListener
{
public void actionPerformed(ActionEvent evt)
{
msgListPane.setBackground(Color.blue);
clr = msgListPane.getBackground();
System.out.println("Background color = " + clr);
}
}
}
- duplicates
-
JDK-4243631 JScrollPane fails to reshow scrollbars on window resizes
-
- Resolved
-