public void actionPerformed(ActionEvent e) { Component focusOwner = FocusManager.getCurrentManager().getFocusOwner(); if (getCopyable().isPresent()) { getCopyable().ifPresent(this::handleCopy); } else if (focusOwner instanceof JTextComponent) { handleCopy((JTextComponent) focusOwner); } else if (focusOwner instanceof JTable) { handleCopy((JTable) focusOwner); } else if (focusOwner instanceof JList) { handleCopy((JList) focusOwner); } // Actually, we could put text on to the system clipboard // OWLObject should be serializable!!! }
public void actionPerformed(ActionEvent e) { Component focusOwner = FocusManager.getCurrentManager().getFocusOwner(); if (getCopyable().isPresent()) { getCopyable().ifPresent(this::handleCopy); } else if (focusOwner instanceof JTextComponent) { handleCopy((JTextComponent) focusOwner); } else if (focusOwner instanceof JTable) { handleCopy((JTable) focusOwner); } else if (focusOwner instanceof JList) { handleCopy((JList) focusOwner); } // Actually, we could put text on to the system clipboard // OWLObject should be serializable!!! }
private void updateState() { currentCopyable.ifPresent(c -> c.removeChangeListener(changeListener)); Component focusOwner = FocusManager.getCurrentManager().getFocusOwner(); if (getCopyable().isPresent()) { currentCopyable = getCopyable(); currentCopyable.ifPresent(c -> { c.addChangeListener(changeListener); setEnabled(c.canCopy()); }); } else if (focusOwner instanceof JTextComponent) { setEnabled(true); } else if (focusOwner instanceof JTable) { setEnabled(true); } else if (focusOwner instanceof JList) { setEnabled(true); } else { setEnabled(false); } }
private void updateState() { currentCopyable.ifPresent(c -> c.removeChangeListener(changeListener)); Component focusOwner = FocusManager.getCurrentManager().getFocusOwner(); if (getCopyable().isPresent()) { currentCopyable = getCopyable(); currentCopyable.ifPresent(c -> { c.addChangeListener(changeListener); setEnabled(c.canCopy()); }); } else if (focusOwner instanceof JTextComponent) { setEnabled(true); } else if (focusOwner instanceof JTable) { setEnabled(true); } else if (focusOwner instanceof JList) { setEnabled(true); } else { setEnabled(false); } }