javax.swing.plaf.basic.ComboPopup Java Examples
The following examples show how to use
javax.swing.plaf.basic.ComboPopup.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MaterialComboBox.java From swing-material with MIT License | 6 votes |
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); }
Example #2
Source File: XDMComboBoxUI.java From xdm with GNU General Public License v2.0 | 6 votes |
@Override protected ComboPopup createPopup() { return new BasicComboPopup(comboBox) { /** * */ private static final long serialVersionUID = -4232501153552563408L; @Override protected JScrollPane createScroller() { JScrollPane scroller = new JScrollPane(list, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scroller.setVerticalScrollBar(new DarkScrollBar(JScrollBar.VERTICAL)); return scroller; } }; }
Example #3
Source File: SubstanceComboBoxUI.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
@Override protected ComboPopup createPopup() { final SubstanceComboPopup sPopup = new SubstanceComboPopup(this.comboBox); final ComponentOrientation currOrientation = this.comboBox.getComponentOrientation(); SwingUtilities.invokeLater(() -> { if (SubstanceComboBoxUI.this.comboBox == null) { return; } sPopup.applyComponentOrientation(currOrientation); sPopup.doLayout(); ListCellRenderer cellRenderer = SubstanceComboBoxUI.this.comboBox.getRenderer(); if (cellRenderer instanceof Component) { ((Component) cellRenderer).applyComponentOrientation(currOrientation); } ComboBoxEditor editor = SubstanceComboBoxUI.this.comboBox.getEditor(); if ((editor != null) && (editor.getEditorComponent() != null)) { (editor.getEditorComponent()).applyComponentOrientation(currOrientation); } SubstanceComboBoxUI.this.comboBox.repaint(); }); return sPopup; }
Example #4
Source File: XDebuggerTreeInplaceEditor.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void onHidden() { final ComboPopup popup = myExpressionEditor.getComboBox().getPopup(); if (popup != null && popup.isVisible()) { popup.hide(); } }
Example #5
Source File: WindowsRootPaneUI.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
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(); } } }
Example #6
Source File: WindowsRootPaneUI.java From JDKSourceCode1.8 with MIT License | 5 votes |
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(); } } }
Example #7
Source File: FixedComboBoxEditor.java From consulo with Apache License 2.0 | 5 votes |
private void textChanged() { final Container ancestor = SwingUtilities.getAncestorOfClass(JComboBox.class, this); if (ancestor == null || !ancestor.isVisible()) return; final JComboBox comboBox = (JComboBox)ancestor; if (!comboBox.isPopupVisible()) return; final ComboPopup popup = getComboboxPopup(comboBox); if (popup == null) return; String s = myField.getText(); final ListModel listmodel = comboBox.getModel(); int i = listmodel.getSize(); if (s.length() > 0) { for (int j = 0; j < i; j++) { Object obj = listmodel.getElementAt(j); if (obj == null) continue; String s1 = obj.toString(); if (s1 != null && (s1.startsWith(s) || s1.equals(s))) { popup.getList().setSelectedIndex(j); return; } } } popup.getList().clearSelection(); }
Example #8
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
@Override public void updateUI() { super.updateUI(); EventQueue.invokeLater(() -> { setUI(new MetalComboBoxUI() { @Override protected ComboPopup createPopup() { return new ComboTablePopup(comboBox, table); } }); setEditable(false); }); }
Example #9
Source File: WindowsRootPaneUI.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
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(); } } }
Example #10
Source File: WindowsRootPaneUI.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
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(); } } }
Example #11
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
protected static void repaintComboBox(JComboBox<?> combo, int row) { if (combo.getSelectedIndex() == row) { combo.repaint(); } Accessible a = combo.getAccessibleContext().getAccessibleChild(0); if (a instanceof ComboPopup) { JList<?> list = ((ComboPopup) a).getList(); if (list.isShowing()) { list.repaint(list.getCellBounds(row, row)); } } }
Example #12
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
@Override protected ComboPopup createPopup() { return new BasicComboPopup(comboBox) { @Override public void show() { System.out.println("togglePopup"); // super.show(); } }; }
Example #13
Source File: ComboBoxAutoCompleteSupport.java From netbeans with Apache License 2.0 | 5 votes |
private static JList getPopupList( JComboBox combo ) { Accessible a = combo.getUI().getAccessibleChild(combo, 0); if( a instanceof ComboPopup ) { return ((ComboPopup) a).getList(); } return null; }
Example #14
Source File: ComboBoxAutoCompleteSupport.java From netbeans with Apache License 2.0 | 5 votes |
private static JList getPopupList( JComboBox combo ) { Accessible a = combo.getUI().getAccessibleChild(combo, 0); if( a instanceof ComboPopup ) { return ((ComboPopup) a).getList(); } return null; }
Example #15
Source File: WindowsRootPaneUI.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
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(); } } }
Example #16
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
@Override protected void updateItem(int index) { if (isPopupVisible()) { CheckableItem item = getItemAt(index); item.setSelected(!item.isSelected()); repaint(); Accessible a = getAccessibleContext().getAccessibleChild(0); if (a instanceof ComboPopup) { ((ComboPopup) a).getList().repaint(); } } }
Example #17
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
protected Optional<JList<?>> getList() { Accessible a = getAccessibleContext().getAccessibleChild(0); if (a instanceof ComboPopup) { return Optional.of(((ComboPopup) a).getList()); } return Optional.empty(); }
Example #18
Source File: WindowsRootPaneUI.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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(); } } }
Example #19
Source File: MainPanel.java From java-swing-tips with MIT License | 5 votes |
public static JComboBox<Icon> makeComboBox1(ComboBoxModel<Icon> model, Icon proto, int rowCount) { return new JComboBox<Icon>(model) { @Override public Dimension getPreferredSize() { Insets i = getInsets(); int w = proto.getIconWidth(); int h = proto.getIconHeight(); int totalCount = getItemCount(); int columnCount = totalCount / rowCount + (totalCount % rowCount == 0 ? 0 : 1); return new Dimension(w * columnCount + i.left + i.right, h + i.top + i.bottom); } @Override public void updateUI() { super.updateUI(); setMaximumRowCount(rowCount); setPrototypeDisplayValue(proto); Accessible o = getAccessibleContext().getAccessibleChild(0); if (o instanceof ComboPopup) { JList<?> list = ((ComboPopup) o).getList(); list.setLayoutOrientation(JList.HORIZONTAL_WRAP); list.setVisibleRowCount(rowCount); list.setFixedCellWidth(proto.getIconWidth()); list.setFixedCellHeight(proto.getIconHeight()); } } }; }
Example #20
Source File: JComboBoxOperator.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
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); }
Example #21
Source File: WindowsRootPaneUI.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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(); } } }
Example #22
Source File: WindowsRootPaneUI.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
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(); } } }
Example #23
Source File: WindowsRootPaneUI.java From hottub with GNU General Public License v2.0 | 5 votes |
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(); } } }
Example #24
Source File: WindowsRootPaneUI.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
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(); } } }
Example #25
Source File: WindowsRootPaneUI.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
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(); } } }
Example #26
Source File: FlatComboBox.java From workcraft with MIT License | 5 votes |
@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; }
Example #27
Source File: WindowsRootPaneUI.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
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(); } } }
Example #28
Source File: XDebuggerTreeInplaceEditor.java From consulo with Apache License 2.0 | 5 votes |
@Override protected void doPopupOKAction() { ComboPopup popup = myExpressionEditor.getComboBox().getPopup(); if (popup != null && popup.isVisible()) { Object value = popup.getList().getSelectedValue(); if (value != null) { myExpressionEditor.setExpression((XExpression)value); } } doOKAction(); }
Example #29
Source File: WindowsRootPaneUI.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
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(); } } }
Example #30
Source File: JComboBoxFactory.java From WorldGrower with GNU General Public License v3.0 | 5 votes |
private static<T> void setComboBoxProperties(JComboBox<T> comboBox, ImageInfoReader imageInfoReader) { comboBox.setOpaque(false); comboBox.setBackground(ColorPalette.FOREGROUND_COLOR); comboBox.setForeground(ColorPalette.FOREGROUND_COLOR); comboBox.setFont(Fonts.FONT); comboBox.setUI(new MetalComboBoxUI() { @Override protected ComboPopup createPopup() { return new TiledImageComboPopup( comboBox, imageInfoReader ); } }); }