📄 aboutaction.java
字号:
/* * @(#) AboutAction.java * Copyright 2004 HWStudio. All rights reserved. */package hws.item.smart.action.help;//导入核心Java类库import java.io.IOException;import java.awt.Cursor;import java.awt.Insets;import java.awt.Graphics;import java.awt.FontMetrics;import java.awt.GridBagLayout;import java.awt.GridBagConstraints;import java.awt.event.ActionEvent;import java.awt.event.MouseAdapter;import java.awt.event.MouseEvent;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.JOptionPane;//导入自定义Java类库import hws.item.smart.Smart;import hws.item.smart.misc.XMLConfig;import hws.item.smart.misc.ImageShop;import hws.item.smart.misc.ColorShop;import hws.item.smart.action.BaseAction;/** * 显示程序信息,版本号及版权信息 * * @version 0.1 2005-07-21 * @author Hwerz */public class AboutAction extends BaseAction { /*------------------------------------------------------------------------* * 属性定义 * *------------------------------------------------------------------------*/ /** * 该类自身的一个静态引用 */ private static AboutAction action; /*------------------------------------------------------------------------* * 构造函数 * *------------------------------------------------------------------------*/ /** * 构造函数为私有,这样在整个运行过程中该类就只能有一个实例 */ private AboutAction() { super("关于SmartNet", new Integer('a')); setHintInfo("显示程序信息,版本号及版权信息"); } /*------------------------------------------------------------------------* * 公共方法 * *------------------------------------------------------------------------*/ /** * 对该类提供的一个全局访问点,用来实例化该对象 * * @return 该类唯一的一个实例 */ public static AboutAction getInstance() { if (action == null) { action = new AboutAction(); } return action; } /*------------------------------------------------------------------------* * 覆盖方法 * *------------------------------------------------------------------------*/ /** * 覆盖超类Action的方法 * * @param event ActionEvent对象 */ public void actionPerformed(ActionEvent event) { JOptionPane.showMessageDialog(Smart.getInstance(), new AboutInfoPanel(), "关于SmartNet", JOptionPane.INFORMATION_MESSAGE, ImageShop.TITLE_IMAGEICON); } /*------------------------------------------------------------------------* * 内部类 * *------------------------------------------------------------------------*/ /** * 关于信息面板 */ class AboutInfoPanel extends JPanel { /** * 主页标签 */ private JLabel homePageLabel; /** * 标记鼠标是否进入到homePageLabel的边界内 */ private boolean mouseEntered; /** * Create a new instance of this class */ public AboutInfoPanel() { super(new GridBagLayout()); mouseEntered = false; //名称标签 GridBagConstraints constraints = new GridBagConstraints( //gridx, gridy 0, 0, //gridwidth, gridheight 1, 1, //weightx, weighty 0.0, 0.0, //anchor GridBagConstraints.NORTHWEST, //fill GridBagConstraints.NONE, //insets new Insets(0, 0, 0, 0), //ipadx, ipady 0, 0); add(new JLabel("名称:"), constraints); constraints.gridx = 1; add(new JLabel(XMLConfig.getSoftwareName()), constraints); //版本标签 constraints.gridx = 0; constraints.gridy = 1; add(new JLabel("版本:"), constraints); constraints.gridx = 1; add(new JLabel(XMLConfig.getSoftwareVersion()), constraints); //描述标签 constraints.gridx = 0; constraints.gridy = 2; add(new JLabel("描述:"), constraints); constraints.gridx = 1; add(new JLabel(XMLConfig.getSoftwareDescription()), constraints); //主页标签 constraints.gridx = 0; constraints.gridy = 3; add(new JLabel("主页:"), constraints); constraints.gridx = 1; homePageLabel = new JLabel(XMLConfig.getSoftwareHomepage()) { public void paint(Graphics g) { super.paint(g); if (mouseEntered == true) { FontMetrics metrics = g.getFontMetrics(); int width = metrics .stringWidth(XMLConfig.getSoftwareHomepage()); int height = metrics.getHeight() - 1; g.drawLine(0, height, width, height); } } }; homePageLabel.addMouseListener(new MouseAdapter() { public void mouseEntered(MouseEvent event) { mouseEntered = true; homePageLabel.setCursor( Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); homePageLabel.setForeground(ColorShop.HYPERLINK1_COLOR); } public void mouseExited(MouseEvent event) { mouseEntered = false; homePageLabel.setCursor(Cursor.getDefaultCursor()); homePageLabel.setForeground(ColorShop.HYPERLINK2_COLOR); } public void mouseClicked(MouseEvent event) { try { StringBuffer buffer = new StringBuffer(); buffer.append("rundll32 SHELL32.DLL,ShellExec_RunDLL "); buffer.append(XMLConfig.getSoftwareHomepage()); Runtime.getRuntime().exec(buffer.toString()); } catch (IOException e) { e.printStackTrace(); } } }); add(homePageLabel, constraints); //版权标签 constraints.gridx = 0; constraints.gridy = 4; add(new JLabel("版权:"), constraints); constraints.gridx = 1; add(new JLabel(XMLConfig.getSoftwareCopyright()), constraints); } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -