views:

89

answers:

2

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
I think the font underline constant may actually be "Font.UNDERLINE". Try both.
RJFalconer
Ah, see:http://stackoverflow.com/questions/325840/what-is-the-constant-value-of-the-underline-font-in-java
RJFalconer
A: 

I ended up solving the problem of not being able to underline text by surrounding my string with ..... tags.

Mike2012