⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e767. determining when the menu of a jcombobox component is displayed.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
// Create component
    String[] items = {"item1", "item2"};
    JComboBox cb = new JComboBox(items);
    cb.setEditable(true);
    
    // Create and register listener
    MyPopupMenuListener actionListener = new MyPopupMenuListener();
    cb.addPopupMenuListener(actionListener);
    
    class MyPopupMenuListener implements PopupMenuListener {
        // This method is called just before the menu becomes visible
        public void popupMenuWillBecomeVisible(PopupMenuEvent evt) {
            JComboBox cb = (JComboBox)evt.getSource();
        }
    
        // This method is called just before the menu becomes hidden
        public void popupMenuWillBecomeInvisible(PopupMenuEvent evt) {
            JComboBox cb = (JComboBox)evt.getSource();
        }
    
        // This method is called when menu is hidden because the user cancelled it
        public void popupMenuCanceled(PopupMenuEvent evt) {
            JComboBox cb = (JComboBox)evt.getSource();
        }
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -