⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basicsplitpaneui.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     * @return The preferred height of the component.     */    protected int getPreferredSizeOfComponent(Component c)    {      Dimension dims = c.getPreferredSize();      if (dims != null)        return dims.height;      return 0;    }    /**     * This method returns the current height of the component.     *     * @param c The component to measure.     *     * @return The current height of the component.     */    protected int getSizeOfComponent(Component c)    {      return c.getHeight();    }    /**     * This method returns the minimum layout size. The minimum height is the     * sum of all the components' minimum heights. The minimum width is the     * maximum of all the  components' minimum widths.     *     * @param container The container to measure.     *     * @return The minimum size.     */    public Dimension minimumLayoutSize(Container container)    {      if (container instanceof JSplitPane)        {          JSplitPane split = (JSplitPane) container;          Insets insets = container.getInsets();          int height = 0;          int width = 0;          for (int i = 0; i < components.length; i++)            {              if (components[i] == null)                continue;              Dimension dims = components[i].getMinimumSize();              if (dims != null)                {                  height += dims.height;                  width = Math.max(width, dims.width);                }            }          return new Dimension(width, height);        }      return null;    }    /**     * This method returns the preferred layout size. The preferred height is     * the sum of all the components'  preferred heights. The preferred width     * is the maximum of  all the components' preferred widths.     *     * @param container The container to measure.     *     * @return The preferred size.     */    public Dimension preferredLayoutSize(Container container)    {      if (container instanceof JSplitPane)        {          JSplitPane split = (JSplitPane) container;          Insets insets = container.getInsets();          int height = 0;          int width = 0;          for (int i = 0; i < components.length; i++)            {              if (components[i] == null)                continue;              Dimension dims = components[i].getPreferredSize();              if (dims != null)                {                  height += dims.height;                  width = Math.max(width, dims.width);                }            }          return new Dimension(width, height);        }      return null;    }    /**     * This method sets the bounds of the given component. The y coordinate is     * the location given. The x coordinate is the left inset. The height is     * the size given. The width is the container size minus the left and     * right inset.     *     * @param c The component to set bounds for.     * @param size The height.     * @param location The y coordinate.     * @param insets The insets to use.     * @param containerSize The container's size.     */    protected void setComponentToSize(Component c, int size, int location,                                      Insets insets, Dimension containerSize)    {      int y = location;      int x = insets.left;      int h = size;      int w = containerSize.width - insets.left - insets.right;      c.setBounds(x, y, w, h);    }    /**     * This method returns the minimum height of the component at the given     * index.     *     * @param index The index of the component to check.     *     * @return The minimum height of the given component.     */    int minimumSizeOfComponent(int index)    {      Dimension dims = components[index].getMinimumSize();      if (dims != null)        return dims.height;      else        return 0;    }  }  /**   * This class handles FocusEvents from the JComponent.   *   * @specnote Apparently this class was intended to be protected,   *           but was made public by a compiler bug and is now   *           public for compatibility.   */  public class FocusHandler extends FocusAdapter  {    /**     * This method is called when the JSplitPane gains focus.     *     * @param ev The FocusEvent.     */    public void focusGained(FocusEvent ev)    {      // FIXME: implement.    }    /**     * This method is called when the JSplitPane loses focus.     *     * @param ev The FocusEvent.     */    public void focusLost(FocusEvent ev)    {      // FIXME: implement.    }  }  /**   * This is a deprecated class. It is supposed to be used for handling down   * and right key presses.   *   * @specnote Apparently this class was intended to be protected,   *           but was made public by a compiler bug and is now   *           public for compatibility.   */  public class KeyboardDownRightHandler implements ActionListener  {    /**     * This method is called when the down or right keys are pressed.     *     * @param ev The ActionEvent     */    public void actionPerformed(ActionEvent ev)    {      // FIXME: implement.    }  }  /**   * This is a deprecated class. It is supposed to be used for handling end   * key presses.   *   * @specnote Apparently this class was intended to be protected,   *           but was made public by a compiler bug and is now   *           public for compatibility.   */  public class KeyboardEndHandler implements ActionListener  {    /**     * This method is called when the end key is pressed.     *     * @param ev The ActionEvent.     */    public void actionPerformed(ActionEvent ev)    {      // FIXME: implement.    }  }  /**   * This is a deprecated class. It is supposed to be used for handling home   * key presses.   *   * @specnote Apparently this class was intended to be protected,   *           but was made public by a compiler bug and is now   *           public for compatibility.   */  public class KeyboardHomeHandler implements ActionListener  {    /**     * This method is called when the home key is pressed.     *     * @param ev The ActionEvent.     */    public void actionPerformed(ActionEvent ev)    {      // FIXME: implement.    }  }  /**   * This is a deprecated class. It is supposed to be used for handling resize   * toggles.   *   * @specnote Apparently this class was intended to be protected,   *           but was made public by a compiler bug and is now   *           public for compatibility.   */  public class KeyboardResizeToggleHandler implements ActionListener  {    /**     * This method is called when a resize is toggled.     *     * @param ev The ActionEvent.     */    public void actionPerformed(ActionEvent ev)    {      // FIXME: implement.    }  }  /**   * This is a deprecated class. It is supposed to be used for handler up and   * left key presses.   *   * @specnote Apparently this class was intended to be protected,   *           but was made public by a compiler bug and is now   *           public for compatibility.   */  public class KeyboardUpLeftHandler implements ActionListener  {    /**     * This method is called when the left or up keys are pressed.     *     * @param ev The ActionEvent.     */    public void actionPerformed(ActionEvent ev)    {      // FIXME: implement.    }  }  /**   * This helper class handles PropertyChangeEvents from the JSplitPane. When   * a property changes, this will update the UI accordingly.   *   * @specnote Apparently this class was intended to be protected,   *           but was made public by a compiler bug and is now   *           public for compatibility.   */  public class PropertyHandler implements PropertyChangeListener  {    /**     * This method is called whenever one of the JSplitPane's properties     * change.     *     * @param e DOCUMENT ME!     */    public void propertyChange(PropertyChangeEvent e)    {      if (e.getPropertyName().equals(JSplitPane.DIVIDER_SIZE_PROPERTY))        {          int newSize = splitPane.getDividerSize();          int[] tmpSizes = layoutManager.getSizes();          dividerSize = tmpSizes[2];          int newSpace = newSize - tmpSizes[2];          tmpSizes[2] = newSize;          tmpSizes[0] += newSpace / 2;          tmpSizes[1] += newSpace / 2;                layoutManager.setSizes(tmpSizes);        }      else if (e.getPropertyName().equals(JSplitPane.ORIENTATION_PROPERTY))        {          int max = layoutManager.getAvailableSize(splitPane.getSize(),                                                   splitPane.getInsets());          int dividerLoc = getDividerLocation(splitPane);          double prop = ((double) dividerLoc) / max;          resetLayoutManager();          if (prop <= 1 && prop >= 0)            splitPane.setDividerLocation(prop);        }      layoutManager.layoutContainer(splitPane);      splitPane.repaint();      // Don't have to deal with continuous_layout - only      // necessary in dragging modes (and it's checked      // every time you drag there)      // Don't have to deal with resize_weight (as there      // will be no extra space associated with this      // event - the changes to the weighting will      // be taken into account the next time the      // sizes change.)      // Don't have to deal with divider_location      // The method in JSplitPane calls our setDividerLocation      // so we'll know about those anyway.      // Don't have to deal with last_divider_location      // Although I'm not sure why, it doesn't seem to      // have any effect on Sun's JSplitPane.      // one_touch_expandable changes are dealt with      // by our divider.    }  }  /** The location of the divider when dragging began. */  protected int beginDragDividerLocation;  /** The size of the divider while dragging. */  protected int dividerSize;  /** The location where the last drag location ended. */  transient int lastDragLocation = -1;  /** The distance the divider is moved when moved by keyboard actions. */  // Sun defines this as 3  protected static int KEYBOARD_DIVIDER_MOVE_OFFSET = 3;  /** The divider that divides this JSplitPane. */  protected BasicSplitPaneDivider divider;  /** The listener that listens for PropertyChangeEvents from the JSplitPane. */  protected PropertyChangeListener propertyChangeListener;  /** The JSplitPane's focus handler. */  protected FocusListener focusListener;  /** @deprecated The handler for down and right key presses. */  protected ActionListener keyboardDownRightListener;  /** @deprecated The handler for end key presses. */  protected ActionListener keyboardEndListener;  /** @deprecated The handler for home key presses. */  protected ActionListener keyboardHomeListener;  /** @deprecated The handler for toggling resizes. */  protected ActionListener keyboardResizeToggleListener;  /** @deprecated The handler for up and left key presses. */  protected ActionListener keyboardUpLeftListener;  /** The JSplitPane's current layout manager. */  protected BasicHorizontalLayoutManager layoutManager;  /** @deprecated The divider resize toggle key. */  protected KeyStroke dividerResizeToggleKey;  /** @deprecated The down key. */  protected KeyStroke downKey;  /** @deprecated The end key. */  protected KeyStroke endKey;  /** @deprecated The home key. */  protected KeyStroke homeKey;  /** @deprecated The left key. */  protected KeyStroke leftKey;  /** @deprecated The right key. */  protected KeyStroke rightKey;  /** @deprecated The up key. */  protected KeyStroke upKey;  /** Set to true when dragging heavy weight components. */  protected boolean draggingHW;  /**   * The constraints object used when adding the non-continuous divider to the   * JSplitPane.   */  protected static final String NON_CONTINUOUS_DIVIDER    = "nonContinuousDivider";  /** The dark divider used when dragging in non-continuous layout mode. */  protected Component nonContinuousLayoutDivider;  /** The JSplitPane that this UI draws. */  protected JSplitPane splitPane;  /**   * Creates a new BasicSplitPaneUI object.   */  public BasicSplitPaneUI()  {    // Nothing to do here.  }  /**   * This method creates a new BasicSplitPaneUI for the given JComponent.   *   * @param x The JComponent to create a UI for.   *   * @return A new BasicSplitPaneUI.   */  public static ComponentUI createUI(JComponent x)  {    return new BasicSplitPaneUI();  }  /**   * This method installs the BasicSplitPaneUI for the given JComponent.   *   * @param c The JComponent to install the UI for.   */  public void installUI(JComponent c)  {    if (c instanceof JSplitPane)      {        splitPane = (JSplitPane) c;        installDefaults();        installListeners();        installKeyboardActions();      }  }  /**   * This method uninstalls the BasicSplitPaneUI for the given JComponent.   *   * @param c The JComponent to uninstall the UI for.   */  public void uninstallUI(JComponent c)  {    uninstallKeyboardActions();    uninstallListeners();    uninstallDefaults();    splitPane = null;  }  /**   * This method installs the defaults given by the Look and Feel.   */  protected void installDefaults()  {    LookAndFeel.installColors(splitPane, "SplitPane.background",                              "SplitPane.foreground");    LookAndFeel.installBorder(splitPane, "SplitPane.border");    divider = createDefaultDivider();    resetLayoutManager();    nonContinuousLayoutDivider = createDefaultNonContinuousLayoutDivider();    splitPane.add(divider, JSplitPane.DIVIDER);    // There is no need to add the nonContinuousLayoutDivider    splitPane.setDividerSize(UIManager.getInt("SplitPane.dividerSize"));    splitPane.setOpaque(true);  }  /**   * This method uninstalls the defaults and nulls any objects created during   * install.   */  protected void uninstallDefaults()  {    layoutManager = null;    splitPane.remove(divider);    divider = null;    nonContinuousLayoutDivider = null;    splitPane.setBackground(null);    splitPane.setBorder(null);  }  /**   * This method installs the listeners needed for this UI to function.   */  protected void installListeners()  {    propertyChangeListener = createPropertyChangeListener();    focusListener = createFocusListener();    splitPane.addPropertyChangeListener(propertyChangeListener);    splitPane.addFocusListener(focusListener);  }  /**   * This method uninstalls all listeners registered for the UI.   */  protected void uninstallListeners()  {    splitPane.removePropertyChangeListener(propertyChangeListener);    splitPane.removeFocusListener(focusListener);    focusListener = null;    propertyChangeListener = null;  }  /**   * This method installs the keyboard actions for the JSplitPane.   */  protected void installKeyboardActions()  {    // FIXME: implement.  }  /**   * This method reverses the work done in installKeyboardActions.   */  protected void uninstallKeyboardActions()  {    // FIXME: implement.  }  /**   * This method creates a new PropertyChangeListener.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -