www.pudn.com > JSystemTrader.zip > AboutDialog.java


package com.jsystemtrader.client; 
 
import java.awt.*; 
import java.awt.event.*; 
import java.util.*; 
 
import javax.swing.*; 
 
import com.ib.client.*; 
import com.jsystemtrader.platform.*; 
import com.jsystemtrader.util.*; 
 
/** 
 * Dialog to show the application info, system info, and IB info. 
 */ 
public class AboutDialog extends JDialog { 
 
    /* inner class to define the "about" model */ 
    private class AboutTableModel extends TableDataModel { 
        public AboutTableModel() { 
            String[] aboutSchema = {"Property", "Value"}; 
            setSchema(aboutSchema); 
        } 
    } 
 
 
    /* inner class to launch a browser and display a web page */ 
    private class HyperLinkActionListener implements ActionListener { 
        public void actionPerformed(ActionEvent e) { 
            String url = e.getActionCommand(); 
            Browser.openURL(url); 
        } 
    } 
 
 
    public AboutDialog(JFrame parent) { 
        super(parent); 
        jbInit(); 
        pack(); 
        setLocationRelativeTo(parent); 
        setVisible(true); 
    } 
 
    private void jbInit() { 
        setModal(true); 
        setDefaultCloseOperation(DISPOSE_ON_CLOSE); 
        setTitle("About " + JSystemTrader.APP_NAME); 
 
        HyperLinkActionListener hyperLinkListener = new HyperLinkActionListener(); 
 
        JPanel contentPanel = new JPanel(new BorderLayout()); 
        getContentPane().add(contentPanel, BorderLayout.CENTER); 
 
        JTabbedPane tabbedPane1 = new JTabbedPane(); 
        contentPanel.add(tabbedPane1, BorderLayout.CENTER); 
 
        JPanel aboutPanel = new JPanel(new SpringLayout()); 
        JPanel apiPanel = new JPanel(new SpringLayout()); 
 
        tabbedPane1.addTab("About", aboutPanel); 
        tabbedPane1.addTab("API Info", apiPanel); 
 
        Dimension dimension = new Dimension(150, 23); 
 
        JLabel productLabel = new JLabel("Product:", JLabel.TRAILING); 
        JLabel productValueLabel = new JLabel(JSystemTrader.APP_NAME); 
        productValueLabel.setForeground(Color.BLACK); 
        productValueLabel.setPreferredSize(dimension); 
        productValueLabel.setMaximumSize(dimension); 
        productLabel.setLabelFor(productValueLabel); 
        aboutPanel.add(productLabel); 
        aboutPanel.add(productValueLabel); 
 
        JLabel versionLabel = new JLabel("Version:", JLabel.TRAILING); 
        JLabel versionValueLabel = new JLabel("4.12, January 4, 2007"); 
        versionValueLabel.setForeground(Color.BLACK); 
        versionValueLabel.setPreferredSize(dimension); 
        versionValueLabel.setMaximumSize(dimension); 
        versionLabel.setLabelFor(versionValueLabel); 
        aboutPanel.add(versionLabel); 
        aboutPanel.add(versionValueLabel); 
 
        JLabel authorLabel = new JLabel("Author:", JLabel.TRAILING); 
        JLabel authorValueLabel = new JLabel("Eugene Kononov"); 
        authorValueLabel.setForeground(Color.BLACK); 
        authorValueLabel.setPreferredSize(dimension); 
        authorValueLabel.setMaximumSize(dimension); 
        authorLabel.setLabelFor(authorValueLabel); 
        aboutPanel.add(authorLabel); 
        aboutPanel.add(authorValueLabel); 
 
        JLabel emailLabel = new JLabel("Email:", JLabel.TRAILING); 
        JLabel emailValueLabel = new JLabel("nonlinear5@yahoo.com"); 
        emailValueLabel.setForeground(Color.BLACK); 
        emailValueLabel.setPreferredSize(dimension); 
        emailValueLabel.setMaximumSize(dimension); 
        emailLabel.setLabelFor(productValueLabel); 
        aboutPanel.add(emailLabel); 
        aboutPanel.add(emailValueLabel); 
 
        JLabel licenseLabel = new JLabel("License:", JLabel.TRAILING); 
        JLabel licenseValueLabel = new JLabel("BSD (Open Source)"); 
        licenseValueLabel.setForeground(Color.BLACK); 
        licenseValueLabel.setPreferredSize(dimension); 
        licenseValueLabel.setMaximumSize(dimension); 
        licenseLabel.setLabelFor(licenseValueLabel); 
        aboutPanel.add(licenseLabel); 
        aboutPanel.add(licenseValueLabel); 
 
        JLabel userManualLabel = new JLabel("User Manual:", JLabel.TRAILING); 
        JButton userManualButton = new JButton("Online User Manual"); 
        userManualButton.setActionCommand("http://www.myjavaserver.com/~nonlinear/JSystemTrader/UserManual.pdf"); 
        userManualButton.addActionListener(hyperLinkListener); 
        userManualButton.setPreferredSize(dimension); 
        userManualButton.setMaximumSize(dimension); 
        userManualLabel.setLabelFor(userManualButton); 
        aboutPanel.add(userManualLabel); 
        aboutPanel.add(userManualButton); 
 
        JLabel supportLabel = new JLabel("Support:", JLabel.TRAILING); 
        JButton supportButton = new JButton("Discussion Thread"); 
        supportButton.setActionCommand( 
                "http://www.interactivebrokers.com/cgi-bin/discus/board-auth.pl?lm=1167502383&file=/2/38821.html"); 
        supportButton.addActionListener(hyperLinkListener); 
        supportButton.setPreferredSize(dimension); 
        supportButton.setMaximumSize(dimension); 
        supportLabel.setLabelFor(supportButton); 
        aboutPanel.add(supportLabel); 
        aboutPanel.add(supportButton); 
 
        JLabel homePageLabel = new JLabel("Home Page:", JLabel.TRAILING); 
        JButton homePageButton = new JButton("JSystemTrader"); 
        homePageButton.setActionCommand("http://www.myjavaserver.com/~nonlinear/JSystemTrader/JSystemTrader.html"); 
        homePageButton.addActionListener(hyperLinkListener); 
        homePageButton.setPreferredSize(dimension); 
        homePageButton.setMaximumSize(dimension); 
        homePageLabel.setLabelFor(homePageButton); 
        aboutPanel.add(homePageLabel); 
        aboutPanel.add(homePageButton); 
 
        // rows, cols, initX, initY, xPad, yPad 
        SpringUtilities.makeCompactGrid(aboutPanel, 8, 2, 10, 5, 10, 5); 
 
        JLabel serverVersionLabel = new JLabel("Server Version:", JLabel.TRAILING); 
        String serverVersion = "Disconnected from server"; 
        Trader trader = Account.getTrader(); 
        if (trader != null) { 
            int version = trader.getAssistant().getServerVersion(); 
            if (version != 0) { 
                serverVersion = String.valueOf(version); 
            } 
        } 
        JLabel serverVersionValueLabel = new JLabel(serverVersion); 
        serverVersionValueLabel.setForeground(Color.BLACK); 
        serverVersionValueLabel.setPreferredSize(dimension); 
        serverVersionValueLabel.setMaximumSize(dimension); 
        serverVersionLabel.setLabelFor(serverVersionValueLabel); 
        apiPanel.add(serverVersionLabel); 
        apiPanel.add(serverVersionValueLabel); 
 
        JLabel clientVersionLabel = new JLabel("Client Version:", JLabel.TRAILING); 
        JLabel clientVersionValueLabel = new JLabel("" + EClientSocket.CLIENT_VERSION); 
        clientVersionValueLabel.setForeground(Color.BLACK); 
        clientVersionValueLabel.setPreferredSize(dimension); 
        clientVersionValueLabel.setMaximumSize(dimension); 
        clientVersionLabel.setLabelFor(clientVersionValueLabel); 
        apiPanel.add(clientVersionLabel); 
        apiPanel.add(clientVersionValueLabel); 
 
        // rows, cols, initX, initY, xPad, yPad 
        SpringUtilities.makeCompactGrid(apiPanel, 2, 2, 10, 5, 10, 5); 
 
        JPanel systemInfoPanel = new JPanel(new BorderLayout(5, 5)); 
        tabbedPane1.addTab("System Info", systemInfoPanel); 
 
        JScrollPane systemInfoScrollPane = new JScrollPane(); 
        systemInfoPanel.add(systemInfoScrollPane, BorderLayout.CENTER); 
 
        TableDataModel aboutModel = new AboutTableModel(); 
        systemInfoScrollPane.getViewport().add(new JTable(aboutModel)); 
 
        getContentPane().setPreferredSize(new Dimension(453, 280)); 
 
        Properties properties = System.getProperties(); 
        Enumeration propNames = properties.propertyNames(); 
 
        while (propNames.hasMoreElements()) { 
            String key = (String) propNames.nextElement(); 
            String value = properties.getProperty(key); 
            String[] item = {key, value}; 
            aboutModel.addData(item); 
        } 
    } 
}