//设置控件隐藏 tbButton.setVisible(false); InputMap inputMap = this.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_M, InputEvent.CTRL_DOWN_MASK), "VK_M"); ActionMap actionMap = this.getActionMap(); actionMap.put("VK_M", new AbstractAction() { boolean isVisible = false;//显示 @Override public void actionPerformed(ActionEvent e) { isVisible = !isVisible; tbButton.setVisible(!isVisible); } });
时间: 2024-12-29 10:25:04