Duplicate :
|
|
Duplicate :
|
|
Relates :
|
|
Relates :
|
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) ======================================================================
|