本文整理了Java中javax.swing.JComboBox.getLocationOnScreen()
方法的一些代码示例,展示了JComboBox.getLocationOnScreen()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComboBox.getLocationOnScreen()
方法的具体详情如下:
包路径:javax.swing.JComboBox
类名称: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);
}
}
内容来源于网络,如有侵权,请联系作者删除!