题
我需要的字体下划线和蓝色在我Jbutton将一个超链接,但似乎Font类没有明显的方式做到这一点。因为我不会用Graphics类来显示这个我不能使用attributedtext。有反正我能做到这一点?我只需要我的JButton的标题是蓝色并带有下划线。
解决方案 3
我最终解决不能够通过我的字符串,围绕着.....标签来强调文本的问题。
其他提示
我来不及回答。但不管怎么说,我将它张贴在这里。也许这将是有益的人。
JButton button = new JButton("Label");
HashMap<TextAttribute, Object> textAttrMap = new HashMap<TextAttribute, Object>();
textAttrMap.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
textAttrMap.put(TextAttribute.FOREGROUND, Color.BLUE);
button.setFont(button.getFont().deriveFont(textAttrMap));
价: http://docs.oracle.com/ JavaSE的/教程/ 2D /文本/示例/ AttributedText.java
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);
不隶属于 StackOverflow