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

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

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

JComboBox.getLocationOnScreen介绍

暂无

代码示例

代码示例来源: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: 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.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: 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: 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: 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: 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);
  }
}

相关文章

JComboBox类方法