我知道,如果我想在 JButton
中为文本添加下划线,我必须这样做:
JButton myButton=new JButton("Test");
Font font = myButton.getFont();
Map attributes = font.getAttributes();
attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
myButton.setFont(font.deriveFont(attributes));
而且,如果我要为文本添加上划线呢?我应该怎么办?有人可以帮助我吗?
最佳答案
不需要 Font
在这里上课。您可以使用HTML directly并添加 <u>
和<strike>
标签:
myButton = new JButton("<html><strike><u>Test</u></strike></html>");
关于java - JButton 内的上划线文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30440400/