javax.swing.AbstractButton.getParent()方法的使用及代码示例

x33g5p2x  于2022-01-15 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(130)

本文整理了Java中javax.swing.AbstractButton.getParent()方法的一些代码示例,展示了AbstractButton.getParent()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractButton.getParent()方法的具体详情如下:
包路径:javax.swing.AbstractButton
类名称:AbstractButton
方法名:getParent

AbstractButton.getParent介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.api/org-netbeans-swing-plaf

private static boolean isFirst (AbstractButton b) {
  if (b.getParent() != null && b.getParent().getComponentCount() > 1) {
    //The grip is always component 0, so see if the button
    //is component 1
    return b == b.getParent().getComponent(1);
  } else {
    return false;
  }
}

代码示例来源:origin: com.github.insubstantial/substance

/**
 * Checks and answers if the specified button is in a scroll bar.
 * 
 * @param button
 *            the button to check
 * @return <code>true</code> if in scroll bar, <code>false</code> otherwise
 */
public static boolean isScrollBarButton(AbstractButton button) {
  Container parent = button.getParent();
  return (parent != null)
      && ((parent instanceof JScrollBar) || (parent.getParent() instanceof JScrollBar));
}

代码示例来源:origin: org.java.net.substance/substance

/**
 * Checks and answers if the specified button is in a scroll bar.
 * 
 * @param button
 *            the button to check
 * @return <code>true</code> if in scroll bar, <code>false</code> otherwise
 */
public static boolean isScrollBarButton(AbstractButton button) {
  Container parent = button.getParent();
  return (parent != null)
      && ((parent instanceof JScrollBar) || (parent.getParent() instanceof JScrollBar));
}

代码示例来源:origin: org.java.net.substance/substance

/**
 * Checks and answers if the specified button is in a combo box.
 * 
 * @param button
 *            the button to check
 * @return <code>true</code> if in combo box, <code>false</code> otherwise
 */
public static boolean isComboBoxButton(AbstractButton button) {
  Container parent = button.getParent();
  return (parent != null)
      && ((parent instanceof JComboBox) || (parent.getParent() instanceof JComboBox));
}

代码示例来源:origin: com.github.insubstantial/substance

/**
 * Checks and answers if the specified button is in a combo box.
 * 
 * @param button
 *            the button to check
 * @return <code>true</code> if in combo box, <code>false</code> otherwise
 */
public static boolean isComboBoxButton(AbstractButton button) {
  Container parent = button.getParent();
  return (parent != null)
      && ((parent instanceof JComboBox) || (parent.getParent() instanceof JComboBox));
}

代码示例来源:origin: com.github.insubstantial/substance

/**
 * Checks and answers if the specified button is in a spinner.
 * 
 * @param button
 *            the button to check
 * @return <code>true</code> if in spinner, <code>false</code> otherwise
 */
public static boolean isSpinnerButton(AbstractButton button) {
  Container parent = button.getParent();
  if (!(button instanceof SubstanceSpinnerButton))
    return false;
  return (parent != null)
      && ((parent instanceof JSpinner) || (parent.getParent() instanceof JSpinner));
}

代码示例来源:origin: org.java.net.substance/substance

/**
 * Checks and answers if the specified button is in a spinner.
 * 
 * @param button
 *            the button to check
 * @return <code>true</code> if in spinner, <code>false</code> otherwise
 */
public static boolean isSpinnerButton(AbstractButton button) {
  Container parent = button.getParent();
  if (!(button instanceof SubstanceSpinnerButton))
    return false;
  return (parent != null)
      && ((parent instanceof JSpinner) || (parent.getParent() instanceof JSpinner));
}

代码示例来源:origin: net.java.abeille/abeille

public void stateChanged(ChangeEvent e) {
    AbstractButton src = (AbstractButton) e.getSource();
    JPanel btn_panel = (JPanel) src.getParent();
    if (src.isSelected()) {
      btn_panel.setBackground(java.awt.Color.lightGray);
      btn_panel.setBorder(BorderFactory.createLineBorder(java.awt.Color.gray));
    }
    else {
      btn_panel.setBackground(javax.swing.UIManager.getColor("control"));
      btn_panel.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));
    }
  }
});

代码示例来源:origin: org.jfree/jcommon

/**
   * Disables the drawing of the border when the mouse leaves the button area.
   *
   * @param e  the mouse event.
   */
  public void mouseExited(final MouseEvent e) {
    if (e.getSource() instanceof AbstractButton) {
      final AbstractButton button = (AbstractButton) e.getSource();
      button.setBorderPainted(false);
      if (button.getParent() != null)
      {
//                button.getParent().repaint(button.getX(), button.getY(),
//                    button.getWidth(), button.getHeight());
        button.getParent().repaint();
      }
    }
  }

代码示例来源:origin: org.jfree/com.springsource.org.jfree

/**
   * Disables the drawing of the border when the mouse leaves the button area.
   *
   * @param e  the mouse event.
   */
  public void mouseExited(final MouseEvent e) {
    if (e.getSource() instanceof AbstractButton) {
      final AbstractButton button = (AbstractButton) e.getSource();
      button.setBorderPainted(false);
      if (button.getParent() != null)
      {
//                button.getParent().repaint(button.getX(), button.getY(),
//                    button.getWidth(), button.getHeight());
        button.getParent().repaint();
      }
    }
  }

代码示例来源:origin: jfree/jcommon

/**
   * Disables the drawing of the border when the mouse leaves the button area.
   *
   * @param e  the mouse event.
   */
  public void mouseExited(final MouseEvent e) {
    if (e.getSource() instanceof AbstractButton) {
      final AbstractButton button = (AbstractButton) e.getSource();
      button.setBorderPainted(false);
      if (button.getParent() != null)
      {
//                button.getParent().repaint(button.getX(), button.getY(),
//                    button.getWidth(), button.getHeight());
        button.getParent().repaint();
      }
    }
  }

代码示例来源:origin: net.sf.nimrod/nimrod-laf

public void refresh() {
 if ( papi != null && papi.getParent() != null ) {
  papi.getParent().repaint( papi.getX()-5, papi.getY()-5, 
               papi.getWidth()+10, papi.getHeight()+10);
 }
}

代码示例来源:origin: net.sf.nimrod/nimrod-laf

public void refresh() {
 if ( papi != null && papi.getParent() != null ) {
  papi.getParent().repaint( papi.getX()-5, papi.getY()-5, 
               papi.getWidth()+10, papi.getHeight()+10);
 }
}

代码示例来源:origin: stackoverflow.com

class ButtonGroupVisibilityToggleChange implements ButtonGroupToggleChange {

  public boolean toggle(ButtonGroup buttonGroup, boolean actualToggleState) {
    boolean nextVisibleState = !actualToggleState;
    Enumeration<AbstractButton> buttons = buttonGroup.getElements();
    while (buttons.hasMoreElements()) {
      AbstractButton abstractButton = buttons.nextElement();
      abstractButton.setVisible(nextVisibleState);
      Container parent = abstractButton.getParent();
      if (parent != null) {
        parent.revalidate();
      }
    }

    return nextVisibleState;
  }
}

代码示例来源:origin: net.sf.nimrod/nimrod-laf

protected void paintFocus( Graphics g, AbstractButton b,
                            Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
 if ( !b.isFocusPainted() || !oldOpaque ) {
  return;
 }
 if( b.getParent() instanceof JToolBar ) {
  return;  // No se pintael foco cuando estamos en una barra
 }
 
 NimRODUtils.paintFocus( g, 3,3, b.getWidth()-6, b.getHeight()-6, 2, 2, NimRODLookAndFeel.getFocusColor());
}

代码示例来源:origin: net.sf.nimrod/nimrod-laf

protected void paintFocus( Graphics g, AbstractButton b,
                            Rectangle viewRect, Rectangle textRect, Rectangle iconRect) {
 if ( !b.isFocusPainted() || !oldOpaque ) {
  return;
 }
 if ( b.getParent() instanceof JToolBar ) {
  return;  // No se pinta el foco cuando estamos en una barra
 }
 
 NimRODUtils.paintFocus( g, 3,3, b.getWidth()-6, b.getHeight()-6, 2, 2, NimRODLookAndFeel.getFocusColor());
}

代码示例来源:origin: com.jtattoo/JTattoo

protected void paintBackground(Graphics g, AbstractButton b) {
    if (b.isContentAreaFilled() && !(b.getParent() instanceof JMenuBar)) {
      Color backColor = b.getBackground();
      ButtonModel model = b.getModel();
      if (model.isEnabled()) {
        if (model.isPressed() && model.isArmed()) {
          backColor = ColorHelper.darker(backColor, 30);
        }
      } else {
        backColor = ColorHelper.brighter(AbstractLookAndFeel.getDisabledForegroundColor(), 80);
      }
      g.setColor(backColor);
      g.fillRect(0, 0, b.getWidth(), b.getHeight());
    }
  }
}

代码示例来源:origin: it.tidalwave.solidblue/it-tidalwave-netbeans-lookandfeel

@Override
protected void paintFocus (Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) 
 {
  if (!b.isFocusPainted() || !b.isOpaque()) 
   {
    return;
   }
  
  if (b.getParent() instanceof JToolBar) 
   {
    return; 
   }
  g.setColor(getFocusColor());
  g.drawRoundRect(2, 2, b.getWidth() - 6, b.getHeight() - 6, 5, 5);
  g.drawRoundRect(3, 3, b.getWidth() - 6, b.getHeight() - 6, 4, 4);
 }

代码示例来源:origin: it.tidalwave.netbeans/it-tidalwave-netbeans-lookandfeel

@Override
protected void paintFocus (Graphics g, AbstractButton b, Rectangle viewRect, Rectangle textRect, Rectangle iconRect) 
 {
  if (!b.isFocusPainted() || !b.isOpaque()) 
   {
    return;
   }
  
  if (b.getParent() instanceof JToolBar) 
   {
    return; 
   }
  g.setColor(getFocusColor());
  g.drawRoundRect(2, 2, b.getWidth() - 6, b.getHeight() - 6, 5, 5);
  g.drawRoundRect(3, 3, b.getWidth() - 6, b.getHeight() - 6, 4, 4);
 }

代码示例来源:origin: com.jtattoo/JTattoo

protected void paintBackground(Graphics g, AbstractButton b) {
    if (b.isContentAreaFilled() && !(b.getParent() instanceof JMenuBar)) {
      Color backColor = b.getBackground();
      ButtonModel model = b.getModel();
      if (model.isEnabled()) {
        if ((model.isPressed() && model.isArmed()) || model.isSelected()) {
          backColor = ColorHelper.darker(backColor, 10);
        }
      } else {
        backColor = ColorHelper.brighter(AbstractLookAndFeel.getDisabledForegroundColor(), 80);
      }
      g.setColor(backColor);
      g.fillRect(1, 1, b.getWidth() - 2, b.getHeight() - 2);
    }
  }
}

相关文章

微信公众号

最新文章

更多

AbstractButton类方法