-
Bug
-
Resolution: Unresolved
-
P3
-
8, 11, 17, 18, 19
-
generic
-
generic
ADDITIONAL SYSTEM INFORMATION :
OS: tested on Linux, but actually not OS specific.
JDK version: openjdk version "18.0.1.1" (persists since at least Java 8)
A DESCRIPTION OF THE PROBLEM :
JTabbedPane scroll buttons are laid out incorrectly, when JTabbedPane's border has nonequal left and right insets.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See "Source code for an executable test case" for code example.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Scroll buttons are laid out correctly.
ACTUAL -
When border's left inset is greater than right inset -- scroll buttons are laid out on top of a tab components.
When border's left inset is less than right inset -- scroll buttons are laid out outside of a tab area.
---------- BEGIN SOURCE ----------
import javax.swing.BorderFactory;
import javax.swing.JTabbedPane;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
public class TabbedPaneDemo extends JPanel {
public TabbedPaneDemo() {
super(new GridLayout(1, 1));
JTabbedPane tabbedPane = new JTabbedPane();
// trigger the bug
// insets.right > insets.left
tabbedPane.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 50, Color.red));
// insets.left > insets.right
// tabbedPane.setBorder(BorderFactory.createMatteBorder(0, 50, 0, 0, Color.red));
for (int i = 0; i < 4; i++) {
JLabel lbl = new JLabel("Tab " + (i + 1));
tabbedPane.addTab("Tab " + (i + 1), /*Icon*/null, /*Component*/lbl, /*Tooltip*/null);
}
add(tabbedPane);
tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
}
private static void createAndShowGUI() {
JFrame frame = new JFrame("TabbedPaneDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new TabbedPaneDemo(), BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
---------- END SOURCE ----------
FREQUENCY : always
OS: tested on Linux, but actually not OS specific.
JDK version: openjdk version "18.0.1.1" (persists since at least Java 8)
A DESCRIPTION OF THE PROBLEM :
JTabbedPane scroll buttons are laid out incorrectly, when JTabbedPane's border has nonequal left and right insets.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
See "Source code for an executable test case" for code example.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Scroll buttons are laid out correctly.
ACTUAL -
When border's left inset is greater than right inset -- scroll buttons are laid out on top of a tab components.
When border's left inset is less than right inset -- scroll buttons are laid out outside of a tab area.
---------- BEGIN SOURCE ----------
import javax.swing.BorderFactory;
import javax.swing.JTabbedPane;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JFrame;
import javax.swing.JComponent;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.GridLayout;
public class TabbedPaneDemo extends JPanel {
public TabbedPaneDemo() {
super(new GridLayout(1, 1));
JTabbedPane tabbedPane = new JTabbedPane();
// trigger the bug
// insets.right > insets.left
tabbedPane.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 50, Color.red));
// insets.left > insets.right
// tabbedPane.setBorder(BorderFactory.createMatteBorder(0, 50, 0, 0, Color.red));
for (int i = 0; i < 4; i++) {
JLabel lbl = new JLabel("Tab " + (i + 1));
tabbedPane.addTab("Tab " + (i + 1), /*Icon*/null, /*Component*/lbl, /*Tooltip*/null);
}
add(tabbedPane);
tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT);
}
private static void createAndShowGUI() {
JFrame frame = new JFrame("TabbedPaneDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new TabbedPaneDemo(), BorderLayout.CENTER);
frame.pack();
frame.setVisible(true);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
createAndShowGUI();
}
});
}
}
---------- END SOURCE ----------
FREQUENCY : always
- relates to
-
JDK-8225220 When the Tab Policy is checked,the scroll button direction displayed incorrectly.
- Resolved