package com.onaro.util.jfc; import java.awt.Color; import java.awt.Cursor; import java.awt.Font; import java.awt.font.TextAttribute; import java.util.Map; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.SwingConstants; import com.onaro.sanscreen.client.help.HelpManagerFactory; /** * This object is a help field which shows the help display text and * links to the help context by showing it as a link in the landing page. */ public class HelpField extends JButton{ private static final long serialVersionUID = 1L; public HelpField(final String helpDisplayText, final String helpContext){ setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); setFocusPainted(false); setHorizontalAlignment(SwingConstants.LEFT); setForeground(Color.BLUE); //This is to set the blue font to show it as a link. //Did not want to hard code the html link format. Font currentFont = getFont(); @SuppressWarnings("unchecked") Map attributes = (Map)currentFont.getAttributes(); attributes.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON); setFont(currentFont.deriveFont(attributes)); setText(helpDisplayText); //connect to the help system. HelpManagerFactory.getHelpManager().setHelpContext (this, helpContext); HelpManagerFactory.getHelpManager().registerHelpInvoker (this); setBorder(BorderFactory.createEmptyBorder()); setBackground(Color.WHITE); } }