Java tutorial
//package com.java2s; //License from project: Apache License import java.awt.Component; import javax.swing.ComboBoxEditor; import javax.swing.JComboBox; import javax.swing.text.JTextComponent; public class Main { static void dndCopy(final Component component) { final JTextComponent textComponent = getTextComponent(component); if (textComponent != null) { textComponent.copy(); } } static JTextComponent getTextComponent(final Component component) { if (component instanceof JTextComponent) { return (JTextComponent) component; } else if (component instanceof JComboBox) { final JComboBox<?> comboBox = (JComboBox<?>) component; final ComboBoxEditor editor = comboBox.getEditor(); final Component editorComponent = editor.getEditorComponent(); return getTextComponent(editorComponent); } else { return null; } } }