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

Cannot underline Font using Map

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 6
    • 2.0, 1.2.0, 1.3.0
    • client-libs
    • 2d
    • b33
    • generic, x86
    • generic, windows_95



      Name: krT82822 Date: 12/04/99


      original user summary:

      Map map = getFont().getAttributes();
      map.put(TextAttribute.SIZE, new Float(19.0));
      map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
      Font newFont = new Font(map);
      setFont(newFont);

      This code is from the mouseEntered method of a class that extends JLabel. The
      effect of applying this new Font() is that the size is reflected, however, the
      underline is NOT.

      ----------------------------

      12/4/99 eval1127@eng -- filed against 1.2.x, but behavior the same under kestrel RA (1.3.0 build "I").

      import java.awt.*;
      import java.awt.font.*;
      import java.util.*;

      import javax.swing.*;

      class MyLabel extends JLabel {
              public MyLabel(String text) {
                      super(text);
                      Map map = (new Font("Arial", Font.PLAIN, 48)).getAttributes();
                      map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
                      map.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_LOW_TWO_PIXEL);
                      Font newFont = new Font(map);
                      setFont(newFont);
                      setForeground(Color.blue);
              }
      }

      public class Blah extends JFrame {

              public Blah() {
                      super("califragilistic...");
                      MyLabel lbl = new MyLabel("how does this look");
                      setContentPane(lbl);
                      pack();
              }

              public static void main(String[] args) {
                      Blah f = new Blah();
                      f.setLocation(300,300);
                      f.setVisible(true);
              }
      }

      (Review ID: 98544)
      ======================================================================

            dougfelt Doug Felt (Inactive)
            kryansunw Kevin Ryan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: