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

📄 jtoolbar.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
  } // JToolBar()  /**   * This method creates a new JToolBar with the given orientation and  no   * name.   *   * @param orientation JToolBar orientation (HORIZONTAL or VERTICAL)   */  public JToolBar(int orientation)  {    this(null, orientation);  } // JToolBar()  /**   * This method creates a new JToolBar object with the given name and   * horizontal orientation.   *   * @param name Name assigned to undocked tool bar.   */  public JToolBar(String name)  {    this(name, HORIZONTAL);  } // JToolBar()  /**   * This method creates a new JToolBar object with the given name and   * orientation.   *   * @param name Name assigned to undocked tool bar.   * @param orientation JToolBar orientation (HORIZONTAL or VERTICAL)   */  public JToolBar(String name, int orientation)  {    setName(name);    setOrientation(orientation);    setLayout(new DefaultToolBarLayout());    revalidate();    updateUI();  } // JToolBar()  /**   * This method adds a new JButton that performs the given Action to the   * JToolBar.   *   * @param action The Action to add to the JToolBar.   *   * @return The JButton that wraps the Action.   */  public JButton add(Action action)  {    JButton b = createActionComponent(action);    add(b);    return b;  } // add()  /**   * This method paints the border if the borderPainted property is true.   *   * @param graphics The graphics object to paint with.   */  protected void paintBorder(Graphics graphics)  {    if (paintBorder && isFloatable())      super.paintBorder(graphics);  } // paintBorder()  /**   * This method returns the UI class used to paint this JToolBar.   *   * @return The UI class for this JToolBar.   */  public ToolBarUI getUI()  {    return (ToolBarUI) ui;  } // getUI()  /**   * This method sets the UI used with the JToolBar.   *   * @param ui The UI used with the JToolBar.   */  public void setUI(ToolBarUI ui)  {    super.setUI(ui);  } // setUI()  /**   * This method resets the UI used to the Look and Feel defaults.   */  public void updateUI()  {    setUI((ToolBarUI) UIManager.getUI(this));    revalidate();    repaint();  } // updateUI()  /**   * This method returns the String identifier for the UI class to the used   * with the JToolBar.   *   * @return The String identifier for the UI class.   */  public String getUIClassID()  {    return "ToolBarUI";  } // getUIClassID()  /**   * This method sets the rollover property for the JToolBar. In rollover   * mode, JButtons inside the JToolBar will only display their borders when   * the mouse is moving over them.   *   * @param b The new rollover property.   */  public void setRollover(boolean b)  {    if (b != rollover)      {	rollover = b;	firePropertyChange("rollover", ! rollover, rollover);	revalidate();	repaint();      }  }  /**   * This method returns the rollover property.   *   * @return The rollover property.   */  public boolean isRollover()  {    return rollover;  }  /**   * This method returns the index of the given component.   *   * @param component The component to find.   *   * @return The index of the given component.   */  public int getComponentIndex(Component component)  {    Component[] components = getComponents();    if (components == null)      return -1;    for (int i = 0; i < components.length; i++)      if (components[i] == component)	return i;    return -1;  } // getComponentIndex()  /**   * This method returns the component at the given index.   *   * @param index The index of the component.   *   * @return The component at the given index.   */  public Component getComponentAtIndex(int index)  {    return getComponent(index);  } // getComponentAtIndex()  /**   * This method returns the margin property.   *   * @return The margin property.   */  public Insets getMargin()  {    return margin;  } // getMargin()  /**   * This method sets the margin property. The margin property determines the   * extra space between the children components of the JToolBar and the   * border.   *   * @param margin The margin property.   */  public void setMargin(Insets margin)  {    if ((this.margin != null && margin == null)        || (this.margin == null && margin != null)        || (margin != null && this.margin != null        && (margin.left != this.margin.left        || margin.right != this.margin.right || margin.top != this.margin.top        || margin.bottom != this.margin.bottom)))      {	Insets oldMargin = this.margin;	this.margin = margin;	firePropertyChange("margin", oldMargin, this.margin);	revalidate();	repaint();      }  } // setMargin()  /**   * This method returns the borderPainted property.   *   * @return The borderPainted property.   */  public boolean isBorderPainted()  {    return paintBorder;  } // isBorderPainted()  /**   * This method sets the borderPainted property. If set to false, the border   * will not be painted.   *   * @param painted Whether the border will be painted.   */  public void setBorderPainted(boolean painted)  {    if (painted != paintBorder)      {	paintBorder = painted;	firePropertyChange("borderPainted", ! paintBorder,	                   paintBorder);	repaint();      }  } // setBorderPainted()  /**   * This method returns the floatable property.   *   * @return The floatable property.   */  public boolean isFloatable()  {    return floatable;  } // isFloatable()  /**   * This method sets the floatable property. If set to false, the JToolBar   * cannot be dragged.   *   * @param floatable Whether the JToolBar can be dragged.   */  public void setFloatable(boolean floatable)  {    if (floatable != this.floatable)      {	this.floatable = floatable;	firePropertyChange("floatable", ! floatable, floatable);      }  } // setFloatable()  /**   * This method returns the orientation of the JToolBar.   *   * @return The orientation of the JToolBar.   */  public int getOrientation()  {    return orientation;  } // getOrientation()  /**   * This method sets the layout manager to be used with the JToolBar.   *   * @param mgr The Layout Manager used with the JToolBar.   */  public void setLayout(LayoutManager mgr)  {    super.setLayout(mgr);    revalidate();    repaint();  } // setLayout()  /**   * This method sets the orientation property for JToolBar.   *   * @param orientation The new orientation for JToolBar.   *   * @throws IllegalArgumentException If the orientation is not HORIZONTAL or   *         VERTICAL.   */  public void setOrientation(int orientation)  {    if (orientation != HORIZONTAL && orientation != VERTICAL)      throw new IllegalArgumentException(orientation                                         + " is not a legal orientation");    if (orientation != this.orientation)      {	int oldOrientation = this.orientation;	this.orientation = orientation;	firePropertyChange("orientation", oldOrientation, this.orientation);	revalidate();	repaint();      }  } // setOrientation()  /**   * This method adds a Separator of default size to the JToolBar.   */  public void addSeparator()  {    add(new Separator());  } // addSeparator()  /**   * This method adds a Separator with the given size to the JToolBar.   *   * @param size The size of the Separator.   */  public void addSeparator(Dimension size)  {    add(new Separator(size));  } // addSeparator()  /**   * This method is used to create JButtons which can be added to the JToolBar   * for the given action.   *   * @param action The action to create a JButton for.   *   * @return The JButton created from the action.   */  protected JButton createActionComponent(Action action)  {    return new JButton(action);  } // createActionComponent()  /**   * This method creates a pre-configured PropertyChangeListener which updates   * the control as changes are made to the Action. However, this is no   * longer the recommended way of adding Actions to Containers. As such,   * this method returns null.   *   * @param button The JButton to configure a PropertyChangeListener for.   *   * @return null.   */  protected PropertyChangeListener createActionChangeListener(JButton button)  {    // XXX: As specified, this returns null. But seems kind of strange, usually deprecated methods don't just return null, verify!    return null;  } // createActionChangeListener()  /**   * This method overrides Container's addImpl method. If a JButton is added,   * it is disabled.   *   * @param component The Component to add.   * @param constraints The Constraints placed on the component.   * @param index The index to place the Component at.   */  protected void addImpl(Component component, Object constraints, int index)  {    // XXX: Sun says disable button but test cases show otherwise.    super.addImpl(component, constraints, index);    // if we added a Swing Button then adjust this a little    if (component instanceof AbstractButton)      {        AbstractButton b = (AbstractButton) component;        b.setRolloverEnabled(rollover);      }  } // addImpl()  /**   * This method returns a String description of the JToolBar.   *   * @return A String description of the JToolBar.   */  protected String paramString()  {    return "JToolBar";  } // paramString()  /**   * getAccessibleContext   *   * @return AccessibleContext   */  public AccessibleContext getAccessibleContext()  {    if (accessibleContext == null)      accessibleContext = new AccessibleJToolBar();    return accessibleContext;  }}

⌨️ 快捷键说明

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