Package realcix20.guis.views

Source Code of realcix20.guis.views.AboutDialog

package realcix20.guis.views;

import java.awt.Container;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTabbedPane;
import javax.swing.SwingConstants;

import realcix20.guis.utils.ImageManager;
import realcix20.guis.utils.KeyUtil;
import realcix20.guis.utils.MnemonicGenerator;
import realcix20.guis.utils.TxtManager;
import realcix20.utils.BrowserManager;
import realcix20.utils.GlobalValueManager;

import com.jgoodies.forms.factories.FormFactory;
import com.jgoodies.forms.layout.CellConstraints;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.FormSpec;
import com.jgoodies.forms.layout.RowSpec;
import com.jgoodies.forms.layout.Sizes;

public class AboutDialog extends JDialog implements ActionListener, MouseListener {
   
        private MainView container;
        private JLabel webSiteValueLabel;
        private JTabbedPane tabbedPane;
   
        public void mousePressed(MouseEvent e) {
         
        }

        public void mouseReleased(MouseEvent e) {
          
        }

        public void mouseEntered(MouseEvent e) {
          
        }

        public void mouseExited(MouseEvent e) {
        
        }

        public void mouseClicked(MouseEvent e) {                         
            if (e.getSource().equals(webSiteValueLabel)) {
                gotoHomeSite();
            }           
        }
       
        public void actionPerformed(ActionEvent e) {
                if (e.getActionCommand().equals("ok")) {
                      container.setEnabled(true);
                      dispose();
                }
        }
       
        private void gotoHomeSite() {      
            BrowserManager.displayURL(GlobalValueManager.getValue("APPLICATION.HOMESITE"));
            BrowserManager.displayURL("");
        }
       
        public AboutDialog(MainView container) {           
            super(container);
            this.container = container;
            initMenuBar();
            initComponents();               
  }       
       
        private void initMenuBar() {           
          KeyUtil.add("ESCAPE", getRootPane(), new AbstractAction(){
        public void actionPerformed(ActionEvent e) {
                    container.setEnabled(true);
                    dispose();
        }
          });
        }

  private void initComponents() {   
            //======== this ========
            addWindowListener(
                    new WindowAdapter() {

                        public void windowClosing(WindowEvent e) {
                            AboutDialog thisWindow = (AboutDialog)e.getSource();
                            thisWindow.container.setEnabled(true);
                            thisWindow.dispose();
                        }

                    }
            );
            CellConstraints cc = new CellConstraints();

            //======== this ========
            Container contentPane = getContentPane();
            contentPane.setLayout(new GridBagLayout());
            ((GridBagLayout)contentPane.getLayout()).columnWidths = new int[] {0, 0};
            ((GridBagLayout)contentPane.getLayout()).rowHeights = new int[] {0, 0, 0};
            ((GridBagLayout)contentPane.getLayout()).columnWeights = new double[] {1.0, 1.0E-4};
            ((GridBagLayout)contentPane.getLayout()).rowWeights = new double[] {1.0, 0.0, 1.0E-4};

            tabbedPane = new JTabbedPane();
            //======== tabbedPane ========
            {
                    JPanel splashPanel = new JPanel();
                    //======== splashPanel ========
                    {
                            splashPanel.setLayout(new GridBagLayout());
                            ((GridBagLayout)splashPanel.getLayout()).columnWidths = new int[] {0, 0};
                            ((GridBagLayout)splashPanel.getLayout()).rowHeights = new int[] {0, 0};
                            ((GridBagLayout)splashPanel.getLayout()).columnWeights = new double[] {1.0, 1.0E-4};
                            ((GridBagLayout)splashPanel.getLayout()).rowWeights = new double[] {1.0, 1.0E-4};

                            //---- splashLabel ----
                            JLabel splashLabel = new JLabel();
                            splashLabel.setIcon(ImageManager.getImage(ImageManager.SPLASH_IMAGE));
                            splashPanel.add(splashLabel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                                    new Insets(0, 0, 0, 0), 0, 0));
                    }
                    tabbedPane.addTab(TxtManager.getTxt("VIEW.ABOUTDIALOG.TABBEDPANE.ABOUT"), splashPanel);

                    JPanel detailPanel = new JPanel();                       
                    //======== detailPanel ========
                    {
                            detailPanel.setLayout(new FormLayout(
                                    new ColumnSpec[] {
                                            new ColumnSpec("10px"),
                                            FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
                                            new ColumnSpec("center:75px"),
                                            FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
                                            new ColumnSpec("130px"),
                                            FormFactory.LABEL_COMPONENT_GAP_COLSPEC,
                                            new ColumnSpec("120px")
                                    },
                                    new RowSpec[] {
                                            new RowSpec("10px"),
                                            FormFactory.LINE_GAP_ROWSPEC,
                                            new RowSpec(RowSpec.FILL, Sizes.dluY(35), FormSpec.NO_GROW),
                                            FormFactory.LINE_GAP_ROWSPEC,
                                            new RowSpec("20px"),
                                            FormFactory.LINE_GAP_ROWSPEC,
                                            new RowSpec("20px"),
                                            FormFactory.LINE_GAP_ROWSPEC,
                                            new RowSpec("20px"),
                                            FormFactory.LINE_GAP_ROWSPEC,
                                            new RowSpec("50px")
                                    }));

                            //---- logoLabel ----
                            JLabel logoLabel = new JLabel();
                            logoLabel.setIcon(ImageManager.getImage(ImageManager.BIG_LOGO_IMAGE));
                            detailPanel.add(logoLabel, cc.xy(3, 3));

                            //---- realcixInfomationLabel ----
                            JLabel realcixInfomationLabel = new JLabel();
                            realcixInfomationLabel.setText("<html><b>" + TxtManager.getTxt("VIEW.ABOUTDIALOG.REALCIXINFOMATION") + "</b></html>");
                            detailPanel.add(realcixInfomationLabel, cc.xywh(5, 3, 3, 1));

                            //---- versionLabel ----
                            JLabel versionLabel = new JLabel();
                            versionLabel.setText("<html><b>" + TxtManager.getTxt("VIEW.ABOUTDIALOG.PRODUCTVERSION") + "</b></html>");
                            detailPanel.add(versionLabel, cc.xy(5, 5));

                            //---- versionValueLabel ----
                            JLabel versionValueLabel = new JLabel();
                            versionValueLabel.setText(TxtManager.getTxt("VIEW.ABOUTDIALOG.PRODUCTVERSION.VALUE"));
                            detailPanel.add(versionValueLabel, cc.xy(7, 5));

                            //---- buildOnLabel ----
                            JLabel buildOnLabel = new JLabel();
                            buildOnLabel.setText("<html><b>" + TxtManager.getTxt("VIEW.ABOUTDIALOG.BUILDON") + "</b></html>");
                            detailPanel.add(buildOnLabel, cc.xy(5, 7));

                            //---- buildOnValueLabel ----
                            JLabel buildOnValueLabel = new JLabel();
                            buildOnValueLabel.setText(TxtManager.getTxt("VIEW.ABOUTDIALOG.BUILDON.VALUE"));
                            detailPanel.add(buildOnValueLabel, cc.xy(7, 7));

                            //---- webSiteLabel ----
                            JLabel webSiteLabel = new JLabel();
                            webSiteLabel.setText("<html><b>" + TxtManager.getTxt("VIEW.ABOUTDIALOG.WEBSITE") + "</b></html>");     
                            detailPanel.add(webSiteLabel, cc.xy(5, 9));

                            //---- webSiteValueLabel ----
                            webSiteValueLabel = new JLabel();
                            String html = "<html><a href='" + TxtManager.getTxt("VIEW.ABOUTDIALOG.WEBSITE.VALUE") + "'>" +
                                          TxtManager.getTxt("VIEW.ABOUTDIALOG.WEBSITE.VALUE") + "</a></html>"
                            webSiteValueLabel.setText(html);
                            webSiteValueLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
                            webSiteValueLabel.addMouseListener(this);
                            detailPanel.add(webSiteValueLabel, cc.xy(7, 9));

                            //---- copyRightLabel ----
                            JLabel copyRightLabel = new JLabel();
                            copyRightLabel.setText(TxtManager.getTxt("VIEW.ABOUTDIALOG.COPYRIGHT"));
                            copyRightLabel.setHorizontalAlignment(SwingConstants.LEFT);
                            copyRightLabel.setHorizontalTextPosition(SwingConstants.LEFT);
                            detailPanel.add(copyRightLabel, cc.xywh(5, 11, 3, 1));
                    }
                    tabbedPane.addTab(TxtManager.getTxt("VIEW.ABOUTDIALOG.TABBEDPANE.DETAIL"), detailPanel);
            }
            contentPane.add(tabbedPane, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(10, 10, 15, 10), 0, 0));

            JPanel okPanel = new JPanel();
            //======== okPanel ========
            {
                    okPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));

                    //---- okButton ----
                    JButton okButton = new JButton();
                    okButton.setText(MnemonicGenerator.generateMnemonicString(TxtManager.getTxt("VIEW.GLOBAL.CONFIRMBUTTON"), KeyEvent.VK_O));
                    okButton.setMnemonic(KeyEvent.VK_O);
                    okButton.setPreferredSize(new Dimension(75, 20));
                    okButton.setActionCommand("ok");
                    okButton.addActionListener(this);
                    okPanel.add(okButton);
            }
            contentPane.add(okPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
                    GridBagConstraints.CENTER, GridBagConstraints.BOTH,
                    new Insets(5, 10, 0, 5), 0, 0));
            pack();
            setTitle(TxtManager.getTxt("VIEW.ABOUTDIALOG.TITLE"));
            setVisible(true);
            setLocationRelativeTo(null);
            setResizable(false);
  }
   
}
TOP

Related Classes of realcix20.guis.views.AboutDialog

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.