Example usage for java.awt GridBagConstraints GridBagConstraints

List of usage examples for java.awt GridBagConstraints GridBagConstraints

Introduction

In this page you can find the example usage for java.awt GridBagConstraints GridBagConstraints.

Prototype

public GridBagConstraints() 

Source Link

Document

Creates a GridBagConstraint object with all of its fields set to their default value.

Usage

From source file:SimpleAuthenticator.java

protected PasswordAuthentication getPasswordAuthentication() {

    // given a prompt?
    String prompt = getRequestingPrompt();
    if (prompt == null)
        prompt = "Please login...";

    // protocol/*from  w  ww . j ava2 s .  c om*/
    String protocol = getRequestingProtocol();
    if (protocol == null)
        protocol = "Unknown protocol";

    // get the host
    String host = null;
    InetAddress inet = getRequestingSite();
    if (inet != null)
        host = inet.getHostName();
    if (host == null)
        host = "Unknown host";

    // port
    String port = "";
    int portnum = getRequestingPort();
    if (portnum != -1)
        port = ", port " + portnum + " ";

    // Build the info string
    String info = "Connecting to " + protocol + " mail service on host " + host + port;

    //JPanel d = new JPanel();
    // XXX - for some reason using a JPanel here causes JOptionPane
    // to display incorrectly, so we workaround the problem using
    // an anonymous JComponent.
    JComponent d = new JComponent() {
    };

    GridBagLayout gb = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    d.setLayout(gb);
    c.insets = new Insets(2, 2, 2, 2);

    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 0.0;
    d.add(constrain(new JLabel(info), gb, c));
    d.add(constrain(new JLabel(prompt), gb, c));

    c.gridwidth = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    d.add(constrain(new JLabel("Username:"), gb, c));

    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;
    String user = getDefaultUserName();
    JTextField username = new JTextField(user, 20);
    d.add(constrain(username, gb, c));

    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    c.weightx = 0.0;
    d.add(constrain(new JLabel("Password:"), gb, c));

    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;
    JPasswordField password = new JPasswordField("", 20);
    d.add(constrain(password, gb, c));
    // XXX - following doesn't work
    if (user != null && user.length() > 0)
        password.requestFocus();
    else
        username.requestFocus();

    int result = JOptionPane.showConfirmDialog(frame, d, "Login", JOptionPane.OK_CANCEL_OPTION,
            JOptionPane.QUESTION_MESSAGE);

    if (result == JOptionPane.OK_OPTION)
        return new PasswordAuthentication(username.getText(), password.getText());
    else
        return null;
}

From source file:com.digitalgeneralists.assurance.ui.components.FileAttributesPanel.java

private void initializeComponent() {
    if (!this.initialized) {
        if (this.file == null) {
            this.dialogTitle = "No File Provided";
            this.file = null;
        } else {/*from  w w  w. j  av  a 2s.c  om*/
            StringBuilder title = new StringBuilder(128);
            this.dialogTitle = title.append("Attributes for ").append(file.getFile().getName()).toString();
            title.setLength(0);
            title = null;
        }

        GridBagLayout gridbag = new GridBagLayout();
        this.setLayout(gridbag);

        GridBagConstraints filePanelConstraints = new GridBagConstraints();
        filePanelConstraints.anchor = GridBagConstraints.NORTH;
        filePanelConstraints.fill = GridBagConstraints.HORIZONTAL;
        filePanelConstraints.gridx = 0;
        filePanelConstraints.gridy = 0;
        filePanelConstraints.weightx = 1.0;
        filePanelConstraints.weighty = 0.1;
        filePanelConstraints.gridheight = 1;
        filePanelConstraints.gridwidth = 1;
        filePanelConstraints.insets = new Insets(5, 5, 5, 5);

        final JPanel filePanel = new JPanel();
        filePanel.setLayout(new GridBagLayout());

        GridBagConstraints filePathValueConstraints = new GridBagConstraints();
        filePathValueConstraints.anchor = GridBagConstraints.WEST;
        filePathValueConstraints.gridx = 0;
        filePathValueConstraints.gridy = 0;
        filePathValueConstraints.weightx = 1.0;
        filePathValueConstraints.weighty = 1.0;
        filePathValueConstraints.gridheight = 1;
        filePathValueConstraints.gridwidth = 1;
        filePathValueConstraints.insets = new Insets(5, 5, 5, 5);

        String filePath = "File is null.";
        if (file != null) {
            File diskFile = file.getFile();
            if (diskFile == null) {
                filePath = "The disk file is not set.";
            } else {
                filePath = diskFile.getPath();
            }
            diskFile = null;
        }
        JLabel filePathValue = new JLabel(filePath);
        filePath = null;
        filePanel.add(filePathValue, filePathValueConstraints);

        this.add(filePanel, filePanelConstraints);

        Border attributesBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        attributesBorder = BorderFactory.createTitledBorder(attributesBorder, "File Attributes",
                TitledBorder.CENTER, TitledBorder.TOP);

        GridBagConstraints attributesPanelConstraints = new GridBagConstraints();
        attributesPanelConstraints.anchor = GridBagConstraints.SOUTH;
        attributesPanelConstraints.fill = GridBagConstraints.BOTH;
        attributesPanelConstraints.gridx = 0;
        attributesPanelConstraints.gridy = 1;
        attributesPanelConstraints.weightx = 1.0;
        attributesPanelConstraints.weighty = 0.9;
        attributesPanelConstraints.gridheight = 1;
        attributesPanelConstraints.gridwidth = 1;
        attributesPanelConstraints.insets = new Insets(0, 5, 5, 5);

        JPanel attributesPanel = this.createFileAttributesPanel(file);

        attributesPanel.setBorder(attributesBorder);

        this.add(attributesPanel, attributesPanelConstraints);

        this.initialized = true;
    }
}

From source file:PizzaGridBagLayout.java

private void addItem(JPanel p, JComponent c, int x, int y, int width, int height, int align) {
    GridBagConstraints gc = new GridBagConstraints();
    gc.gridx = x;/*from  w w  w  . j  a v  a 2  s.c  om*/
    gc.gridy = y;
    gc.gridwidth = width;
    gc.gridheight = height;
    gc.weightx = 100.0;
    gc.weighty = 100.0;
    gc.insets = new Insets(5, 5, 5, 5);
    gc.anchor = align;
    gc.fill = GridBagConstraints.NONE;
    p.add(c, gc);
}

From source file:com.sshtools.common.ui.OptionsPanel.java

/**
 *
 *
 * @param parent//  w w w  .ja  va2  s .  c om
 * @param tabs tabs
 *
 * @return
 */
public static boolean showOptionsDialog(Component parent, OptionsTab[] tabs) {
    final OptionsPanel opts = new OptionsPanel(tabs);
    opts.reset();

    JDialog d = null;
    Window w = (Window) SwingUtilities.getAncestorOfClass(Window.class, parent);

    if (w instanceof JDialog) {
        d = new JDialog((JDialog) w, "Options", true);
    } else if (w instanceof JFrame) {
        d = new JDialog((JFrame) w, "Options", true);
    } else {
        d = new JDialog((JFrame) null, "Options", true);
    }

    final JDialog dialog = d;

    //  Create the bottom button panel
    final JButton cancel = new JButton("Cancel");
    cancel.setMnemonic('c');
    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            opts.cancelled = true;
            dialog.setVisible(false);
        }
    });

    final JButton ok = new JButton("Ok");
    ok.setMnemonic('o');
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (opts.validateTabs()) {
                dialog.setVisible(false);
            }
        }
    });
    dialog.getRootPane().setDefaultButton(ok);

    JPanel buttonPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(6, 6, 0, 0);
    gbc.weighty = 1.0;
    UIUtil.jGridBagAdd(buttonPanel, ok, gbc, GridBagConstraints.RELATIVE);
    UIUtil.jGridBagAdd(buttonPanel, cancel, gbc, GridBagConstraints.REMAINDER);

    JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
    southPanel.add(buttonPanel);

    //
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    mainPanel.add(opts, BorderLayout.CENTER);
    mainPanel.add(southPanel, BorderLayout.SOUTH);

    // Show the dialog
    dialog.getContentPane().setLayout(new GridLayout(1, 1));
    dialog.getContentPane().add(mainPanel);
    dialog.pack();
    dialog.setResizable(true);
    UIUtil.positionComponent(SwingConstants.CENTER, dialog);
    dialog.setVisible(true);

    if (!opts.cancelled) {
        opts.applyTabs();
    }

    return !opts.cancelled;
}

From source file:com.digitalgeneralists.assurance.ui.components.ExclusionsPanel.java

@Override
protected void initializeComponent() {
    if (!this.initialized) {
        if (this.exclusion == null) {
            this.mode = AssuranceDialogMode.ADD;
            this.dialogTitle = "Add New Exclusion";
            this.exclusion = new FileReference();
        } else {/*from   w ww . j a  va  2 s  .c om*/
            this.mode = AssuranceDialogMode.EDIT;
            this.dialogTitle = "Edit Exclusion";
        }

        GridBagLayout gridbag = new GridBagLayout();
        this.setLayout(gridbag);

        final JPanel exclusionPathPanel = new JPanel();
        exclusionPathPanel.setLayout(new GridBagLayout());

        Border exclusionPanelBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        exclusionPanelBorder = BorderFactory.createTitledBorder(exclusionPanelBorder, "Exclusion",
                TitledBorder.CENTER, TitledBorder.TOP);

        GridBagConstraints exclusionPathPanelConstraints = new GridBagConstraints();
        exclusionPathPanelConstraints.anchor = GridBagConstraints.NORTH;
        exclusionPathPanelConstraints.fill = GridBagConstraints.HORIZONTAL;
        exclusionPathPanelConstraints.gridx = 0;
        exclusionPathPanelConstraints.gridy = 0;
        exclusionPathPanelConstraints.weightx = 1.0;
        exclusionPathPanelConstraints.weighty = 1.0;
        exclusionPathPanelConstraints.gridheight = 1;
        exclusionPathPanelConstraints.gridwidth = 2;
        exclusionPathPanelConstraints.insets = new Insets(5, 5, 5, 5);

        exclusionPathPanel.setBorder(exclusionPanelBorder);
        this.add(exclusionPathPanel, exclusionPathPanelConstraints);

        GridBagConstraints exclusionPathFieldConstraints = new GridBagConstraints();
        exclusionPathFieldConstraints.anchor = GridBagConstraints.NORTH;
        exclusionPathFieldConstraints.fill = GridBagConstraints.HORIZONTAL;
        exclusionPathFieldConstraints.gridx = 0;
        exclusionPathFieldConstraints.gridy = 1;
        exclusionPathFieldConstraints.weightx = 1.0;
        exclusionPathFieldConstraints.weighty = 1.0;
        exclusionPathFieldConstraints.gridheight = 1;
        exclusionPathFieldConstraints.gridwidth = 1;
        exclusionPathFieldConstraints.insets = new Insets(5, 5, 5, 5);

        exclusionPathPanel.add(this.exclusionPathTextFieldPicker, exclusionPathFieldConstraints);

        if (this.exclusion != null) {
            File exclusionPath = exclusion.getFile();
            if (exclusionPath != null) {
                this.exclusionPathTextFieldPicker.setValue(exclusionPath.getPath());
            } else {
                this.exclusionPathTextFieldPicker.setValue("");
            }
        }

        this.initialized = true;
    }
}

From source file:MessageViewer.java

/**
 * sets the current message to be displayed in the viewer
 *///from ww w  .ja v a  2  s.  co  m
public void setMessage(Message what) {
    displayed = what;

    if (mainbody != null)
        remove(mainbody);

    if (what != null) {
        loadHeaders();
        mainbody = getBodyComponent();
    } else {
        headers.setText("");
        TextArea dummy = new TextArea("", 24, 80, TextArea.SCROLLBARS_NONE);
        dummy.setEditable(false);
        mainbody = dummy;
    }

    // add the main body
    GridBagConstraints gb = new GridBagConstraints();
    gb.gridwidth = GridBagConstraints.REMAINDER;
    gb.fill = GridBagConstraints.BOTH;
    gb.weightx = 1.0;
    gb.weighty = 1.0;
    add(mainbody, gb);

    invalidate();
    validate();
}

From source file:com.jostrobin.battleships.view.frames.GameFrame.java

private void addGamePanel(int gridX, int gridY, int gridWidth) {
    GridBagConstraints battlefieldConstraints = new GridBagConstraints();
    battlefieldConstraints.weightx = 1.0;
    battlefieldConstraints.weighty = 0.8;
    battlefieldConstraints.gridy = gridY;
    battlefieldConstraints.gridx = gridX;
    battlefieldConstraints.gridwidth = gridWidth;
    battlefieldConstraints.anchor = GridBagConstraints.ABOVE_BASELINE_LEADING;
    battlefieldConstraints.fill = GridBagConstraints.BOTH;
    add(gamePanel, battlefieldConstraints);
}

From source file:interpolation.InteractiveRegression.java

public void Card() {

    CardLayout cl = new CardLayout();

    panelCont.setLayout(cl);/*from  www  . j a  v  a 2s  .  c o  m*/

    panelCont.add(panelFirst, "1");
    panelCont.add(panelSecond, "2");

    panelFirst.setName("Regression Polynomial Fits");

    /* Instantiation */
    final GridBagLayout layout = new GridBagLayout();
    final GridBagConstraints c = new GridBagConstraints();

    final Scrollbar degreeSB = new Scrollbar(Scrollbar.HORIZONTAL, this.degreeInt, 1, MIN_SLIDER,
            MAX_SLIDER + 1);

    final Label degreeLabel = new Label("Degree of polynomial = " + this.degree, Label.CENTER);

    // Location
    panelFirst.setLayout(layout);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;

    ++c.gridy;
    c.insets = new Insets(30, 150, 0, 150);
    panelFirst.add(degreeSB, c);

    ++c.gridy;
    c.insets = new Insets(30, 150, 0, 150);
    panelFirst.add(degreeLabel, c);

    degreeSB.addAdjustmentListener(new DegreeListener(this, degreeLabel, degreeSB));

    panelFirst.setVisible(true);
    cl.show(panelCont, "1");
    Cardframe.add(panelCont, BorderLayout.CENTER);

    Cardframe.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    Cardframe.pack();
    Cardframe.setVisible(true);
    updateRegression();
}

From source file:Demo.ScatterGraph.java

public ScatterGraph(int sampleNb, List<String> paraType_list) {
    this.sampleNb = sampleNb;
    this.paraType_list = paraType_list;

    // widgets: charts(JFreeChart), parameter selectors (JList)
    DefaultListModel xModel = new DefaultListModel();
    xSelector = new JList(xModel);
    JScrollPane xSelPane = new JScrollPane();
    xSelPane.setViewportView(xSelector);

    DefaultListModel yModel = new DefaultListModel();
    ySelector = new JList(yModel);
    JScrollPane ySelPane = new JScrollPane();
    ySelPane.setViewportView(ySelector);

    charts = new JFreeChart[paraType_list.size()][paraType_list.size()];
    for (int i = 0; i < paraType_list.size(); i++) {
        String para = paraType_list.get(i);
        xModel.addElement(para);/*from   w  w w.  j  a v  a 2s .  co  m*/
        yModel.addElement(para);

        for (int j = 0; j < paraType_list.size(); j++) {
            charts[i][j] = null;
        }
    }

    charts[0][0] = CreateChart(0, 0);
    chartPane = new ChartPanel(charts[0][0]);

    xSelector.setSelectedIndex(0);
    ySelector.setSelectedIndex(0);

    xSelector.addMouseListener(this);
    ySelector.addMouseListener(this);

    // layout
    GridBagLayout layout = new GridBagLayout();
    setLayout(layout);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.BOTH;

    gbc.insets = new Insets(5, 20, 5, 5);
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 20;
    gbc.weighty = 12;
    gbc.gridheight = 4;
    add(chartPane, gbc);

    gbc.insets = new Insets(5, 5, 5, 20);
    gbc.gridx = 1;
    gbc.weightx = 1;
    gbc.gridheight = 1;

    gbc.gridy = 0;
    gbc.weighty = 1;
    add(new JLabel("X :"), gbc);
    gbc.gridy = 2;
    add(new JLabel("Y :"), gbc);

    gbc.gridy = 1;
    gbc.weighty = 5;
    add(xSelPane, gbc);
    gbc.gridy = 3;
    add(ySelPane, gbc);
}

From source file:com.litt.core.security.license.gui.ConfigPanel.java

/**
 * Create the panel./*from   w ww  .  j  a v a  2 s .  c  o  m*/
 */
public ConfigPanel(final Gui gui) {
    GridBagLayout gbl_configPanel = new GridBagLayout();
    gbl_configPanel.columnWidths = new int[] { 0, 0, 0, 0 };
    gbl_configPanel.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    gbl_configPanel.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };
    gbl_configPanel.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0,
            Double.MIN_VALUE };
    this.setLayout(gbl_configPanel);

    JLabel label_18 = new JLabel("?");
    GridBagConstraints gbc_label_18 = new GridBagConstraints();
    gbc_label_18.insets = new Insets(0, 0, 5, 5);
    gbc_label_18.anchor = GridBagConstraints.EAST;
    gbc_label_18.gridx = 0;
    gbc_label_18.gridy = 0;
    this.add(label_18, gbc_label_18);

    comboBox_config = new JComboBox();
    comboBox_config.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                try {
                    LicenseConfig licenseConfig = (LicenseConfig) e.getItem();
                    File licenseFile = new File(licenseConfig.getLicenseFilePath());
                    currentLicenseConfig = licenseConfig;
                    loadLicense(licenseFile);
                    gui.setCurrentLicenseConfig(currentLicenseConfig);
                } catch (Exception e1) {
                    JOptionPane.showMessageDialog(self, e1.getMessage());
                }
            }
        }
    });
    GridBagConstraints gbc_comboBox_config = new GridBagConstraints();
    gbc_comboBox_config.insets = new Insets(0, 0, 5, 5);
    gbc_comboBox_config.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBox_config.gridx = 1;
    gbc_comboBox_config.gridy = 0;
    this.add(comboBox_config, gbc_comboBox_config);

    JButton button_3 = new JButton("?");
    button_3.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {

            try {
                comboBox_config.removeAllItems();

                File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml");

                Document document = XmlUtils.readXml(configFile);
                Element rootE = document.getRootElement();
                List productList = rootE.elements();
                for (int i = 0; i < productList.size(); i++) {
                    Element productE = (Element) productList.get(i);
                    String productCode = productE.attributeValue("code");

                    List customerList = productE.elements();
                    for (int j = 0; j < customerList.size(); j++) {
                        Element customerE = (Element) customerList.get(j);
                        String customerCode = customerE.attributeValue("code");

                        LicenseConfig licenseConfig = new LicenseConfig();
                        licenseConfig.setProductCode(productCode);
                        licenseConfig.setCustomerCode(customerCode);
                        licenseConfig.setLicenseId(customerE.elementText("licenseId"));
                        licenseConfig.setEncryptedLicense(customerE.elementText("encryptedLicense"));
                        licenseConfig.setRootFilePath(Gui.HOME_PATH);
                        licenseConfig.setLicenseFilePath(Gui.HOME_PATH + File.separator + productCode
                                + File.separator + customerCode + File.separator + "license.xml");
                        licenseConfig.setPriKeyFilePath(
                                Gui.HOME_PATH + File.separator + productCode + File.separator + "private.key");
                        licenseConfig.setPubKeyFilePath(
                                Gui.HOME_PATH + File.separator + productCode + File.separator + "license.key");
                        comboBox_config.addItem(licenseConfig);
                        if (i == 0 && j == 0) {
                            File licenseFile = new File(licenseConfig.getLicenseFilePath());
                            currentLicenseConfig = licenseConfig;
                            loadLicense(licenseFile);
                            gui.setCurrentLicenseConfig(currentLicenseConfig);

                            btnDelete.setEnabled(true);
                        }
                    }
                }

            } catch (Exception e1) {
                e1.printStackTrace();
                JOptionPane.showMessageDialog(self, e1.getMessage());
            }

        }
    });

    btnDelete = new JButton();
    btnDelete.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (currentLicenseConfig != null) {
                try {
                    String productCode = currentLicenseConfig.getProductCode();
                    String customerCode = currentLicenseConfig.getCustomerCode();
                    //congfig.xml
                    File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml");
                    Document document = XmlUtils.readXml(configFile);

                    Element customerNode = (Element) document.selectSingleNode(
                            "//product[@code='" + productCode + "']/customer[@code='" + customerCode + "']");
                    if (customerNode != null) {
                        customerNode.detach();
                        XmlUtils.writeXml(configFile, document);
                    }
                    //                  
                    File licensePathFile = new File(currentLicenseConfig.getLicenseFilePath());
                    if (licensePathFile.exists()) {
                        FileUtils.deleteDirectory(licensePathFile.getParentFile());
                    }

                    //comboboxitem
                    comboBox_config.removeItemAt(comboBox_config.getSelectedIndex());
                } catch (IOException e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                } catch (Exception e1) {
                    // TODO Auto-generated catch block
                    e1.printStackTrace();
                }
                if (comboBox_config.getItemCount() <= 0) {
                    btnDelete.setEnabled(false);
                }

            }
        }
    });
    btnDelete.setEnabled(false);
    btnDelete.setIcon(new ImageIcon(ConfigPanel.class.getResource("/images/icon_delete.png")));
    GridBagConstraints gbc_btnDelete = new GridBagConstraints();
    gbc_btnDelete.insets = new Insets(0, 0, 5, 0);
    gbc_btnDelete.gridx = 2;
    gbc_btnDelete.gridy = 0;
    add(btnDelete, gbc_btnDelete);
    GridBagConstraints gbc_button_3 = new GridBagConstraints();
    gbc_button_3.insets = new Insets(0, 0, 5, 5);
    gbc_button_3.gridx = 1;
    gbc_button_3.gridy = 1;
    this.add(button_3, gbc_button_3);

    JLabel lblid = new JLabel("?ID");
    GridBagConstraints gbc_lblid = new GridBagConstraints();
    gbc_lblid.anchor = GridBagConstraints.EAST;
    gbc_lblid.insets = new Insets(0, 0, 5, 5);
    gbc_lblid.gridx = 0;
    gbc_lblid.gridy = 2;
    this.add(lblid, gbc_lblid);

    textField_licenseId = new JTextField();
    GridBagConstraints gbc_textField_licenseId = new GridBagConstraints();
    gbc_textField_licenseId.insets = new Insets(0, 0, 5, 5);
    gbc_textField_licenseId.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_licenseId.gridx = 1;
    gbc_textField_licenseId.gridy = 2;
    this.add(textField_licenseId, gbc_textField_licenseId);
    textField_licenseId.setColumns(10);

    JLabel label = new JLabel("?");
    GridBagConstraints gbc_label = new GridBagConstraints();
    gbc_label.anchor = GridBagConstraints.EAST;
    gbc_label.insets = new Insets(0, 0, 5, 5);
    gbc_label.gridx = 0;
    gbc_label.gridy = 3;
    add(label, gbc_label);

    comboBox_licenseType = new JComboBox(MapComboBoxModel.getLicenseTypeOptions().toArray());
    GridBagConstraints gbc_comboBox_licenseType = new GridBagConstraints();
    gbc_comboBox_licenseType.insets = new Insets(0, 0, 5, 5);
    gbc_comboBox_licenseType.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBox_licenseType.gridx = 1;
    gbc_comboBox_licenseType.gridy = 3;
    add(comboBox_licenseType, gbc_comboBox_licenseType);

    JLabel label_23 = new JLabel("???");
    GridBagConstraints gbc_label_23 = new GridBagConstraints();
    gbc_label_23.anchor = GridBagConstraints.EAST;
    gbc_label_23.insets = new Insets(0, 0, 5, 5);
    gbc_label_23.gridx = 0;
    gbc_label_23.gridy = 4;
    this.add(label_23, gbc_label_23);

    textField_productName = new JTextField();
    GridBagConstraints gbc_textField_productName = new GridBagConstraints();
    gbc_textField_productName.insets = new Insets(0, 0, 5, 5);
    gbc_textField_productName.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_productName.gridx = 1;
    gbc_textField_productName.gridy = 4;
    this.add(textField_productName, gbc_textField_productName);
    textField_productName.setColumns(10);

    JLabel label_24 = new JLabel("???");
    GridBagConstraints gbc_label_24 = new GridBagConstraints();
    gbc_label_24.anchor = GridBagConstraints.EAST;
    gbc_label_24.insets = new Insets(0, 0, 5, 5);
    gbc_label_24.gridx = 0;
    gbc_label_24.gridy = 5;
    this.add(label_24, gbc_label_24);

    textField_companyName = new JTextField();
    GridBagConstraints gbc_textField_companyName = new GridBagConstraints();
    gbc_textField_companyName.insets = new Insets(0, 0, 5, 5);
    gbc_textField_companyName.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_companyName.gridx = 1;
    gbc_textField_companyName.gridy = 5;
    this.add(textField_companyName, gbc_textField_companyName);
    textField_companyName.setColumns(10);

    JLabel label_25 = new JLabel("??");
    GridBagConstraints gbc_label_25 = new GridBagConstraints();
    gbc_label_25.anchor = GridBagConstraints.EAST;
    gbc_label_25.insets = new Insets(0, 0, 5, 5);
    gbc_label_25.gridx = 0;
    gbc_label_25.gridy = 6;
    this.add(label_25, gbc_label_25);

    textField_customerName = new JTextField();
    GridBagConstraints gbc_textField_customerName = new GridBagConstraints();
    gbc_textField_customerName.insets = new Insets(0, 0, 5, 5);
    gbc_textField_customerName.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_customerName.gridx = 1;
    gbc_textField_customerName.gridy = 6;
    this.add(textField_customerName, gbc_textField_customerName);
    textField_customerName.setColumns(10);

    JLabel label_26 = new JLabel("");
    GridBagConstraints gbc_label_26 = new GridBagConstraints();
    gbc_label_26.anchor = GridBagConstraints.EAST;
    gbc_label_26.insets = new Insets(0, 0, 5, 5);
    gbc_label_26.gridx = 0;
    gbc_label_26.gridy = 7;
    this.add(label_26, gbc_label_26);

    textField_version = new JTextField();
    GridBagConstraints gbc_textField_version = new GridBagConstraints();
    gbc_textField_version.insets = new Insets(0, 0, 5, 5);
    gbc_textField_version.fill = GridBagConstraints.HORIZONTAL;
    gbc_textField_version.gridx = 1;
    gbc_textField_version.gridy = 7;
    this.add(textField_version, gbc_textField_version);
    textField_version.setColumns(10);

    JLabel label_27 = new JLabel("");
    GridBagConstraints gbc_label_27 = new GridBagConstraints();
    gbc_label_27.insets = new Insets(0, 0, 5, 5);
    gbc_label_27.gridx = 0;
    gbc_label_27.gridy = 8;
    this.add(label_27, gbc_label_27);

    datePicker_expiredDate = new DatePicker(new Date(), "yyyy-MM-dd", null, null);
    //datePicker_expiredDate.setTimePanleVisible(false);
    GridBagConstraints gbc_datePicker_expiredDate = new GridBagConstraints();
    gbc_datePicker_expiredDate.anchor = GridBagConstraints.WEST;
    gbc_datePicker_expiredDate.insets = new Insets(0, 0, 5, 5);
    gbc_datePicker_expiredDate.gridx = 1;
    gbc_datePicker_expiredDate.gridy = 8;
    this.add(datePicker_expiredDate, gbc_datePicker_expiredDate);

    JButton button_5 = new JButton("");
    button_5.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {

            if (currentLicenseConfig != null) {
                try {
                    File priKeyFile = new File(currentLicenseConfig.getPriKeyFilePath());
                    File licenseFile = new File(currentLicenseConfig.getLicenseFilePath());

                    //??
                    License license = new License();
                    license.setLicenseId(textField_licenseId.getText());
                    license.setLicenseType(
                            ((MapComboBoxModel) comboBox_licenseType.getSelectedItem()).getValue().toString());
                    license.setProductName(textField_productName.getText());
                    license.setCompanyName(textField_companyName.getText());
                    license.setCustomerName(textField_customerName.getText());
                    license.setVersion(Version.parseVersion(textField_version.getText()));
                    license.setCreateDate(new Date());
                    license.setExpiredDate(Utility.parseDate(datePicker_expiredDate.getText()));

                    //????
                    DigitalSignatureTool utils = new DigitalSignatureTool("DSA");
                    utils.readPriKey(priKeyFile.getAbsolutePath()); //??
                    String signedData = utils.sign(license.toString()); //??????
                    license.setSignature(signedData);

                    LicenseManager.writeLicense(license, licenseFile);
                    //config.xml
                    String licenseContent = XmlUtils.readXml(licenseFile).asXML();
                    //DES
                    ISecurity security = new DESTool(currentLicenseConfig.getLicenseId(), Algorithm.BLOWFISH);
                    licenseContent = security.encrypt(licenseContent);

                    txt_encryptContent.setText(licenseContent);
                    currentLicenseConfig.setEncryptedLicense(licenseContent);
                    System.out.println(licenseContent);
                    File configFile = new File(Gui.HOME_PATH + File.separator + "config.xml");

                    XMLConfiguration config = new XMLConfiguration(configFile);
                    config.setAutoSave(true);

                    config.setProperty("product.customer.encryptedLicense", licenseContent);

                    //??zip?
                    File customerPath = licenseFile.getParentFile();
                    //???license?????
                    File licensePath = new File(customerPath.getParent(), "license");
                    if (!licensePath.exists() && !licensePath.isDirectory()) {
                        licensePath.mkdir();
                    } else {
                        FileUtils.cleanDirectory(licensePath);
                    }

                    //?
                    FileUtils.copyDirectory(customerPath, licensePath);
                    String currentTime = FormatDateTime.formatDateTimeNum(new Date());
                    ZipUtils.zip(licensePath, new File(licensePath.getParentFile(),
                            currentLicenseConfig.getCustomerCode() + "-" + currentTime + ".zip"));

                    //license
                    FileUtils.deleteDirectory(licensePath);

                    JOptionPane.showMessageDialog(self, "??");
                } catch (Exception e1) {
                    e1.printStackTrace();
                    JOptionPane.showMessageDialog(self, e1.getMessage());
                }
            } else {
                JOptionPane.showMessageDialog(self, "???");
            }
        }
    });
    GridBagConstraints gbc_button_5 = new GridBagConstraints();
    gbc_button_5.insets = new Insets(0, 0, 5, 5);
    gbc_button_5.gridx = 1;
    gbc_button_5.gridy = 9;
    this.add(button_5, gbc_button_5);

    JScrollPane scrollPane = new JScrollPane();
    GridBagConstraints gbc_scrollPane = new GridBagConstraints();
    gbc_scrollPane.insets = new Insets(0, 0, 0, 5);
    gbc_scrollPane.fill = GridBagConstraints.BOTH;
    gbc_scrollPane.gridx = 1;
    gbc_scrollPane.gridy = 10;
    this.add(scrollPane, gbc_scrollPane);

    txt_encryptContent = new JTextArea();
    txt_encryptContent.setLineWrap(true);
    scrollPane.setViewportView(txt_encryptContent);

    //      txt_encryptContent = new JTextArea(20, 20);
    //      GridBagConstraints gbc_6 = new GridBagConstraints();
    //      gbc_6.gridx = 1;
    //      gbc_6.gridy = 10;
    //      this.add(txt_encryptContent, gbc_6);

}