本文整理匯總了Java中javax.swing.plaf.basic.BasicComboPopup.getList方法的典型用法代碼示例。如果您正苦於以下問題:Java BasicComboPopup.getList方法的具體用法?Java BasicComboPopup.getList怎麽用?Java BasicComboPopup.getList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.plaf.basic.BasicComboPopup
的用法示例。
在下文中一共展示了BasicComboPopup.getList方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: lookupPopupItem
import javax.swing.plaf.basic.BasicComboPopup; //導入方法依賴的package包/類
private int lookupPopupItem(String pattern, boolean select) {
BasicComboPopup popup = (BasicComboPopup) comboBox.getAccessibleContext().getAccessibleChild(0);
JList list = popup.getList();
int nextMatch = list.getNextMatch(pattern, 0, Position.Bias.Forward);
if (list.getSelectedIndex() > 0) {
nextMatch = nextMatch < 0 ? list.getNextMatch(pattern, list.getSelectedIndex(), Position.Bias.Backward) : nextMatch;
}
if (select) {
if (nextMatch >= 0) {
list.ensureIndexIsVisible(nextMatch);
list.setSelectedIndex(nextMatch);
} else {
list.getSelectionModel().clearSelection();
}
}
return nextMatch;
}
示例2: popupWider
import javax.swing.plaf.basic.BasicComboPopup; //導入方法依賴的package包/類
private void popupWider(BasicComboPopup popup) {
@SuppressWarnings("unchecked")
JList<E> list = popup.getList();
// Determine the maximimum width to use:
// a) determine the popup preferred width
// b) limit width to the maximum if specified
// c) ensure width is not less than the scroll pane width
int popupWidth = list.getPreferredSize().width
+ 5 // make sure horizontal scrollbar doesn't appear
+ getScrollBarWidth(popup, scrollPane);
if (maximumWidth != -1) {
popupWidth = Math.min(popupWidth, maximumWidth);
}
Dimension scrollPaneSize = scrollPane.getPreferredSize();
popupWidth = Math.max(popupWidth, scrollPaneSize.width);
// Adjust the width
scrollPaneSize.width = popupWidth;
scrollPane.setPreferredSize(scrollPaneSize);
scrollPane.setMaximumSize(scrollPaneSize);
}
示例3: popupWider
import javax.swing.plaf.basic.BasicComboPopup; //導入方法依賴的package包/類
protected void popupWider(BasicComboPopup popup) {
JList list = popup.getList();
// Determine the maximimum width to use:
// a) determine the popup preferred width
// b) limit width to the maximum if specified
// c) ensure width is not less than the scroll pane width
int popupWidth = list.getPreferredSize().width + 5 // make sure horizontal scrollbar doesn't appear
+ getScrollBarWidth(popup, scrollPane);
if (maximumWidth != -1) {
popupWidth = Math.min(popupWidth, maximumWidth);
}
Dimension scrollPaneSize = scrollPane.getPreferredSize();
popupWidth = Math.max(popupWidth, scrollPaneSize.width);
// Adjust the width
scrollPaneSize.width = popupWidth;
scrollPane.setPreferredSize(scrollPaneSize);
scrollPane.setMaximumSize(scrollPaneSize);
}
示例4: updateStateBoxColor
import javax.swing.plaf.basic.BasicComboPopup; //導入方法依賴的package包/類
/**
* Updates the color of the user state combo box
*/
private void updateStateBoxColor(){
ComboUserState.setForeground(state_colors[ComboUserState.getSelectedIndex()]);
Object child = ComboUserState.getAccessibleContext().getAccessibleChild(0);
BasicComboPopup popup = (BasicComboPopup)child;
JList list = popup.getList();
list.setSelectionForeground(state_colors[ComboUserState.getSelectedIndex()]);
list.setSelectionBackground(Color.WHITE);
}
示例5: getScrollPane
import javax.swing.plaf.basic.BasicComboPopup; //導入方法依賴的package包/類
private JScrollPane getScrollPane(BasicComboPopup popup) {
@SuppressWarnings("unchecked")
JList<E> list = popup.getList();
Container c = SwingUtilities.getAncestorOfClass(JScrollPane.class, list);
return (JScrollPane) c;
}
示例6: horizontalScrollBarWillBeVisible
import javax.swing.plaf.basic.BasicComboPopup; //導入方法依賴的package包/類
private boolean horizontalScrollBarWillBeVisible(BasicComboPopup popup, JScrollPane scrollPane) {
@SuppressWarnings("unchecked")
JList<E> list = popup.getList();
int scrollBarWidth = getScrollBarWidth(popup, scrollPane);
int popupWidth = list.getPreferredSize().width + scrollBarWidth;
return popupWidth > scrollPane.getPreferredSize().width;
}
示例7: horizontalScrollBarWillBeVisible
import javax.swing.plaf.basic.BasicComboPopup; //導入方法依賴的package包/類
protected boolean horizontalScrollBarWillBeVisible(BasicComboPopup popup, JScrollPane scrollPane) {
JList list = popup.getList();
int scrollBarWidth = getScrollBarWidth(popup, scrollPane);
int popupWidth = list.getPreferredSize().width + scrollBarWidth;
return popupWidth > scrollPane.getPreferredSize().width;
}
示例8: setComboBoxSelectionColor
import javax.swing.plaf.basic.BasicComboPopup; //導入方法依賴的package包/類
public static void setComboBoxSelectionColor(JComboBox comboBox, Color color) {
Object child = comboBox.getAccessibleContext().getAccessibleChild(0);
BasicComboPopup popup = (BasicComboPopup)child;
JList list = popup.getList();
list.setSelectionForeground(color);
}
示例9: getScrollPane
import javax.swing.plaf.basic.BasicComboPopup; //導入方法依賴的package包/類
protected JScrollPane getScrollPane(BasicComboPopup popup) {
JList list = popup.getList();
Container c = SwingUtilities.getAncestorOfClass(JScrollPane.class, list);
return (JScrollPane) c;
}
示例10: updateModel
import javax.swing.plaf.basic.BasicComboPopup; //導入方法依賴的package包/類
public void updateModel(final SuggestionComboBox comboBox) {
final Object selected = getValue();
ProgressThread t = new ProgressThread("fetching_suggestions") {
@Override
public void run() {
try {
getProgressListener().setTotal(100);
getProgressListener().setCompleted(0);
synchronized (lock) {
removeAllElements();
insertElementAt(LOADING, 0);
// fill list with stuff
List<Object> suggestions = getSuggestions(operator, getProgressListener());
removeAllElements();
int index = 0;
for (Object suggestion : suggestions) {
insertElementAt(suggestion, index);
++index;
}
// resize popup
Object child = comboBox.getAccessibleContext().getAccessibleChild(0);
BasicComboPopup popup = (BasicComboPopup) child;
JList list = popup.getList();
Dimension preferred = list.getPreferredSize();
preferred.width += 25;
int itemCount = comboBox.getItemCount();
int rowHeight = 10;
if(itemCount > 0) {
rowHeight = preferred.height / itemCount;
}
int maxHeight = comboBox.getMaximumRowCount() * rowHeight;
preferred.height = Math.min(preferred.height, maxHeight);
Container c = SwingUtilities.getAncestorOfClass(JScrollPane.class, list);
JScrollPane scrollPane = (JScrollPane) c;
scrollPane.setPreferredSize(preferred);
scrollPane.setMaximumSize(preferred);
Dimension popupSize = popup.getSize();
popupSize.width = preferred.width;
popupSize.height = preferred.height + 5;
Component parent = popup.getParent();
if (parent != null) {
parent.setSize(popupSize);
parent.validate();
parent.repaint();
}
}
getProgressListener().setCompleted(100);
if (getSelectedItem() == null) {
if (model.getSize() == 0) {
setSelectedItem(null);
} else if (selected != null) {
setSelectedItem(selected);
}
}
} finally {
getProgressListener().complete();
}
}
};
t.start();
}