1 18 19 package org.apache.jmeter.gui.action; 20 21 import java.awt.BorderLayout ; 22 import java.awt.Color ; 23 import java.awt.Container ; 24 import java.awt.Dimension ; 25 import java.awt.GridLayout ; 26 import java.awt.Point ; 27 import java.awt.event.ActionEvent ; 28 import java.awt.event.MouseAdapter ; 29 import java.awt.event.MouseEvent ; 30 import java.util.Collections ; 31 import java.util.HashSet ; 32 import java.util.Set ; 33 34 import javax.swing.JDialog ; 35 import javax.swing.JFrame ; 36 import javax.swing.JLabel ; 37 import javax.swing.JPanel ; 38 import javax.swing.border.EmptyBorder ; 39 40 import org.apache.jmeter.gui.GuiPackage; 41 import org.apache.jmeter.util.JMeterUtils; 42 43 50 public class AboutCommand implements Command 51 { 52 private static Set commandSet; 53 private static JDialog about; 54 55 static 56 { 57 HashSet commands = new HashSet (); 58 commands.add("about"); 59 AboutCommand.commandSet = Collections.unmodifiableSet(commands); 60 } 61 62 67 public void doAction(ActionEvent e) 68 { 69 if (e.getActionCommand().equals("about")) 70 { 71 this.about(); 72 } 73 } 74 75 78 public Set getActionNames() 79 { 80 return AboutCommand.commandSet; 81 } 82 83 88 void about() 89 { 90 JFrame mainFrame = GuiPackage.getInstance().getMainFrame(); 91 if (about == null) 92 { 93 about = new JDialog (mainFrame, "About Apache JMeter...", false); 94 about.addMouseListener(new MouseAdapter () 95 { 96 public void mouseClicked(MouseEvent e) 97 { 98 about.setVisible(false); 99 } 100 }); 101 102 JLabel jmeter = new JLabel (JMeterUtils.getImage("jmeter.jpg")); 103 JLabel copyright = 104 new JLabel ( 105 JMeterUtils.getJMeterCopyright(), 106 JLabel.CENTER); 107 JLabel rights = new JLabel ("All Rights Reserved.", JLabel.CENTER); 108 JLabel version = 109 new JLabel ( 110 "Apache JMeter Version " + JMeterUtils.getJMeterVersion(), 111 JLabel.CENTER); 112 JPanel infos = new JPanel (); 113 infos.setOpaque(false); 114 infos.setLayout(new GridLayout (0, 1)); 115 infos.setBorder(new EmptyBorder (5, 5, 5, 5)); 116 infos.add(copyright); 117 infos.add(rights); 118 infos.add(version); 119 Container panel = about.getContentPane(); 120 panel.setLayout(new BorderLayout ()); 121 panel.setBackground(Color.white); 122 panel.add(jmeter, BorderLayout.NORTH); 123 panel.add(infos, BorderLayout.SOUTH); 124 } 125 126 Point p = mainFrame.getLocationOnScreen(); 131 Dimension d1 = mainFrame.getSize(); 132 Dimension d2 = about.getSize(); 133 about.setLocation( 134 p.x + (d1.width - d2.width) / 2, 135 p.y + (d1.height - d2.height) / 2); 136 about.pack(); 137 about.setVisible(true); 138 } 139 } 140 | Popular Tags |