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

Some LabelView.(is)setXXXX methods works incorrectly

XMLWordPrintable



      Name: nkR10003 Date: 10/23/2000



      JavaDoc comments for LabelView.setUnderline states:
      "Set whether or not the view is underlined." Also
      JavaDoc comments for LabelView.isUnderline states:
      "Determine if the glyphs should be underlined....."
      So after the call to setUnderline(true), method
      isUnderline should return true. Actually it returns false.

      The same problem appears with methods from the list below:
      Methods list:
          protected void setUnderline(boolean u)
          protected boolean isUnderline()
          protected void setStrikeThrough(boolean s)
          protected boolean isStrikeThrough()
          protected void setSuperscript(boolean s)
          protected boolean isSuperscript()
          protected void setSubscript(boolean s)
          protected boolean isSubscript()

      Example below demonstrates this problem:
      ------------------example--------------------
      //test.java
      import javax.swing.text.*;
      import javax.swing.*;

      public class test {
          public static void main(String[] args) {
              DefaultStyledDocument doc = new DefaultStyledDocument();
              Element element = doc.getDefaultRootElement();
              UnderlineView view = new UnderlineView(element);
              
              if (!view.isUnderline()) {
                  System.out.println("is underline: " + view.isUnderline());
                  System.out.println("Test failed");
                  System.exit(1);
              }
              
              System.out.println("Test passed");
              System.exit(0);
          }
      }

      class UnderlineView extends LabelView {
          public UnderlineView(Element element) {
              super(element);
              setUnderline(true);
          }
      }
      ----------------output:----------------------
      is underline: false
      Test failed
      ---------------------------------------------
      ======================================================================

            Unassigned Unassigned
            knasunw Kna Kna (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: