类javax.swing.plaf.basic.ComboPopup源码实例Demo

下面列出了怎么用javax.swing.plaf.basic.ComboPopup的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: xdm   文件: XDMComboBoxUI.java
@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;
		}
	};
}
 
源代码2 项目: radiance   文件: SubstanceComboBoxUI.java
@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;
}
 
源代码3 项目: swing-material   文件: MaterialComboBox.java
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);
}
 
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();
        }
    }
}
 
源代码5 项目: dragonwell8_jdk   文件: WindowsRootPaneUI.java
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();
        }
    }
}
 
源代码6 项目: jdk8u60   文件: WindowsRootPaneUI.java
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();
        }
    }
}
 
源代码7 项目: JDKSourceCode1.8   文件: WindowsRootPaneUI.java
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();
        }
    }
}
 
源代码8 项目: nanoleaf-desktop   文件: ModernComboBoxUI.java
@Override
protected ComboPopup createPopup()
{
	return new BasicComboPopup(comboBox)
	{
		@Override
		protected JScrollPane createScroller()
		{
			// Override the default Metal scrollbar
			JScrollPane scroller = super.createScroller();
			scroller.getVerticalScrollBar().setUI(new ModernScrollBarUI());
			return scroller;
		}
	};
}
 
源代码9 项目: radiance   文件: ScrollPaneSelectorWidget.java
@Override
public void installListeners() {
    this.hierarchyListener = (HierarchyEvent e) -> {
        if (jcomp.getParent() instanceof ComboPopup) {
            if (scrollPaneSelector != null) {
                scrollPaneSelector.uninstallFromScrollPane();
                scrollPaneSelector = null;
            }
        }
    };
    this.jcomp.addHierarchyListener(this.hierarchyListener);

    this.propertyChangeListener = (PropertyChangeEvent evt) -> {
        if (SubstanceSynapse.COMPONENT_PREVIEW_PAINTER.equals(evt.getPropertyName())) {
            PreviewPainter pPainter = WidgetUtilities.getComponentPreviewPainter(jcomp);
            // Uninstall old scroll pane selector
            if (scrollPaneSelector != null) {
                scrollPaneSelector.uninstallFromScrollPane();
                scrollPaneSelector = null;
            }
            // Install new scroll pane selector
            if (pPainter != null && SubstanceCoreUtilities.toShowExtraWidgets(jcomp)) {
                scrollPaneSelector = new ScrollPaneSelector();
                scrollPaneSelector.installOnScrollPane(jcomp);
            }
        }
    };
    this.jcomp.addPropertyChangeListener(this.propertyChangeListener);
}
 
源代码10 项目: consulo   文件: XDebuggerTreeInplaceEditor.java
@Override
protected void onHidden() {
  final ComboPopup popup = myExpressionEditor.getComboBox().getPopup();
  if (popup != null && popup.isVisible()) {
    popup.hide();
  }
}
 
源代码11 项目: netbeans   文件: ComboBoxAutoCompleteSupport.java
private static JList getPopupList( JComboBox combo ) {
    Accessible a = combo.getUI().getAccessibleChild(combo, 0);

    if( a instanceof ComboPopup ) {
        return ((ComboPopup) a).getList();
    }
    return null;
}
 
源代码12 项目: netbeans   文件: ComboBoxAutoCompleteSupport.java
private static JList getPopupList( JComboBox combo ) {
    Accessible a = combo.getUI().getAccessibleChild(combo, 0);

    if( a instanceof ComboPopup ) {
        return ((ComboPopup) a).getList();
    }
    return null;
}
 
源代码13 项目: openjdk-jdk8u-backup   文件: WindowsRootPaneUI.java
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();
        }
    }
}
 
源代码14 项目: openjdk-jdk9   文件: WindowsRootPaneUI.java
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();
        }
    }
}
 
源代码15 项目: openjdk-jdk9   文件: JComboBoxOperator.java
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);
}
 
源代码16 项目: jdk8u-jdk   文件: WindowsRootPaneUI.java
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();
        }
    }
}
 
源代码17 项目: hottub   文件: WindowsRootPaneUI.java
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();
        }
    }
}
 
源代码18 项目: openjdk-8-source   文件: WindowsRootPaneUI.java
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();
        }
    }
}
 
源代码19 项目: workcraft   文件: FlatComboBox.java
@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;
}
 
源代码20 项目: openjdk-8   文件: WindowsRootPaneUI.java
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();
        }
    }
}
 
源代码21 项目: consulo   文件: XDebuggerTreeInplaceEditor.java
@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();
}
 
源代码22 项目: jdk8u_jdk   文件: WindowsRootPaneUI.java
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();
        }
    }
}
 
源代码23 项目: WorldGrower   文件: JComboBoxFactory.java
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 );
		}
	});
}
 
源代码24 项目: jdk8u-jdk   文件: WindowsRootPaneUI.java
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();
        }
    }
}
 
源代码25 项目: jdk8u-dev-jdk   文件: WindowsRootPaneUI.java
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();
        }
    }
}
 
源代码26 项目: java-swing-tips   文件: MainPanel.java
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());
      }
    }
  };
}
 
源代码27 项目: java-swing-tips   文件: MainPanel.java
protected Optional<JList<?>> getList() {
  Accessible a = getAccessibleContext().getAccessibleChild(0);
  if (a instanceof ComboPopup) {
    return Optional.of(((ComboPopup) a).getList());
  }
  return Optional.empty();
}
 
源代码28 项目: java-swing-tips   文件: MainPanel.java
@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();
    }
  }
}
 
源代码29 项目: java-swing-tips   文件: MainPanel.java
@Override protected ComboPopup createPopup() {
  return new BasicComboPopup(comboBox) {
    @Override public void show() {
      System.out.println("togglePopup");
      // super.show();
    }
  };
}
 
源代码30 项目: java-swing-tips   文件: MainPanel.java
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));
    }
  }
}
 
 类所在包
 类方法
 同包方法