title: Strange Java cast exception. Why can't I cast Long to a Float?
body: <p>Why can't I cast Long to a Float?</p>
  
  <p>I get this error message:</p>
  
  <blockquote>
    <p>java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Float</p>
  </blockquote>
  
  <p>Why is this a problem? The numbers that I'm trying to cast are decimals in the domain [-10.0, 10.0]. They start out as Object instances returned using <code>JFormattedTextField.getValue()</code>. But they must be converted to floats.</p>
  
  <h2>Stack trace:</h2>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Float
      at submodeler.animation.Timeline.setKeyedAttribute(Timeline.java:59)
      at submodeler.ui.attributes.TransformationAttributePanel.actionPerformed(TransformationAttributePanel.java:247)
      at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028)
      at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351)
      at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
      at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
      at java.awt.Component.processMouseEvent(Component.java:6348)
      at javax.swing.JComponent.processMouseEvent(JComponent.java:3267)
      at java.awt.Component.processEvent(Component.java:6113)
      at java.awt.Container.processEvent(Container.java:2085)
      at java.awt.Component.dispatchEventImpl(Component.java:4714)
      at java.awt.Container.dispatchEventImpl(Container.java:2143)
      at java.awt.Component.dispatchEvent(Component.java:4544)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4618)
      at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4282)
      at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4212)
      at java.awt.Container.dispatchEventImpl(Container.java:2129)
      at java.awt.Window.dispatchEventImpl(Window.java:2475)
      at java.awt.Component.dispatchEvent(Component.java:4544)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:635)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
  </code></pre>