Detecting when JToolBar has been made floatable

Main.java:

import javax.swing.plaf.basic.*;
import javax.swing.border.*;
import java.awt.event.*;
import javax.swing.*;
import java.beans.*;
import java.awt.*;
 
public class Main extends JFrame
{
   public Main()
   {
      final JToolBar toolBar = new JToolBar();
      JButton gifButton = new JButton("GIF");
      JButton jpgButton = new JButton("JPG");
      JButton tiffButton = new JButton("TIFF");
      toolBar.add(gifButton);
      toolBar.add(jpgButton);
      toolBar.add(tiffButton);
 
      getContentPane().add(BorderLayout.NORTH, toolBar);
 
      toolBar.addPropertyChangeListener(new PropertyChangeListener() {
         boolean wasFloating = false;
 
         public void propertyChange(PropertyChangeEvent evt) {
            if (toolBar.getUI() instanceof BasicToolBarUI) {
               BasicToolBarUI bt = (BasicToolBarUI) toolBar.getUI();
               if (wasFloating != bt.isFloating()) {
                  wasFloating = bt.isFloating();
                  System.out.println("Floating: " + wasFloating);
               }
            }
         }
      });            
 
      addWindowListener(new WindowAdapter() {
         public void windowClosing(WindowEvent we) {
            System.exit(0);
         }
      });
   }
      
   public static void main(String []args) {
      Main main = new Main();
      main.setSize(300, 300);
      main.setVisible(true);
   }
}