void (ActionEvent e) { if (!(e.getSource() instanceof JComboBox)) return; @SuppressWarnings("unchecked") JComboBox<Object> comboBox = (JComboBox<Object>)e.getSource(); String text; Object selectedItem = comboBox.getSelectedItem(); if (selectedItem instanceof String) { text = (String)selectedItem; } else { Component component = comboBox.getRenderer().getListCellRendererComponent(new JList<>(), selectedItem, 0, false, false); if (component instanceof JLabel) { text = ((JLabel)component).getText(); } else if (component != null) { String str = component.toString(); // skip default Component.toString and handle SimpleColoredComponent case text = str == null || str.startsWith(component.getClass().getName() + '[') ? null : str; } else { text = null; } } if (text != null) { JTextField textField = new JTextField(text); textField.selectAll(); textField.copy(); } }