Abd*_*dan 39
JLabel label = new JLabel("<HTML><U>YOUR TEXT HERE</U></HTML>");
label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
Run Code Online (Sandbox Code Playgroud)
要么
JLabel label = new JLabel("Underlined Label");
Font font = label.getFont();
Map attributes = font.getAttributes();
attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
label.setFont(font.deriveFont(attributes));
Run Code Online (Sandbox Code Playgroud)
Rei*_*eus 35
JLabel label = new JLabel("Underlined Label");
Font font = label.getFont();
Map<TextAttribute, Object> attributes = new HashMap<>(font.getAttributes());
attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
label.setFont(font.deriveFont(attributes));
Run Code Online (Sandbox Code Playgroud)