Package realcix20.guis.views

Source Code of realcix20.guis.views.LicenseView

package realcix20.guis.views;

import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Insets;
import java.awt.event.KeyEvent;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextPane;

import realcix20.guis.components.LanguageChooser;
import realcix20.guis.listeners.LicenseListener;
import realcix20.guis.utils.ImageManager;
import realcix20.guis.utils.MnemonicGenerator;
import realcix20.guis.utils.TxtManager;
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 LicenseView extends JFrame {
   
    private LicenseListener listener;
    private LanguageChooser languageChooser;
    private JTextPane licenseTextPane;
    private JButton acceptButton;
    private JButton exitButton;
   
    public LicenseView() {
        listener = new LicenseListener(this);
        languageChooser = new LanguageChooser();
        licenseTextPane = new JTextPane();
        acceptButton = new JButton();
        exitButton = new JButton();
        initComponents();
    }
   
    private void initComponents() {       
        addWindowListener(listener);
        CellConstraints cc = new CellConstraints();
        Container contentPane = getContentPane();
        contentPane.setLayout(new FormLayout(
            ColumnSpec.decodeSpecs("default:grow"),
            new RowSpec[] {
                    FormFactory.DEFAULT_ROWSPEC,
                    FormFactory.LINE_GAP_ROWSPEC,
                    new RowSpec(RowSpec.FILL, Sizes.DEFAULT, FormSpec.DEFAULT_GROW),
                    FormFactory.LINE_GAP_ROWSPEC,
                    FormFactory.DEFAULT_ROWSPEC
            }));
        JPanel topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));       
        languageChooser.setActionCommand("Change Language");
        languageChooser.addActionListener(listener);
        languageChooser.setPreferredSize(new Dimension(100, 20));
        languageChooser.setSelectedLang(GlobalValueManager.getValue("deflang"));
        topPanel.add(languageChooser);
        contentPane.add(topPanel, cc.xy(1, 1));
       
        licenseTextPane.setEditable(false);
        JScrollPane licenseScrollPane = new JScrollPane();
        licenseScrollPane.setPreferredSize(new Dimension(500, 400));
        licenseScrollPane.setViewportView(licenseTextPane);
        contentPane.add(licenseScrollPane, new CellConstraints(1, 3, 1, 1, CellConstraints.DEFAULT, CellConstraints.DEFAULT, new Insets( 0, 5, 0, 5)));
       
        JPanel bottomPanel = new JPanel(new FlowLayout(FlowLayout.CENTER));
        acceptButton.setText(MnemonicGenerator.generateMnemonicString(TxtManager.getTxt("VIEW.GLOBAL.ACCEPTBUTTON"), KeyEvent.VK_A));
        acceptButton.setMnemonic(KeyEvent.VK_A);
        acceptButton.setPreferredSize(new Dimension(75, 20));
        acceptButton.setActionCommand("Accept");
        acceptButton.addActionListener(listener);
        bottomPanel.add(acceptButton);       
        exitButton.setText(MnemonicGenerator.generateMnemonicString(TxtManager.getTxt("VIEW.GLOBAL.EXITBUTTON"), KeyEvent.VK_C));
        exitButton.setMnemonic(KeyEvent.VK_X);
        exitButton.setPreferredSize(new Dimension(75, 20));
        exitButton.setActionCommand("Exit");
        exitButton.addActionListener(listener);
        bottomPanel.add(exitButton);
        contentPane.add(bottomPanel, cc.xy(1, 5));
       
        pack();
        setResizable(false);
        setVisible(true);
        setLocationRelativeTo(null);
        setTitle(TxtManager.getTxt("VIEW.APPLICATION.TITLE"));
        setIconImage(ImageManager.getImage(ImageManager.REALCIX_APP_IAMGE).getImage());
        setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    }

    public LanguageChooser getLanguageChooser() {
        return languageChooser;
    }

    public JTextPane getLicenseTextPane() {
        return licenseTextPane;
    }

    public JButton getAcceptButton() {
        return acceptButton;
    }

    public JButton getExitButton() {
        return exitButton;
    }
   
}
TOP

Related Classes of realcix20.guis.views.LicenseView

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.