jdk/src/share/classes/sun/tools/jconsole/AboutDialog.java
changeset 12851 3334e1c781d0
parent 5506 202f599c92aa
child 14342 8435a30053c1
equal deleted inserted replaced
12850:f4a05c228eca 12851:3334e1c781d0
    28 import java.awt.*;
    28 import java.awt.*;
    29 import java.awt.event.*;
    29 import java.awt.event.*;
    30 import java.beans.PropertyVetoException;
    30 import java.beans.PropertyVetoException;
    31 import java.net.URI;
    31 import java.net.URI;
    32 
    32 
    33 import javax.accessibility.*;
       
    34 import javax.swing.*;
    33 import javax.swing.*;
    35 import javax.swing.border.*;
    34 import javax.swing.border.*;
    36 import javax.swing.event.*;
    35 import javax.swing.event.*;
    37 
    36 
       
    37 
    38 import static java.awt.BorderLayout.*;
    38 import static java.awt.BorderLayout.*;
    39 import static sun.tools.jconsole.Resources.*;
       
    40 import static sun.tools.jconsole.Utilities.*;
    39 import static sun.tools.jconsole.Utilities.*;
    41 
    40 
    42 @SuppressWarnings("serial")
    41 @SuppressWarnings("serial")
    43 public class AboutDialog extends InternalDialog {
    42 public class AboutDialog extends InternalDialog {
    44 
    43 
    45     private static final Color textColor     = new Color(87,   88,  89);
    44     private static final Color textColor     = new Color(87,   88,  89);
    46     private static final Color bgColor       = new Color(232, 237, 241);
    45     private static final Color bgColor       = new Color(232, 237, 241);
    47     private static final Color borderColor   = Color.black;
    46     private static final Color borderColor   = Color.black;
    48 
    47 
    49     private Icon mastheadIcon =
    48     private Icon mastheadIcon =
    50         new MastheadIcon(getText("Help.AboutDialog.masthead.title"));
    49         new MastheadIcon(Messages.HELP_ABOUT_DIALOG_MASTHEAD_TITLE);
    51 
    50 
    52     private static AboutDialog aboutDialog;
    51     private static AboutDialog aboutDialog;
    53 
    52 
    54     private JLabel statusBar;
    53     private JLabel statusBar;
    55     private Action closeAction;
    54     private Action closeAction;
    56 
    55 
    57     public AboutDialog(JConsole jConsole) {
    56     public AboutDialog(JConsole jConsole) {
    58         super(jConsole, Resources.getText("Help.AboutDialog.title"), false);
    57         super(jConsole, Messages.HELP_ABOUT_DIALOG_TITLE, false);
    59 
    58 
    60         setAccessibleDescription(this,
    59         setAccessibleDescription(this, Messages.HELP_ABOUT_DIALOG_ACCESSIBLE_DESCRIPTION);
    61                                  getText("Help.AboutDialog.accessibleDescription"));
       
    62         setDefaultCloseOperation(HIDE_ON_CLOSE);
    60         setDefaultCloseOperation(HIDE_ON_CLOSE);
    63         setResizable(false);
    61         setResizable(false);
    64         JComponent cp = (JComponent)getContentPane();
    62         JComponent cp = (JComponent)getContentPane();
    65 
    63 
    66         createActions();
    64         createActions();
    67 
    65 
    68         JLabel mastheadLabel = new JLabel(mastheadIcon);
    66         JLabel mastheadLabel = new JLabel(mastheadIcon);
    69         setAccessibleName(mastheadLabel,
    67         setAccessibleName(mastheadLabel,
    70                           getText("Help.AboutDialog.masthead.accessibleName"));
    68                 Messages.HELP_ABOUT_DIALOG_MASTHEAD_ACCESSIBLE_NAME);
    71 
    69 
    72         JPanel mainPanel = new TPanel(0, 0);
    70         JPanel mainPanel = new TPanel(0, 0);
    73         mainPanel.add(mastheadLabel, NORTH);
    71         mainPanel.add(mastheadLabel, NORTH);
    74 
    72 
    75         String jConsoleVersion = Version.getVersion();
    73         String jConsoleVersion = Version.getVersion();
    76         String vmName = System.getProperty("java.vm.name");
    74         String vmName = System.getProperty("java.vm.name");
    77         String vmVersion = System.getProperty("java.vm.version");
    75         String vmVersion = System.getProperty("java.vm.version");
    78         String urlStr = getText("Help.AboutDialog.userGuideLink.url");
    76         String urlStr = Messages.HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL;
    79         if (isBrowseSupported()) {
    77         if (isBrowseSupported()) {
    80             urlStr = "<a style='color:#35556b' href=\"" + urlStr + "\">" + urlStr + "</a>";
    78             urlStr = "<a style='color:#35556b' href=\"" + urlStr + "\">" + urlStr + "</a>";
    81         }
    79         }
    82 
    80 
    83         JPanel infoAndLogoPanel = new JPanel(new BorderLayout(10, 10));
    81         JPanel infoAndLogoPanel = new JPanel(new BorderLayout(10, 10));
    84         infoAndLogoPanel.setBackground(bgColor);
    82         infoAndLogoPanel.setBackground(bgColor);
    85 
    83 
    86         String colorStr = String.format("%06x", textColor.getRGB() & 0xFFFFFF);
    84         String colorStr = String.format("%06x", textColor.getRGB() & 0xFFFFFF);
    87         JEditorPane helpLink = new JEditorPane("text/html",
    85         JEditorPane helpLink = new JEditorPane("text/html",
    88                                 "<html><font color=#"+ colorStr + ">" +
    86                                 "<html><font color=#"+ colorStr + ">" +
    89                         getText("Help.AboutDialog.jConsoleVersion", jConsoleVersion) +
    87                         Resources.format(Messages.HELP_ABOUT_DIALOG_JCONSOLE_VERSION, jConsoleVersion) +
    90                 "<p>" + getText("Help.AboutDialog.javaVersion", (vmName +", "+ vmVersion)) +
    88                 "<p>" + Resources.format(Messages.HELP_ABOUT_DIALOG_JAVA_VERSION, (vmName +", "+ vmVersion)) +
    91                 "<p>" + getText("Help.AboutDialog.userGuideLink", urlStr) +
    89                 "<p>" + Resources.format(Messages.HELP_ABOUT_DIALOG_USER_GUIDE_LINK, urlStr) +
    92                                                  "</html>");
    90                                                  "</html>");
    93         helpLink.setOpaque(false);
    91         helpLink.setOpaque(false);
    94         helpLink.setEditable(false);
    92         helpLink.setEditable(false);
    95         helpLink.setForeground(textColor);
    93         helpLink.setForeground(textColor);
    96         mainPanel.setBorder(BorderFactory.createLineBorder(borderColor));
    94         mainPanel.setBorder(BorderFactory.createLineBorder(borderColor));
   153     static void showAboutDialog(JConsole jConsole) {
   151     static void showAboutDialog(JConsole jConsole) {
   154         getAboutDialog(jConsole).showDialog();
   152         getAboutDialog(jConsole).showDialog();
   155     }
   153     }
   156 
   154 
   157     static void browseUserGuide(JConsole jConsole) {
   155     static void browseUserGuide(JConsole jConsole) {
   158         getAboutDialog(jConsole).browse(getText("Help.AboutDialog.userGuideLink.url"));
   156         getAboutDialog(jConsole).browse(Messages.HELP_ABOUT_DIALOG_USER_GUIDE_LINK_URL);
   159     }
   157     }
   160 
   158 
   161     static boolean isBrowseSupported() {
   159     static boolean isBrowseSupported() {
   162         return (Desktop.isDesktopSupported() &&
   160         return (Desktop.isDesktopSupported() &&
   163                 Desktop.getDesktop().isSupported(Desktop.Action.BROWSE));
   161                 Desktop.getDesktop().isSupported(Desktop.Action.BROWSE));
   174             }
   172             }
   175         }
   173         }
   176     }
   174     }
   177 
   175 
   178     private void createActions() {
   176     private void createActions() {
   179         closeAction = new AbstractAction(getText("Close")) {
   177         closeAction = new AbstractAction(Messages.CLOSE) {
   180             public void actionPerformed(ActionEvent ev) {
   178             public void actionPerformed(ActionEvent ev) {
   181                 setVisible(false);
   179                 setVisible(false);
   182                 statusBar.setText("");
   180                 statusBar.setText("");
   183             }
   181             }
   184         };
   182         };