Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6483561

add a method to JSplitPane which would just disables the bar and move actions

XMLWordPrintable

      J2SE Version (please include all output from java -version flag):

      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_08-b03)
      Java HotSpot(TM) Client VM (build 1.5.0_08-b03, mixed mode, sharing)


      Does this problem occur on J2SE 1.3, 1.4.x or 1.5? Yes / No (pick one)
      1.5, 1.6.0-beta-b59g


      Operating System Configuration Information (be specific):
      Windows XP SP2


      Hardware Configuration Information (be specific):
      Sony VAIO Laptop 2.8 GHz P4

      Bug Description:
      Related issues:
      http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4861969
      http://forum.java.sun.com/thread.jspa?threadID=287960&messageID=1128746
      http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6356769

      We have an dialog, where when the user gets to a certain state, we want to prevent them from adjusting the split in the JSplitPane. However, doing so causes unexpected behavior in other parts of our application.

      There needs to be some way to disable the moving of a split in a JSplitPane without messing up the UI. In the example code, click the button to disable / enable the split pane. Disabling a split pane is currently the only way to stop a user from being able to move the divider. However, doing so causes the changing of the cursor to the resize cursor (in the table) to fail. If changing how the AWT treats disabling of components (as in 4861969) is a bit too draconian, then perhaps add a method to JSplitPane which would just disables the bar and move actions.

      Also evidenced in the example is that, although the split pane is disabled, there is no visual indication that this has occured. (6356769)


      Steps to Reproduce (be specific):

      import java.awt.BorderLayout;
      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;
      import javax.swing.JButton;
      import javax.swing.JCheckBox;
      import javax.swing.JFrame;
      import javax.swing.JPanel;
      import javax.swing.JScrollPane;
      import javax.swing.JSplitPane;
      import javax.swing.JTable;

      public class SplitPaneTest extends JFrame{

      private JSplitPane splitPane;

      public SplitPaneTest() {
      JPanel panel = new JPanel(new BorderLayout());
      JPanel p = new JPanel();
      JButton button = new JButton("Toggle Enabled");
      final JCheckBox box = new JCheckBox("Enabled?",button.isEnabled());
      box.setEnabled(false);
      button.addActionListener( new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      boolean b = splitPane.isEnabled();
      box.setSelected(!b);
      splitPane.setEnabled(!b);
      }
      });
      splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,new JPanel(),getTablePanel());
      p.add(button);
      p.add(box);
      panel.add(p,BorderLayout.NORTH);
      panel.add(splitPane,BorderLayout.CENTER);
      getContentPane().add(panel);
      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      setSize(400,400);
      setVisible(true);
      }
      private JPanel getTablePanel() {
      JPanel p = new JPanel(new BorderLayout());
      JTable table = new JTable(5,10);
      p.add(new JScrollPane(table));
      return p;
      }
      public static void main(String[] argv) {
      new SplitPaneTest();
      }

      }

            Unassigned Unassigned
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: