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

Allow double-click on JSplitPane divider to resetToPreferredSizes()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Won't Fix
    • Icon: P4 P4
    • None
    • 1.1.6, 1.2.0
    • client-libs



      Name: rm29839 Date: 06/10/98


      I would like to be able to have a JSplitPane call
      its resetToPreferredSizes() method if the user double clicks on the divider. This feature could be an option, like
      setOneTouchExpandable().

      I tried adding a MouseAdapter to implement this feature, but I ran into a couple of problems:

      1) If I add the MouseAdapter to the JSplitPane,
         the adapter only responds to a very narrow
         portion of the divider.

      2) If I add the MouseAdapter to the divider
         (to which there is no convenient access)
         I am no longer able to drag the divider.

      I used the following code to add the adapter to
      the divider.

      try {
        Component divider =
          ((java.awt.swing.plaf.basic.BasicSplitPaneUI)
          fSplitPane.getUI()).getDivider();
            
        divider.addMouseListener (new MouseAdapter() {
          public void mouseClicked (MouseEvent event)
          {
            if (event.getClickCount() == 2) {
              fSplitPane.resetToPreferredSizes();
              repaint(); // This shouldn't be necessary!
            } // if
          } // mouseClicked
        });
      } catch (ClassCastException e) {}
      (Review ID: 33435)
      ======================================================================

            svioletsunw Scott Violet (Inactive)
            rmandelsunw Ronan Mandel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: