コード例 #1
0
 public void actionPerformed(ActionEvent evt) {
   Component focusOwner =
       KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
   if (focusOwner != null) {
     if (focusOwner instanceof EditableComponent) {
       ((EditableComponent) focusOwner).duplicate();
     } else {
       focusOwner.getToolkit().beep();
     }
   }
 }
コード例 #2
0
ファイル: CutAction.java プロジェクト: vonfrank/SB5-MAI-E15
 @FeatureEntryPoint(JHotDrawFeatures.BASIC_EDITING)
 public void actionPerformed(ActionEvent evt) {
   Component focusOwner =
       KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
   if (focusOwner != null && focusOwner instanceof JComponent) {
     JComponent component = (JComponent) focusOwner;
     component
         .getTransferHandler()
         .exportToClipboard(
             component, component.getToolkit().getSystemClipboard(), TransferHandler.MOVE);
   }
 }
コード例 #3
0
 @Override
 public void actionPerformed(ActionEvent evt) {
   JComponent c = target;
   if (c == null
       && (KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner()
           instanceof JComponent)) {
     c =
         (JComponent)
             KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
   }
   if (c != null && c.isEnabled()) {
     if (c instanceof EditableComponent) {
       ((EditableComponent) c).clearSelection();
     } else if (c instanceof JTextComponent) {
       JTextComponent tc = ((JTextComponent) c);
       tc.select(tc.getSelectionStart(), tc.getSelectionStart());
     } else {
       c.getToolkit().beep();
     }
   }
 }