Uploaded image for project: 'Groovy'
  1. Groovy
  2. GROOVY-4448

SwingBuilder TitledBorder not recognizing justification attribute correctly

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.7.5
    • 1.7.6, 1.8-beta-3
    • Swing
    • None
    • Patch

    Description

      I was attempting to move my titled border around the panel by modifying the justification attribute.

      panel(border: titledBorder(border: etchedBorder(), title: 'Project', justification: 'right', position: 'bottom')) {
      

      It seemed no matter what value I put into the justification attribute, it would stay on the left of my panel. I looked into the source code, and it appears as though there may be a copy paste error from the section processing the position attribute. The current version of TitledBorderFactory reads the justification attribute from the builder, and then tries to look the value up in the position map instead of the justification map. I think a simple code change to look things up in the justification map would fix things.

      i.e. change this:

      def justification = attributes.remove("justification")
      justification = positions[justification] ?: justification
      
      

      to this:

      def justification = attributes.remove("justification")
      justification = justifications[justification] ?: justification
      

      Attachments

        1. justificationFix.diff
          0.7 kB
          Jonathan Baker
        2. TitledBorderFactoryJustificationTest.groovy
          1 kB
          Jonathan Baker

        Activity

          People

            roshandawrani Roshan Dawrani
            solidjb Jonathan Baker
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: