-
Bug
-
Resolution: Fixed
-
P3
-
18
-
b19
There is unspecified behavior of BasicSplitPaneDivider:oneTouchExpandableChanged() spec when run with -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel.
Spec says
https://download.java.net/java/early_access/jdk17/docs/api/java.desktop/javax/swing/plaf/basic/BasicSplitPaneDivider.html#oneTouchExpandableChanged()
"it will create the leftButton and rightButton if they are null."
Generally, by calling oneTouchExpandableChanged(), leftButton and rightButton should be created if they are null.
But with GTKLookAndFeel,oneTouchExpandableChanged() does not initialize leftButton and rightButton. They remain null.
If the behavior of the BasicSplitPaneDivider::oneTouchExpandableChanged() varies based on Look and feel then this should be stated explicitly in spec.
Code snippet:
class BasicImpl extends BasicSplitPaneDivider {
public JButton leftB;
public JButton rightB;
public BasicImpl(BasicSplitPaneUI ui) {
super(ui);
}
@Override
protected void oneTouchExpandableChanged() {
super.oneTouchExpandableChanged();
this.leftB = super.leftButton;
this.rightB = super.rightButton;
}
}
public class SplitTests {
public static void main(String[] args) {
new SplitTests().test();
}
public void test(){
BasicSplitPaneUI splitPaneUIS = new BasicSplitPaneUI(){};
JSplitPane splitPane = new JSplitPane();
splitPane.setOneTouchExpandable(true);
splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
splitPaneUIS.installUI(splitPane);
BasicImpl basic= new BasicImpl(splitPaneUIS);
basic.oneTouchExpandableChanged();
if(basic.leftB != null && basic.rightB != null)
System.out.println("Expected : left and right Button created.");
else
System.out.println("Unexpected : buttons are null. " +basic.rightB+ " "+basic.leftB);
}
}
Obeservation:
=====
/scratch/jdk-cache/17/34/jdk-17/bin/java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel SplitTests
Unexpected : buttons are null. null null
/scratch/jdk-cache/17/34/jdk-17/bin/java SplitTests
Expected : left and right Button created.
Spec says
https://download.java.net/java/early_access/jdk17/docs/api/java.desktop/javax/swing/plaf/basic/BasicSplitPaneDivider.html#oneTouchExpandableChanged()
"it will create the leftButton and rightButton if they are null."
Generally, by calling oneTouchExpandableChanged(), leftButton and rightButton should be created if they are null.
But with GTKLookAndFeel,oneTouchExpandableChanged() does not initialize leftButton and rightButton. They remain null.
If the behavior of the BasicSplitPaneDivider::oneTouchExpandableChanged() varies based on Look and feel then this should be stated explicitly in spec.
Code snippet:
class BasicImpl extends BasicSplitPaneDivider {
public JButton leftB;
public JButton rightB;
public BasicImpl(BasicSplitPaneUI ui) {
super(ui);
}
@Override
protected void oneTouchExpandableChanged() {
super.oneTouchExpandableChanged();
this.leftB = super.leftButton;
this.rightB = super.rightButton;
}
}
public class SplitTests {
public static void main(String[] args) {
new SplitTests().test();
}
public void test(){
BasicSplitPaneUI splitPaneUIS = new BasicSplitPaneUI(){};
JSplitPane splitPane = new JSplitPane();
splitPane.setOneTouchExpandable(true);
splitPane.setOrientation(JSplitPane.HORIZONTAL_SPLIT);
splitPaneUIS.installUI(splitPane);
BasicImpl basic= new BasicImpl(splitPaneUIS);
basic.oneTouchExpandableChanged();
if(basic.leftB != null && basic.rightB != null)
System.out.println("Expected : left and right Button created.");
else
System.out.println("Unexpected : buttons are null. " +basic.rightB+ " "+basic.leftB);
}
}
Obeservation:
=====
/scratch/jdk-cache/17/34/jdk-17/bin/java -Dswing.defaultlaf=com.sun.java.swing.plaf.gtk.GTKLookAndFeel SplitTests
Unexpected : buttons are null. null null
/scratch/jdk-cache/17/34/jdk-17/bin/java SplitTests
Expected : left and right Button created.
- is cloned by
-
JDK-8336873 BasicSplitPaneDivider:oneTouchExpandableChanged() should mention that implementation depends on SplitPane.supportsOneTouchButtons property
-
- Resolved
-