1 package com.ca.commons.cbutil; 2 3 import javax.swing.*; 4 import java.awt.*; 5 import java.awt.event.*; 6 import java.io.File ; 7 import java.io.IOException ; 8 9 10 15 16 public class CBAbout extends JDialog 17 { 18 19 private JTextArea information; private JLabel productLogoLabel, caLogoLabel; private JPanel buttonsPanel, bottomPanel; 22 private CBButton okButton; 23 private static final int width = 477; private static final int height = 288; private JFrame owner; 26 27 28 31 private static final String URL = "http://www.ca.com"; 32 33 44 45 46 public CBAbout(JFrame frame, String message, ImageIcon caLogoImage, ImageIcon productLogoImage, 47 String okButtonMessage, String okButtonTooltip, String aboutDialogTitle) 48 { 49 super(frame, aboutDialogTitle, true); 50 51 owner = frame; 52 53 54 setBackground(Color.white); 55 56 Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); 57 setBounds((screen.width - width) / 2, (screen.height - height) / 2, width, height); 58 59 setSize(width, height); 60 setResizable(false); 61 62 65 productLogoLabel = new JLabel(productLogoImage); 66 productLogoLabel.setBackground(Color.white); 67 getContentPane().add(productLogoLabel, BorderLayout.NORTH); 68 69 73 JPanel infoPanel = new JPanel(new GridLayout(1, 0)); 74 infoPanel.setBackground(Color.white); 75 information = new JTextArea(message); 76 information.setBackground(Color.white); 77 information.setOpaque(true); 78 information.setEditable(false); 79 80 JScrollPane textPane = new JScrollPane(information); 81 textPane.setBackground(Color.white); 82 textPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS); 83 infoPanel.add(textPane); 84 infoPanel.setBorder(BorderFactory.createLineBorder(Color.white, 15)); 85 getContentPane().add(infoPanel, BorderLayout.CENTER); 86 87 91 bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); 92 bottomPanel.setBackground(Color.white); 93 caLogoLabel = new JLabel(caLogoImage); 94 caLogoLabel.setToolTipText("i am ca"); 95 96 caLogoLabel.addMouseListener(new MouseAdapter() 97 { 98 102 public void mouseEntered(MouseEvent e) 103 { 104 CBUtility.setHandCursor((Component) caLogoLabel); 105 } 106 107 111 public void mouseExited(MouseEvent e) 112 { 113 CBUtility.setNormalCursor((Component) caLogoLabel); 114 } 115 116 119 public void mouseClicked(MouseEvent e) 120 { 121 iAmCa(); 122 } 123 }); 124 bottomPanel.add(caLogoLabel); 125 bottomPanel.add(new JLabel(" ")); 126 127 131 buttonsPanel = new JPanel(new FlowLayout()); 132 buttonsPanel.setBackground(Color.white); 133 134 buttonsPanel.add(new JLabel("")); 136 buttonsPanel.add(new JLabel("")); 137 138 okButton = new CBButton(okButtonMessage, okButtonTooltip); 139 okButton.addActionListener(new ActionListener() 140 { 141 public void actionPerformed(ActionEvent e) 142 { 143 setVisible(false); 144 } 145 }); 146 buttonsPanel.add(okButton); 147 bottomPanel.add(buttonsPanel); 148 getContentPane().add(bottomPanel, BorderLayout.SOUTH); 149 } 150 151 152 156 157 public void iAmCa() 158 { 159 if (System.getProperty("os.name").indexOf("Windows") >= 0) 160 CBLauncher.launchProgram(".html", URL); 161 else 162 { 163 164 String browserName; 165 166 FileDialog fileDialog = new FileDialog(owner); 168 fileDialog.setMode(FileDialog.LOAD); 169 fileDialog.setTitle("Choose the browser to use:"); 170 fileDialog.setVisible(true); 171 172 String resultPath = fileDialog.getDirectory(); 174 String resultFile = fileDialog.getFile(); 175 if (resultPath != null && resultPath.length() != 0 && resultFile != null && resultFile.length() != 0) 176 { 177 File file = new File (resultPath + resultFile); 178 if (file != null) 179 { 180 browserName = file.getPath(); 181 182 try 183 { 184 Runtime.getRuntime().exec(new String []{browserName, URL}); 186 } 187 catch (IOException exc) 188 { 189 exc.printStackTrace(); 190 } 191 } 192 } 193 } 194 } 195 } | Popular Tags |