Studyon Minte9.com
Java SE




JLabel underline




package testexample; import java.awt.*; import java.awt.font.TextAttribute; import java.util.Map; import javax.swing.*; public class Test extends JFrame { public static void main(String[] args) { Test frame = new Test(); frame.setBounds(200, 200, 300, 200); frame.setDefaultCloseOperation(EXIT_ON_CLOSE); frame.setVisible(true); } public Test() { JLabel label = new JLabel("Underlined Label"); Font font = label.getFont(); Map attributes = font.getAttributes(); attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); // --- Look Here --- // //attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_REGULAR); //attributes.put(TextAttribute.WEIGHT, TextAttribute.WEIGHT_BOLD); label.setFont(font.deriveFont(attributes)); JPanel panel = new JPanel(); panel.add(label); add(panel); } }
 


http://stackoverflow.com/questions/15892844/make-my-jlabel-underlined