當前位置: 首頁>>代碼示例>>Java>>正文


Java ComboPopup類代碼示例

本文整理匯總了Java中javax.swing.plaf.basic.ComboPopup的典型用法代碼示例。如果您正苦於以下問題:Java ComboPopup類的具體用法?Java ComboPopup怎麽用?Java ComboPopup使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ComboPopup類屬於javax.swing.plaf.basic包,在下文中一共展示了ComboPopup類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: altPressed

import javax.swing.plaf.basic.ComboPopup; //導入依賴的package包/類
void altPressed(KeyEvent ev) {
    MenuSelectionManager msm =
        MenuSelectionManager.defaultManager();
    MenuElement[] path = msm.getSelectedPath();
    if (path.length > 0 && ! (path[0] instanceof ComboPopup)) {
        msm.clearSelectedPath();
        menuCanceledOnPress = true;
        ev.consume();
    } else if(path.length > 0) { // We are in ComboBox
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        ev.consume();
    } else {
        menuCanceledOnPress = false;
        WindowsLookAndFeel.setMnemonicHidden(false);
        WindowsGraphicsUtils.repaintMnemonicsInWindow(winAncestor);
        JMenuBar mbar = root != null ? root.getJMenuBar() : null;
        if(mbar == null && winAncestor instanceof JFrame) {
            mbar = ((JFrame)winAncestor).getJMenuBar();
        }
        JMenu menu = mbar != null ? mbar.getMenu(0) : null;
        if(menu != null) {
            ev.consume();
        }
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:28,代碼來源:WindowsRootPaneUI.java

示例2: MaterialComboBox

import javax.swing.plaf.basic.ComboPopup; //導入依賴的package包/類
public MaterialComboBox() {
    setModel(new DefaultComboBoxModel<T>());
    setRenderer(new FieldRenderer<T>(this));
    setUI(new BasicComboBoxUI() {
        @Override
        protected ComboPopup createPopup() {
            BasicComboPopup popup = new Popup(comboBox);
            popup.getAccessibleContext().setAccessibleParent(comboBox);
            return popup;
        }

        @Override
        protected JButton createArrowButton() {
            JButton button = new javax.swing.plaf.basic.BasicArrowButton(
                    javax.swing.plaf.basic.BasicArrowButton.SOUTH,
                    MaterialColor.TRANSPARENT,
                    MaterialColor.TRANSPARENT,
                    MaterialColor.TRANSPARENT,
                    MaterialColor.TRANSPARENT);
            button.setName("ComboBox.arrowButton");
            return button;
        }
    });
    setOpaque(false);
    setBackground(MaterialColor.TRANSPARENT);
}
 
開發者ID:leMaik,項目名稱:swing-material,代碼行數:27,代碼來源:MaterialComboBox.java

示例3: getAccessibleSelection

import javax.swing.plaf.basic.ComboPopup; //導入依賴的package包/類
/**
 * Returns the accessible selection from this AccssibleJComboBox.
 *
 * @param index the index of the selected child to fetch
 *
 * @return the accessible selection from this AccssibleJComboBox
 */
public Accessible getAccessibleSelection(int index)
{
  // Get hold of the actual popup.
  Accessible popup = getUI().getAccessibleChild(JComboBox.this, 0);
  Accessible selected = null;
  if (popup != null && popup instanceof ComboPopup)
    {
      ComboPopup cPopup = (ComboPopup) popup;
      // Query the list for the currently selected child.
      JList l = cPopup.getList();
      AccessibleContext listCtx = l.getAccessibleContext();
      if (listCtx != null)
        {
          AccessibleSelection s = listCtx.getAccessibleSelection();
          if (s != null)
            {
              selected = s.getAccessibleSelection(index);
            }
        }
    }
  return selected;
}
 
開發者ID:vilie,項目名稱:javify,代碼行數:30,代碼來源:JComboBox.java

示例4: createPopup

import javax.swing.plaf.basic.ComboPopup; //導入依賴的package包/類
@Override
protected ComboPopup createPopup() {
    return new BasicComboPopup(comboBox) {
        private static final long serialVersionUID = -1460253465809092623L;

        @Override
        protected void configurePopup() {
            setBorderPainted(true);
            setBorder(BorderFactory.createLineBorder(Template.COLOR_LIGHT_GRAY));
            setOpaque(false);
            add(scroller);
            setFocusable(false);
        }

    };

}
 
開發者ID:CollapsedDom,項目名稱:Stud.IP-Client,代碼行數:18,代碼來源:DropDownBox.java

示例5: testGetMinimumSize

import javax.swing.plaf.basic.ComboPopup; //導入依賴的package包/類
public void testGetMinimumSize() throws Exception {
    ui.setComboBox(comboBox);
    ComboPopup popup = new BasicComboPopup(comboBox);
    ui.setPopup(popup);
    ui.setListBox(popup.getList());
    ui.installListeners();
    comboBox.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    Dimension listPart = new BasicComboBoxRenderer().getListCellRendererComponent(
            popup.getList(), "", -1, false, false).getPreferredSize();
    Dimension expectedSize = new Dimension(listPart.width + listPart.height + 8,
            listPart.height + 8);
    assertEquals(expectedSize, ui.getMinimumSize(null));
    assertEquals(expectedSize, ui.getCachedMinimumSize());
    ui.setCachedMinimumSize(new Dimension(100, 100));
    assertEquals(ui.getCachedMinimumSize(), ui.getMinimumSize(null));
    comboBox.addItem("aaa");
    listPart = new BasicComboBoxRenderer().getListCellRendererComponent(popup.getList(),
            "aaa", -1, false, false).getPreferredSize();
    expectedSize = new Dimension(listPart.width + listPart.height + 8, listPart.height + 8);
    assertEquals(expectedSize, ui.getMinimumSize(null));
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:22,代碼來源:MetalComboBoxUITest.java

示例6: readText

import javax.swing.plaf.basic.ComboPopup; //導入依賴的package包/類
public static String readText(final JComboBox cb, final int index) {
	return new DoSwingR<String>() {
		@Override
		protected String doRun() {
			Object value = cb.getItemAt(index);
			try {
				BasicComboBoxUI ui = (BasicComboBoxUI) cb.getUI();
				Field popupField = ReflectionUtils.getField(ui.getClass(), "popup");
				popupField.setAccessible(true);
				ComboPopup popup = (ComboPopup) popupField.get(ui);
				JList list = popup.getList();
				ListCellRenderer renderer = list.getCellRenderer();
				Component rendComp = renderer.getListCellRendererComponent(popup.getList(), value, index, false,
						false);
				return ComponentFixture.Common.readText(rendComp);
			} catch (Exception ex) {
			}
			return value.toString();
		}
	}.result();
}
 
開發者ID:jedwards1211,項目名稱:breakout,代碼行數:22,代碼來源:JComboBoxFixture.java

示例7: altPressed

import javax.swing.plaf.basic.ComboPopup; //導入依賴的package包/類
private void altPressed(KeyEvent ev) {
    MenuSelectionManager msm =
        MenuSelectionManager.defaultManager();
    MenuElement[] path = msm.getSelectedPath();
    if (path.length > 0 && ! (path[0] instanceof ComboPopup)) {
        msm.clearSelectedPath();
        menuCanceledOnPress = true;
        ev.consume();
    } else if (path.length > 0) { // we are in a combo box
        menuCanceledOnPress = false;
        ev.consume();
    } else {
        menuCanceledOnPress = false;
        JMenuBar mbar = getMenuBar(ev);
        JMenu menu = mbar != null ? mbar.getMenu(0) : null;
        if (menu != null) {
            ev.consume();
        }
    }
}
 
開發者ID:javachen,項目名稱:IBMDataMovementTool,代碼行數:21,代碼來源:MenuSelectionProcessor.java

示例8: getPopupList

import javax.swing.plaf.basic.ComboPopup; //導入依賴的package包/類
private static JList getPopupList( JComboBox combo ) {
    Accessible a = combo.getUI().getAccessibleChild(combo, 0);

    if( a instanceof ComboPopup ) {
        return ((ComboPopup) a).getList();
    }
    return null;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:ComboBoxAutoCompleteSupport.java

示例9: createPopup

import javax.swing.plaf.basic.ComboPopup; //導入依賴的package包/類
@Override
protected ComboPopup createPopup() {
	BasicComboPopup popup = new BasicComboPopup(comboBox) {

		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		@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);
		}
	};
	popup.getAccessibleContext().setAccessibleParent(comboBox);
	return popup;
}
 
開發者ID:max6cn,項目名稱:jmt,代碼行數:34,代碼來源:SteppedComboBoxUI.java

示例10: ListWater

import javax.swing.plaf.basic.ComboPopup; //導入依賴的package包/類
public ListWater() {
    super();
    cChooser = new ComponentChooser() {
        @Override
        public boolean checkComponent(Component comp) {
            if (comp instanceof JList) {
                Container cont = (Container) comp;
                while ((cont = cont.getParent()) != null) {
                    if (cont instanceof ComboPopup) {
                        return true;
                    }
                }
            }
            return false;
        }

        @Override
        public String getDescription() {
            return "Popup menu";
        }

        @Override
        public String toString() {
            return "JComboBoxOperator.ListWater.ComponentChooser{description = " + getDescription() + '}';
        }
    };
    pChooser = new PopupWindowChooser(cChooser);
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:29,代碼來源:JComboBoxOperator.java

示例11: createPopup

import javax.swing.plaf.basic.ComboPopup; //導入依賴的package包/類
@Override
protected ComboPopup createPopup() {
    BasicComboPopup popup = new BasicComboPopup(comboBox) {
        @Override
        protected Rectangle computePopupBounds(int px, int py, int pw, int ph) {
            return super.computePopupBounds(px, py, Math.max(comboBox.getPreferredSize().width, pw), ph);
        }
    };
    popup.getAccessibleContext().setAccessibleParent(comboBox);
    return popup;
}
 
開發者ID:workcraft,項目名稱:workcraft,代碼行數:12,代碼來源:FlatComboBox.java

示例12: focusLost

import javax.swing.plaf.basic.ComboPopup; //導入依賴的package包/類
@Override
public void focusLost (FocusEvent e) {
	ComboPopup cp = (ComboPopup) getUI().getAccessibleChild(JComboBoxField.this, 0);
	Object item = null;
	item = cp.getList().getSelectedValue();
	if (item == null){
		item = searcher.getCurrent();
	}
	if (item != null){
		setSelectedItem(item);
	}
}
 
開發者ID:Forlini91,項目名稱:Empire-Earth---DB-Editor,代碼行數:13,代碼來源:JComboBoxField.java

示例13: createPopup

import javax.swing.plaf.basic.ComboPopup; //導入依賴的package包/類
@Override
protected ComboPopup
createPopup() {
	ComboPopup cp = new SubstanceComboPopup(combo);
	cp.getList().setFont(cp.getList().getFont().deriveFont(10.0f));
	
	return cp;
}
 
開發者ID:lxlxlo,項目名稱:LS-jsampler,代碼行數:9,代碼來源:FantasiaComboBoxUI.java

示例14: getCurrentPopupValue

import javax.swing.plaf.basic.ComboPopup; //導入依賴的package包/類
@Nullable
public Object getCurrentPopupValue() {
  if (!isPopupVisible()) return null;

  final ComboPopup popup = myComboBox.getPopup();
  if (popup != null) {
    return popup.getList().getSelectedValue();
  }

  return null;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:12,代碼來源:DebuggerExpressionComboBox.java

示例15: getComboboxPopup

import javax.swing.plaf.basic.ComboPopup; //導入依賴的package包/類
@Nullable
private static ComboPopup getComboboxPopup(final JComboBox comboBox) {
  final ComboBoxUI ui = comboBox.getUI();
  ComboPopup popup = null;
  if (ui instanceof BasicComboBoxUI) {
    popup = ReflectionUtil.getField(BasicComboBoxUI.class, ui, ComboPopup.class, "popup");
  }

  return popup;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:FixedComboBoxEditor.java


注:本文中的javax.swing.plaf.basic.ComboPopup類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。