I need to make a font underline and blue for a hyperlink in one of my JButtons, but it seems the font class has no obvious way to do this. I can't use attributedtext because I'm not going to be displaying this with Graphics class. Is there anyway I can accomplish this? I just need the title of my JButton to be blue and underlined.
A:
JButton button = new JButton("OK");
button.setBackground(Color.blue);
Font buttonFont=new Font(button.getFont().getName(),Font.UNDERLINED+Font.BOLD,button.getFont().getSize());
button.setFont(buttonFont);
RJFalconer
2009-08-07 00:41:06
I think the font underline constant may actually be "Font.UNDERLINE". Try both.
RJFalconer
2009-08-07 00:43:15
Ah, see:http://stackoverflow.com/questions/325840/what-is-the-constant-value-of-the-underline-font-in-java
RJFalconer
2009-08-07 00:44:56
A:
I ended up solving the problem of not being able to underline text by surrounding my string with ..... tags.
Mike2012
2009-09-11 19:43:50