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
 private static void locateOnScreen(Component component) {
   Dimension paneSize = component.getSize();
   Dimension screenSize = component.getToolkit().getScreenSize();
   component.setLocation(
       (screenSize.width - paneSize.width) / 2, (screenSize.height - paneSize.height) / 2);
 }