1 19 20 package org.netbeans.modules.xml.multiview.ui; 21 22 import org.netbeans.modules.xml.multiview.cookies.LinkCookie; 23 24 import javax.swing.*; 25 26 34 public class LinkButton extends JButton { 35 36 37 public LinkButton(LinkCookie panel, Object ddBean, String ddProperty) { 38 super(); 39 initLinkButton(this, panel, ddBean, ddProperty); 40 } 41 42 public static void initLinkButton(final AbstractButton button, LinkCookie panel, Object ddBean, String ddProperty) { 43 button.setForeground(SectionVisualTheme.hyperlinkColor); 44 button.setHorizontalAlignment(SwingConstants.LEFT); 45 button.setMargin(new java.awt.Insets (2, 2, 2, 2)); 46 button.setOpaque(false); 47 button.setBorderPainted(false); 48 button.setFocusPainted(false); 49 button.setContentAreaFilled(false); 50 String text = "<html><b><u>" + button.getText() + "</u></b></html>"; 51 button.setAction(new LinkAction(panel, ddBean, ddProperty)); 52 button.setText(text); 53 54 button.addMouseListener(new java.awt.event.MouseAdapter () { 55 public void mouseEntered(java.awt.event.MouseEvent e) { 56 button.setCursor(java.awt.Cursor.getPredefinedCursor(java.awt.Cursor.HAND_CURSOR)); 57 button.setForeground(SectionVisualTheme.hyperlinkColorFocused); 58 } 59 public void mouseExited(java.awt.event.MouseEvent e) { 60 button.setCursor(java.awt.Cursor.getDefaultCursor()); 61 button.setForeground(SectionVisualTheme.hyperlinkColor); 62 } 63 }); 64 } 65 66 public void setText(String text) { 67 super.setText("<html><b><u>"+text+"</u></b></html>"); 68 } 69 70 public static class LinkAction extends AbstractAction { 71 LinkCookie panel; 72 Object ddBean; 73 String ddProperty; 74 75 public LinkAction(LinkCookie panel, Object ddBean, String ddProperty) { 76 this.panel=panel; 77 this.ddBean=ddBean; 78 this.ddProperty=ddProperty; 79 } 80 81 public void actionPerformed(java.awt.event.ActionEvent evt) { 82 panel.linkButtonPressed(ddBean, ddProperty); 83 } 84 } 85 } 86 | Popular Tags |