Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- jLabel.setFont(new Font("Tahoma",1,20));
- JLabel label = new JLabel("some text - WE ARE UNDERLINED");
- MouseListener l = new MouseAdapter() {
- Font original;
- @Override
- public void mouseEntered(MouseEvent e) {
- original = e.getComponent().getFont();
- Map attributes = original.getAttributes();
- attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
- e.getComponent().setFont(original.deriveFont(attributes));
- }
- @Override
- public void mouseExited(MouseEvent e) {
- e.getComponent().setFont(original);
- }
- };
- label.addMouseListener(l);
- JComponent content = new JPanel();
- content.add(label);
- content.add(new JButton("dummy focus"));
- JLabel#setFont(new Font(attributes));
- JLabel#setFont(new Font("Serif", Font.BOLD, 16));
- final Map attributes = (new Font("Serif", Font.BOLD, 16)).getAttributes();
- attributes.put(TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON);
- yourLabel.setText(htmlIfy("<p style='color:#1C66AE;'>Your text here</p>"));
- private static final String HTML = "<html>";
- private static final String HTML_END = "</html>";
- public static String htmlIfy(String s) {
- return HTML.concat(s).concat(HTML_END);
- }
- yourLabel.setText(HTMLTagUtil.htmlIfy(HTMLTagUtil
- .linkIfy("Your Text Here")));//Forgot Password?
- yourLabel.setCursor(new java.awt.Cursor(
- java.awt.Cursor.HAND_CURSOR));
- private static final String A_HREF = "<a href="";
- private static final String HREF_CLOSED = "">";
- private static final String HREF_END = "</a>";
- public static String linkIfy(String s) {
- return A_HREF.concat(s).concat(HREF_CLOSED).concat(s).concat(HREF_END);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement