-
Enhancement
-
Resolution: Unresolved
-
P3
-
9
-
x86_64
-
windows_7
A DESCRIPTION OF THE REQUEST :
This is a duplicate of 5006095, but this will really be needed once illegal reflective access is enforced.
Currently, reflection can be use to access javax.swing.plaf.basic.BasicSplitPaneUI.setKeepHidden(boolean) and javax.swing.plaf.basic.BasicSplitPaneUI.getKeepHidden() .
Since this will not be allowed in the future, there needs to be a way to get and set the "keep hidden" property of split panes. Although this may not be available depending on Look & Feel, JSplitPane.setOneTouchExpandable(boolean) is provided and the same applies.
JUSTIFICATION :
If the user fully closes or opens a split pane and closes an application, the application should be able to restore that fully closed or open state the next time the it is opened.
It also may be useful to initialize a split pane as fully open or closed if the functionality of one side is currently inactive, and to automatically pop it open when it becomes active.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Would like to see
boolean JSplitPane.getKeepHidden()
and
JSplitPane.setKeepHidden(boolean)
---------- BEGIN SOURCE ----------
/* Run test case then resize frame. Split panes do not stay open/closed.
Uncomment reflection code to enable this behavior. */
import javax.swing.*;
import java.awt.*;
public class JSplitPaneIssue {
public static void main(String args[]) {
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new GridLayout(1, 2));
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
split.setOneTouchExpandable(true);
split.setResizeWeight(.5);
split.setTopComponent(new JLabel("top"));
split.setBottomComponent(new JLabel("bottom"));
frame.getContentPane().add(split);
JSplitPane split2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
split2.setOneTouchExpandable(true);
split2.setResizeWeight(.5);
split2.setTopComponent(new JLabel("top2"));
split2.setBottomComponent(new JLabel("bottom2"));
frame.getContentPane().add(split2);
frame.setSize(400, 400);
frame.setVisible(true);
split.setDividerLocation(0.0);
split2.setDividerLocation(1.0);
// Uncomment the rest to make it work.
/*Object ui = split.getUI();
if(ui instanceof javax.swing.plaf.basic.BasicSplitPaneUI)
try {
java.lang.reflect.Method set_keep_hidden =
javax.swing.plaf.basic.BasicSplitPaneUI.class.getDeclaredMethod(
"setKeepHidden", new Class[] { boolean.class });
set_keep_hidden.setAccessible(true);
set_keep_hidden.invoke(ui, new Object[] { new Boolean(true) });
set_keep_hidden.invoke(split2.getUI(), new Object[] { new Boolean(true) });
}
catch(Exception e) { }*/
}
}
---------- END SOURCE ----------
This is a duplicate of 5006095, but this will really be needed once illegal reflective access is enforced.
Currently, reflection can be use to access javax.swing.plaf.basic.BasicSplitPaneUI.setKeepHidden(boolean) and javax.swing.plaf.basic.BasicSplitPaneUI.getKeepHidden() .
Since this will not be allowed in the future, there needs to be a way to get and set the "keep hidden" property of split panes. Although this may not be available depending on Look & Feel, JSplitPane.setOneTouchExpandable(boolean) is provided and the same applies.
JUSTIFICATION :
If the user fully closes or opens a split pane and closes an application, the application should be able to restore that fully closed or open state the next time the it is opened.
It also may be useful to initialize a split pane as fully open or closed if the functionality of one side is currently inactive, and to automatically pop it open when it becomes active.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Would like to see
boolean JSplitPane.getKeepHidden()
and
JSplitPane.setKeepHidden(boolean)
---------- BEGIN SOURCE ----------
/* Run test case then resize frame. Split panes do not stay open/closed.
Uncomment reflection code to enable this behavior. */
import javax.swing.*;
import java.awt.*;
public class JSplitPaneIssue {
public static void main(String args[]) {
JFrame frame = new JFrame();
frame.getContentPane().setLayout(new GridLayout(1, 2));
JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
split.setOneTouchExpandable(true);
split.setResizeWeight(.5);
split.setTopComponent(new JLabel("top"));
split.setBottomComponent(new JLabel("bottom"));
frame.getContentPane().add(split);
JSplitPane split2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
split2.setOneTouchExpandable(true);
split2.setResizeWeight(.5);
split2.setTopComponent(new JLabel("top2"));
split2.setBottomComponent(new JLabel("bottom2"));
frame.getContentPane().add(split2);
frame.setSize(400, 400);
frame.setVisible(true);
split.setDividerLocation(0.0);
split2.setDividerLocation(1.0);
// Uncomment the rest to make it work.
/*Object ui = split.getUI();
if(ui instanceof javax.swing.plaf.basic.BasicSplitPaneUI)
try {
java.lang.reflect.Method set_keep_hidden =
javax.swing.plaf.basic.BasicSplitPaneUI.class.getDeclaredMethod(
"setKeepHidden", new Class[] { boolean.class });
set_keep_hidden.setAccessible(true);
set_keep_hidden.invoke(ui, new Object[] { new Boolean(true) });
set_keep_hidden.invoke(split2.getUI(), new Object[] { new Boolean(true) });
}
catch(Exception e) { }*/
}
}
---------- END SOURCE ----------