Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8105374

Exception thrown when setting a Font with size 0 to a SwingTextField

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • fx1.2
    • fx1.0
    • javafx
    • Windows XP Prof, JavaFX SDK hudson build 437

      I get the following exception when changing the font of a SwingTextField. I've a Slider which changes the size of the font used by SwingTextField. When slider position is reduced to 0, exception is thrown

      Unexpected exception caught in MasterTimer.timePulse():
      java.lang.ArithmeticException: / by zero
              at javax.swing.text.PlainView.paint(PlainView.java:256)
              at javax.swing.text.FieldView.paint(FieldView.java:171)
              at javax.swing.plaf.basic.BasicTextUI$RootView.paint(BasicTextUI.java:1422)
              at javax.swing.plaf.basic.BasicTextUI.paintSafely(BasicTextUI.java:722)
              at javax.swing.plaf.basic.BasicTextUI.paint(BasicTextUI.java:869)
              at javax.swing.plaf.synth.SynthTextFieldUI.paint(SynthTextFieldUI.java:172)
              at javax.swing.plaf.synth.SynthTextFieldUI.update(SynthTextFieldUI.java:159)
              at javax.swing.JComponent.paintComponent(JComponent.java:763)
              at javafx.ext.swing.JTextFieldImpl.paintComponent(JTextFieldImpl.java:74)
              at javax.swing.JComponent.paint(JComponent.java:1027)
              at javax.swing.JComponent.paintChildren(JComponent.java:864)
              at javax.swing.JComponent.paint(JComponent.java:1036)
              at com.sun.embeddedswing.EmbeddedPeer.paint(EmbeddedPeer.java:134)
              at com.sun.scenario.scenegraph.SGComponent.paint(SGComponent.java:121)
              at com.sun.scenario.scenegraph.SGLeaf.render(SGLeaf.java:179)
              at com.sun.scenario.scenegraph.SGTransform.render(SGTransform.java:284)
              at com.sun.scenario.scenegraph.SGWrapper.render(SGWrapper.java:122)
              at com.sun.scenario.scenegraph.SGGroup.render(SGGroup.java:218)
              at com.sun.scenario.scenegraph.SGGroup.render(SGGroup.java:218)
              at com.sun.scenario.scenegraph.JSGPanel.paintComponent(JSGPanel.java:548)
              at com.sun.javafx.scene.JSGPanelImpl.paintComponent(JSGPanelImpl.java:53)
              at javax.swing.JComponent.paint(JComponent.java:1027)
              at javax.swing.JComponent.paintToOffscreen(JComponent.java:5122)
              at javax.swing.BufferStrategyPaintManager.paint(BufferStrategyPaintManager.java:277)
              at javax.swing.RepaintManager.paint(RepaintManager.java:1213)
              at javax.swing.JComponent._paintImmediately(JComponent.java:5070)
              at javax.swing.JComponent.paintImmediately(JComponent.java:4880)
              at javax.swing.JComponent.paintImmediately(JComponent.java:4892)
              at com.sun.scenario.scenegraph.JSGPanel.repaintDirtyRegions(JSGPanel.java:600)
              at com.sun.scenario.scenegraph.JSGPanelRepainter.repaintAll(JSGPanelRepainter.java:106)
              at com.sun.scenario.scenegraph.JSGPanelRepainter$FrameDisplay.run(JSGPanelRepainter.java:112)
              at com.sun.scenario.animation.AbstractMasterTimer.timePulseImpl(AbstractMasterTimer.java:365)
              at com.sun.scenario.animation.AbstractMasterTimer$MainLoop.run(AbstractMasterTimer.java:247)
              at com.sun.embeddedswing.EmbeddedEventQueue.doPulse(EmbeddedEventQueue.java:440)
              at com.sun.embeddedswing.EmbeddedEventQueue.access$000(EmbeddedEventQueue.java:70)
              at com.sun.embeddedswing.EmbeddedEventQueue$2.run(EmbeddedEventQueue.java:347)
              at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
              at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
              at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)

      Below is the testcase. When Stage comes up, move the slider knob to left end and exception will be thrown.

      import javafx.ext.swing.*;
      import javafx.stage.*;
      import javafx.scene.*;
      import javafx.scene.text.*;

      var font = Font {
          name: "Dialog"
          size: 12
      };
      var tf = SwingTextField {
          text: "Some text"
          columns: 15
          font: bind font
          translateX: 30
          translateY: 40
      };
      var size = 12 on replace {
          font = Font {
              name: "Dialog"
              size: size
          };
      };
      Stage {
          scene: Scene {
              content: [tf, SwingSlider {
                  minimum: 0
                  maximum: 50
                  value: bind size with inverse
                  translateX: 30
                  translateY: 100
              }]
          }
          width: 300
          height: 200
          visible: true
      }

            rbair Richard Bair (Inactive)
            gramachasunw Girish Ramachandran (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: