javax.swing.JComboBox.getHeight()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(11.9k)|赞(0)|评价(0)|浏览(126)

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

JComboBox.getHeight介绍

暂无

代码示例

代码示例来源:origin: leMaik/swing-material

@Override
protected Rectangle computePopupBounds(int px, int py, int pw, int ph) {
  return super.computePopupBounds(px, py - comboBox.getHeight() + 10,
      (int) Math.max(comboBox.getPreferredSize().getWidth(), pw), ph);
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/openide

public void layoutContainer(Container parent) {
    super.layoutContainer (parent);
    if (editor != null) {
      java.awt.Rectangle r = rectangleForCurrentValue();
      r.x = 0;
      r.y = 0;
      r.height = comboBox.getHeight();
      editor.setBounds (r);
    }
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdpary-non-maven/openide

public void layoutContainer(Container parent) {
    super.layoutContainer (parent);
    if (editor != null) {
      java.awt.Rectangle r = rectangleForCurrentValue();
      r.x = 0;
      r.y = 0;
      r.height = comboBox.getHeight();
      editor.setBounds (r);
    }
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/skinlf

/**
 * Description of the Method
 *
 * @return   Description of the Returned Value
 */
protected Rectangle rectangleForCurrentValue() {
 int width = comboBox.getWidth();
 int height = comboBox.getHeight();
 Insets insets = getInsets();
 return new Rectangle(insets.left, insets.top,
            width - (insets.left + insets.right),
            height - (insets.top + insets.bottom));
}

代码示例来源:origin: org.icepdf.os/icepdf-viewer

public JComboBox buildZoomCombBox() {
  // Get the properties manager in preparation for trying to get the zoom levels
  doubleCheckPropertiesManager();
  // Assign any different zoom ranges from the properties file if possible
  zoomLevels = PropertiesManager.checkAndStoreFloatArrayProperty(propertiesManager,
      PropertiesManager.PROPERTY_ZOOM_RANGES,
      zoomLevels);
  JComboBox tmp = new JComboBox();
  tmp.setToolTipText(messageBundle.getString("viewer.toolbar.zoom.tooltip"));
  tmp.setPreferredSize(new Dimension(75, tmp.getHeight()));
  for (float zoomLevel : zoomLevels)
    tmp.addItem(NumberFormat.getPercentInstance().format(zoomLevel));
  tmp.setEditable(true);
  if (viewerController != null)
    viewerController.setZoomComboBox(tmp, zoomLevels);
  return tmp;
}

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

comboBox.addActionListener(new ActionListener() {
   @Override
   public void actionPerformed(ActionEvent e) {
     JComboBox combo = (JComboBox) e.getSource();
     int y = MouseInfo.getPointerInfo().getLocation().y - combo.getLocationOnScreen().y;
     int item =  y / combo.getHeight();
     ((CheckBoxRenderer) combo.getRenderer()).selected[item] = !((CheckBoxRenderer) combo.getRenderer()).selected[item];
   }
 });

代码示例来源:origin: org.swinglabs.swingx/swingx-all

/**
 * Do the adjustment on the specified popupComponent immediately before
 * it is displayed.
 */
private void fixPopupLocation(JComponent popupComponent) {
  // we only need to fix Apple's aqua look and feel
  if(popupComponent.getClass().getName().indexOf("apple.laf") != 0) {
    return;
  }
  
  // put the popup right under the combo box so it looks like a
  // normal Aqua combo box
  Point comboLocationOnScreen = comboBox.getLocationOnScreen();
  int comboHeight = comboBox.getHeight();
  int popupY = comboLocationOnScreen.y + comboHeight;
  
  // ...unless the popup overflows the screen, in which case we put it
  // above the combobox
  Rectangle screenBounds = new ScreenGeometry(comboBox).getScreenBounds();
  int popupHeight = popupComponent.getPreferredSize().height;
  if(comboLocationOnScreen.y + comboHeight + popupHeight > screenBounds.x + screenBounds.height) {
    popupY = comboLocationOnScreen.y - popupHeight;
  }
  
  popupComponent.setLocation(comboLocationOnScreen.x, popupY);
}

代码示例来源:origin: org.codehaus.jtstand/jtstand-desktop

/**
 * Do the adjustment on the specified popupComponent immediately before
 * it is displayed.
 */
private void fixPopupLocation(JComponent popupComponent) {
  // we only need to fix Apple's aqua look and feel
  if(popupComponent.getClass().getName().indexOf("apple.laf") != 0) {
    return;
  }
  
  // put the popup right under the combo box so it looks like a
  // normal Aqua combo box
  Point comboLocationOnScreen = comboBox.getLocationOnScreen();
  int comboHeight = comboBox.getHeight();
  int popupY = comboLocationOnScreen.y + comboHeight;
  
  // ...unless the popup overflows the screen, in which case we put it
  // above the combobox
  Rectangle screenBounds = new ScreenGeometry(comboBox).getScreenBounds();
  int popupHeight = popupComponent.getPreferredSize().height;
  if(comboLocationOnScreen.y + comboHeight + popupHeight > screenBounds.x + screenBounds.height) {
    popupY = comboLocationOnScreen.y - popupHeight;
  }
  
  popupComponent.setLocation(comboLocationOnScreen.x, popupY);
}

代码示例来源:origin: net.java.dev.glazedlists/glazedlists_java15

/**
   * Do the adjustment on the specified popupComponent immediately before
   * it is displayed.
   */
  private void fixPopupLocation(JComponent popupComponent) {
    // we only need to fix Apple's aqua look and feel
    if(popupComponent.getClass().getName().indexOf("apple.laf") != 0) {
      return;
    }

    // put the popup right under the combo box so it looks like a
    // normal Aqua combo box
    Point comboLocationOnScreen = comboBox.getLocationOnScreen();
    int comboHeight = comboBox.getHeight();
    int popupY = comboLocationOnScreen.y + comboHeight;

    // ...unless the popup overflows the screen, in which case we put it
    // above the combobox
    Rectangle screenBounds = new ScreenGeometry(comboBox).getScreenBounds();
    int popupHeight = popupComponent.getPreferredSize().height;
    if(comboLocationOnScreen.y + comboHeight + popupHeight > screenBounds.x + screenBounds.height) {
      popupY = comboLocationOnScreen.y - popupHeight;
    }

    popupComponent.setLocation(comboLocationOnScreen.x, popupY);
  }
}

代码示例来源:origin: com.haulmont.thirdparty/glazedlists

/**
   * Do the adjustment on the specified popupComponent immediately before
   * it is displayed.
   */
  private void fixPopupLocation(JComponent popupComponent) {
    // we only need to fix Apple's aqua look and feel
    if(popupComponent.getClass().getName().indexOf("apple.laf") != 0) {
      return;
    }

    // put the popup right under the combo box so it looks like a
    // normal Aqua combo box
    Point comboLocationOnScreen = comboBox.getLocationOnScreen();
    int comboHeight = comboBox.getHeight();
    int popupY = comboLocationOnScreen.y + comboHeight;

    // ...unless the popup overflows the screen, in which case we put it
    // above the combobox
    Rectangle screenBounds = new ScreenGeometry(comboBox).getScreenBounds();
    int popupHeight = popupComponent.getPreferredSize().height;
    if(comboLocationOnScreen.y + comboHeight + popupHeight > screenBounds.x + screenBounds.height) {
      popupY = comboLocationOnScreen.y - popupHeight;
    }

    popupComponent.setLocation(comboLocationOnScreen.x, popupY);
  }
}

代码示例来源:origin: net.java.dev.glazedlists/glazedlists_java16

/**
   * Do the adjustment on the specified popupComponent immediately before
   * it is displayed.
   */
  private void fixPopupLocation(JComponent popupComponent) {
    // we only need to fix Apple's aqua look and feel
    if(popupComponent.getClass().getName().indexOf("apple.laf") != 0) {
      return;
    }

    // put the popup right under the combo box so it looks like a
    // normal Aqua combo box
    Point comboLocationOnScreen = comboBox.getLocationOnScreen();
    int comboHeight = comboBox.getHeight();
    int popupY = comboLocationOnScreen.y + comboHeight;

    // ...unless the popup overflows the screen, in which case we put it
    // above the combobox
    Rectangle screenBounds = new ScreenGeometry(comboBox).getScreenBounds();
    int popupHeight = popupComponent.getPreferredSize().height;
    if(comboLocationOnScreen.y + comboHeight + popupHeight > screenBounds.x + screenBounds.height) {
      popupY = comboLocationOnScreen.y - popupHeight;
    }

    popupComponent.setLocation(comboLocationOnScreen.x, popupY);
  }
}

代码示例来源:origin: tmyroadctfig/swingx

/**
 * Do the adjustment on the specified popupComponent immediately before
 * it is displayed.
 */
private void fixPopupLocation(JComponent popupComponent) {
  // we only need to fix Apple's aqua look and feel
  if(popupComponent.getClass().getName().indexOf("apple.laf") != 0) {
    return;
  }
  
  // put the popup right under the combo box so it looks like a
  // normal Aqua combo box
  Point comboLocationOnScreen = comboBox.getLocationOnScreen();
  int comboHeight = comboBox.getHeight();
  int popupY = comboLocationOnScreen.y + comboHeight;
  
  // ...unless the popup overflows the screen, in which case we put it
  // above the combobox
  Rectangle screenBounds = new ScreenGeometry(comboBox).getScreenBounds();
  int popupHeight = popupComponent.getPreferredSize().height;
  if(comboLocationOnScreen.y + comboHeight + popupHeight > screenBounds.x + screenBounds.height) {
    popupY = comboLocationOnScreen.y - popupHeight;
  }
  
  popupComponent.setLocation(comboLocationOnScreen.x, popupY);
}

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

@Override
protected Rectangle rectangleForCurrentValue() {
  int width = this.comboBox.getWidth();
  int height = this.comboBox.getHeight();
  Insets insets = this.layoutInsets;
  int buttonWidth = SubstanceSizeUtils
      .getScrollBarWidth(SubstanceSizeUtils
          .getComponentFontSize(comboBox));
  if (this.comboBox.getComponentOrientation().isLeftToRight()) {
    return new Rectangle(insets.left, insets.top, width - insets.left
        - insets.right - buttonWidth, height - insets.top
        - insets.bottom);
  } else {
    int startX = insets.left + buttonWidth;
    return new Rectangle(startX, insets.top, width - startX
        - insets.right, height - insets.top - insets.bottom);
  }
}

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

@Override
protected Rectangle rectangleForCurrentValue() {
  int width = this.comboBox.getWidth();
  int height = this.comboBox.getHeight();
  Insets insets = this.layoutInsets;
  int buttonWidth = SubstanceSizeUtils
      .getScrollBarWidth(SubstanceSizeUtils
          .getComponentFontSize(comboBox));
  if (this.comboBox.getComponentOrientation().isLeftToRight()) {
    return new Rectangle(insets.left, insets.top, width - insets.left
        - insets.right - buttonWidth, height - insets.top
        - insets.bottom);
  } else {
    int startX = insets.left + buttonWidth;
    return new Rectangle(startX, insets.top, width - startX
        - insets.right, height - insets.top - insets.bottom);
  }
}

代码示例来源:origin: com.synaptix/SynaptixTattoo

height = comboBox.getHeight();

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/toniclf

/**
 * Returns the area that is reserved for drawing the currently selected item.
 */
protected Rectangle rectangleForCurrentValue()
{
  int width= comboBox.getWidth();
  int height= comboBox.getHeight();
  Insets insets= getInsets();
  int buttonSize= height - (insets.top + insets.bottom);
  if (arrowButton != null)
  {
    buttonSize= arrowButton.getWidth();
  }
  if (isLeftToRight(comboBox))
  {
    return new Rectangle(
      insets.left,
      insets.top,
      width - (insets.left + insets.right + buttonSize),
      height - (insets.top + insets.bottom));
  }
  else
  {
    return new Rectangle(
      insets.left + buttonSize,
      insets.top,
      width - (insets.left + insets.right + buttonSize),
      height - (insets.top + insets.bottom));
  }
}

代码示例来源:origin: com.github.arnabk/pgslookandfeel

protected Rectangle rectangleForCurrentValue() {
  int width = comboBox.getWidth();
  int height = comboBox.getHeight();
  Insets insets = getInsets();
  int buttonSize = height - (insets.top + insets.bottom);
  if (arrowButton != null) {
    if (arrowButton instanceof PgsComboBoxButtonUI) {
      Icon icon = ((PgsComboBoxButtonUI) arrowButton).getComboIcon();
      Insets buttonInsets = arrowButton.getInsets();
      buttonSize = icon.getIconWidth() + buttonInsets.left +
          buttonInsets.right;
    } else {
      buttonSize = arrowButton.getWidth();
    }
  }
  if(PgsUtils.isLeftToRight(comboBox)) {
    return new Rectangle(insets.left+2, insets.top+1,
               width - (insets.left + insets.right + buttonSize + 4),
               height - (insets.top + insets.bottom)-2);
  } else {
    return new Rectangle(insets.left + buttonSize + 2, insets.top+1,
               width - (insets.left + insets.right + buttonSize + 4),
               height - (insets.top + insets.bottom)-2);
  }
}

代码示例来源:origin: com.github.arnabk/pgslookandfeel

public void layoutComboBox(Container parent, MetalComboBoxLayoutManager manager) {
  if (arrowButton != null) {
    if (arrowButton instanceof PgsComboBoxButtonUI) {
      Icon icon = ((PgsComboBoxButtonUI) arrowButton).getComboIcon();
      Insets buttonInsets = arrowButton.getInsets();
      Insets insets = comboBox.getInsets();
      int buttonWidth = icon.getIconWidth() + buttonInsets.left +
          buttonInsets.right;
      arrowButton.setBounds(
          PgsUtils.isLeftToRight(comboBox)
              ? (comboBox.getWidth() - insets.right - buttonWidth)
              : insets.left+2,
          insets.top + 2, buttonWidth - 2,
          comboBox.getHeight() - insets.top - insets.bottom - 4);
    } else {
      Insets insets = comboBox.getInsets();
      int width = comboBox.getWidth();
      int height = comboBox.getHeight();
      arrowButton.setBounds(
          insets.left, insets.top,
          width - (insets.left + insets.right),
          height - (insets.top + insets.bottom));
    }
  }
  if (editor != null) {
    Rectangle cvb = rectangleForCurrentValue();
    editor.setBounds(cvb);
  }
}

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

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

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

int height = cb.getHeight();

相关文章

JComboBox类方法