Perform outline-dragging with JInternalFrame

Outline dragging is a JDesktopPane client property that provides the user with a outline rectangle when JInternalFrames are dragged instead of displaying the full contents of the JInternalFrame, making dragging internal frames a lot more performant. To perform outline dragging, set the property JDesktopPane.dragMode to outline. Swing 1.1.1 had added fast implementation for fast dragging. Put the client property to “faster”.
Here’s an example:

import java.awt.event.*;
import javax.swing.*;
import java.awt.*;
import java.net.*;
 
public class Main extends JFrame implements ActionListener {
   JDesktopPane desktop;
   int nframes = 0;
 
   public Main() {
      getContentPane().setLayout(new BorderLayout());
      desktop = new JDesktopPane(); 
      createInternalFrame();
      getContentPane().add(BorderLayout.CENTER, desktop);
      setJMenuBar(createMenuBar());
  
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
            System.exit(0);
         }
      });
   
      setTitle("Outline Dragging Demonstration");
      setSize(new Dimension(400, 400));
   }
 
   protected JMenuBar createMenuBar() {
      JMenuBar menuBar = new JMenuBar();

      JMenu menu = new JMenu("JDesktopPane");
      JMenuItem menuItem1 = new JMenuItem("Create new JInternalFrame");
      menuItem1.addActionListener(this);
      menu.add(menuItem1);
      menu.add(new JSeparator());
      JMenuItem menuItem2 = new JMenuItem("Outline dragging normal");
      menuItem2.addActionListener(this);
      menu.add(menuItem2);
      JMenuItem menuItem3 = new JMenuItem("Outline dragging on");
      menuItem3.addActionListener(this);
      menu.add(menuItem3);
      JMenuItem menuItem4 = new JMenuItem("Fast dragging");
      menuItem4.addActionListener(this);
      menu.add(menuItem4);
      menuBar.add(menu);

      return menuBar;
   }
 
   public void actionPerformed(ActionEvent e) {
      if (e.getActionCommand().equals("Create new JInternalFrame")) {
         createInternalFrame();
      }
      else if (e.getActionCommand().equals("Outline dragging normal")) {
         desktop.putClientProperty("JDesktopPane.dragMode", "normal");
      }
      else if (e.getActionCommand().equals("Outline dragging on")) {
         // Make dragging faster
         desktop.putClientProperty("JDesktopPane.dragMode", "outline");
      }
      else if (e.getActionCommand().equals("Fast dragging")) {
         desktop.putClientProperty("JDesktopPane.dragMode", "faster");
      }
   }
 
   protected void createInternalFrame() {
      JInternalFrame frame = new JInternalFrame("InternalFrame", 
         true,    // resizable
         true,    // closable
         true,    // maximizable
         true);   // iconifiable
      frame.setVisible(true); 
      desktop.add(frame);
      frame.setSize(200, 200);
      frame.setLocation(30*nframes, 30*nframes);
      nframes++;
      try {
         frame.setSelected(true);
      } catch (java.beans.PropertyVetoException e) {}
   }
 
   public static void main(String []args) {
      Main main = new Main();
      main.show();
   }
}