本文整理了Java中javax.swing.JComboBox.getBounds()
方法的一些代码示例,展示了JComboBox.getBounds()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JComboBox.getBounds()
方法的具体详情如下:
包路径:javax.swing.JComboBox
类名称:JComboBox
方法名:getBounds
暂无
代码示例来源:origin: com.github.insubstantial/substance
/**
* Calculates the upper left location of the popup.
*
* @return The upper left location of the popup.
*/
private Point getPopupLocation() {
Dimension popupSize = this.comboBox.getSize();
Insets insets = this.getInsets();
// reduce the width of the scrollpane by the insets so that the popup
// is the same width as the combo box.
popupSize.setSize(popupSize.width - (insets.right + insets.left), this
.getPopupHeightForRowCount(this.comboBox.getMaximumRowCount()));
Rectangle popupBounds = this.computePopupBounds(0, this.comboBox
.getBounds().height, popupSize.width, popupSize.height);
Dimension scrollSize = popupBounds.getSize();
Point popupLocation = popupBounds.getLocation();
this.scroller.setMaximumSize(scrollSize);
this.scroller.setPreferredSize(scrollSize);
this.scroller.setMinimumSize(scrollSize);
this.list.revalidate();
return new Point(popupLocation.x, popupLocation.y);
}
代码示例来源:origin: com.synaptix/SynaptixTattoo
/**
* Calculates the upper left location of the Popup.
*/
private Point getPopupLocation() {
int h = getPopupHeightForRowCount(comboBox.getMaximumRowCount());
Dimension pl = list.getPreferredSize();
Dimension popupSize = comboBox.getSize();
// TODO Modif de Gaby pour agrandir la combo box
popupSize.width = Math
.max(
popupSize.width,
(pl.getHeight() > h ? pl.width
+ scroller.getVerticalScrollBar()
.getPreferredSize().width : pl.width) + 2);
Insets insets = getInsets();
// reduce the width of the scrollpane by the insets so that the popup
// is the same width as the combo box.
popupSize.setSize(popupSize.width - (insets.right + insets.left), h);
Rectangle popupBounds = computePopupBounds(0,
comboBox.getBounds().height, popupSize.width, popupSize.height);
Dimension scrollSize = popupBounds.getSize();
Point popupLocation = popupBounds.getLocation();
scroller.setMaximumSize(scrollSize);
scroller.setPreferredSize(scrollSize);
scroller.setMinimumSize(scrollSize);
list.revalidate();
return popupLocation;
}
代码示例来源:origin: org.java.net.substance/substance
/**
* Calculates the upper left location of the popup.
*
* @return The upper left location of the popup.
*/
private Point getPopupLocation() {
Dimension popupSize = this.comboBox.getSize();
Insets insets = this.getInsets();
// reduce the width of the scrollpane by the insets so that the popup
// is the same width as the combo box.
popupSize.setSize(popupSize.width - (insets.right + insets.left), this
.getPopupHeightForRowCount(this.comboBox.getMaximumRowCount()));
Rectangle popupBounds = this.computePopupBounds(0, this.comboBox
.getBounds().height, popupSize.width, popupSize.height);
Dimension scrollSize = popupBounds.getSize();
Point popupLocation = popupBounds.getLocation();
this.scroller.setMaximumSize(scrollSize);
this.scroller.setPreferredSize(scrollSize);
this.scroller.setMinimumSize(scrollSize);
this.list.revalidate();
return new Point(popupLocation.x, popupLocation.y);
}
代码示例来源:origin: khuxtable/seaglass
/**
* Calculates the upper left location of the Popup.
*
* @return the Point representing the upper-left coordinate of the Popup.
*/
private Point getPopupLocation() {
Dimension popupSize = comboBox.getSize();
Insets insets = getInsets();
// reduce the width of the scrollpane by the insets so that the popup
// is the same width as the combo box.
popupSize.setSize(popupSize.width - (insets.right + insets.left), getPopupHeightForRowCount(getMaximumRowCount()));
Rectangle popupBounds = computePopupBounds(0, comboBox.getBounds().height, popupSize.width, popupSize.height);
Dimension scrollSize = popupBounds.getSize();
Point popupLocation = popupBounds.getLocation();
scroller.setMaximumSize(scrollSize);
scroller.setPreferredSize(scrollSize);
scroller.setMinimumSize(scrollSize);
list.revalidate();
return popupLocation;
}
}
代码示例来源:origin: FellowTraveler/otapij
@Override
public void show() {
Dimension popupSize = ((SteppedComboBox) comboBox)
.getPopupSize();
popupSize
.setSize(popupSize.width,
getPopupHeightForRowCount(comboBox
.getMaximumRowCount()));
Rectangle popupBounds = computePopupBounds(0, comboBox
.getBounds().height, popupSize.width, popupSize.height);
scroller.setMaximumSize(popupBounds.getSize());
scroller.setPreferredSize(popupBounds.getSize());
scroller.setMinimumSize(popupBounds.getSize());
list.invalidate();
int selectedIndex = comboBox.getSelectedIndex();
if (selectedIndex == -1) {
list.clearSelection();
} else {
list.setSelectedIndex(selectedIndex);
}
list.ensureIndexIsVisible(list.getSelectedIndex());
setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled());
show(comboBox, popupBounds.x, popupBounds.y);
}
};
代码示例来源:origin: org.ihtsdo/wb-api
public void show() {
int widestWidth = getWidestItemWidth();
if (widestWidth < comboBox.getPreferredSize().width) {
widestWidth = comboBox.getPreferredSize().width;
}
Dimension popupSize = comboBox.getSize();
popupSize.setSize(widestWidth + (2 * padding),
getPopupHeightForRowCount(comboBox.getMaximumRowCount()));
Rectangle popupBounds = computePopupBounds(0, comboBox.getBounds().height, popupSize.width,
popupSize.height);
scroller.setMaximumSize(popupBounds.getSize());
scroller.setPreferredSize(popupBounds.getSize());
scroller.setMinimumSize(popupBounds.getSize());
list.invalidate();
int selectedIndex = comboBox.getSelectedIndex();
if (selectedIndex == -1) {
list.clearSelection();
} else {
list.setSelectedIndex(selectedIndex);
}
list.ensureIndexIsVisible(list.getSelectedIndex());
setLightWeightPopupEnabled(comboBox.isLightWeightPopupEnabled());
show(comboBox, popupBounds.x, popupBounds.y);
}
};
内容来源于网络,如有侵权,请联系作者删除!