Cutting, Copying, Pasting and Deleting Components

JDeveloper supports Cut, Copy, Paste and Delete functionality in the Java Visual Editor. You can perform these operations between files of the same project or different projects.

Note: When you cut, copy, paste from one file to a file in another project, you may be required to update your project properties on the target project to include additional libraries. If the the target project does not define the right libraries for the pasted object, the paste will fail since the Java Visual Editor will not recognize the class of the incoming objects.

Copying Components

To copy one or more components:

  1. Select the components you want to copy.
  2. Choose Edit then choose Copy.

The components are copied to a local clipboard in JDeveloper.

Visual components copied in the Java Visual Editor are not copied to the system clipboard, and cannot be transferred into other applications. Use a screen capture utility to create an image of a control, or copy the source text to use the Java code in another Java development environment.

When you copy a component that has defined event methods, the event listener is copied with the component, but not the event handler. This is because in most cases it's the format of the control, and not the behavior, that you want to copy. If your goal is to copy the control and its behavior to a different Java class file, you need to separately copy the handler: open the file in the Code Editor, locate the handler code, select it, and choose Edit then choose Copy.

Tip: If you find yourself copying components from one project to another primarily for their design settings, consider using Serialized JavaBeans components, which enable you to create new components with predefined properties.

Cutting Components

Before you cut your component be sure to paste the previously cut object since cutting the event code will overwrite the contents of the clipboard.

To cut a component from your user interface:

  1. Select the components you want to cut.
  2. Choose Edit then choose Cut.

The component is removed from the Java Visual Editor and placed into a local clipboard only accessible by JDeveloper (not to the system clipboard). If you quit JDeveloper without pasting the control into a container, the cut version of the control will be lost.

The cut command is the first step in a cut and paste action. If you just want to remove a component, see Deleting a component, below. Deleting a component removes it without changing the contents of your clipboard. If you get in the habit of using the cut command to remove items permanently, there is a chance that one day you will inadvertently replace something in the clipboard that you would rather have kept.

When you cut a component that has defined event methods, the event listener is cut with the component. The event handler is not removed from the source code, nor is it placed on the clipboard. The reasons for this are twofold:

To cut an event handler in the Code Editor, locate the handler code, select it, and choose Edit then choose Cut.

Pasting Components

The components you copy or cut from a JDeveloper Design window can be pasted into any other designable class file.

To paste a component:

  1. Open the file to which you want to paste the component in the Java Visual Editor.
  2. Select the container to which you want to paste the component.
  3. Choose Edit then choose Paste.

The JavaBeans components you paste will add any existing event listener code from the original component to your source code. The event handler code does not get copied or cut with the component: if you want to use the same event handler, you need to copy and paste the handler separately using the Code Editor.

Deleting Components from your UI

Delete a component when you want to remove it from your Java program without affecting the contents of the clipboard.

To delete a component:

  1. Select the component in the Java Visual Editor or the Structure window.
  2. Press the Delete key.

When you delete a JavaBeans component from the Java Visual Editor, the event listener methods, if any, are deleted from the source code, but the event handler methods are not. If you want to remove the event handler methods, you need to delete them in the Code Editor.