Example usage for java.awt GridBagConstraints HORIZONTAL

List of usage examples for java.awt GridBagConstraints HORIZONTAL

Introduction

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

Prototype

int HORIZONTAL

To view the source code for java.awt GridBagConstraints HORIZONTAL.

Click Source Link

Document

Resize the component horizontally but not vertically.

Usage

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

public CustomerPanel() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 0, 0, 0, 0 };
    gridBagLayout.rowHeights = new int[] { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE };
    gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0 };
    setLayout(gridBagLayout);/*  w  w  w .ja v a2s  . c  o m*/

    JLabel lblProduct = new JLabel("\u4EA7\u54C1\uFF1A");
    GridBagConstraints gbc_lblProduct = new GridBagConstraints();
    gbc_lblProduct.insets = new Insets(0, 0, 5, 5);
    gbc_lblProduct.anchor = GridBagConstraints.EAST;
    gbc_lblProduct.gridx = 0;
    gbc_lblProduct.gridy = 0;
    add(lblProduct, gbc_lblProduct);

    comboBoxProduct = new JComboBox();
    GridBagConstraints gbc_comboBoxProduct = new GridBagConstraints();
    gbc_comboBoxProduct.insets = new Insets(0, 0, 5, 5);
    gbc_comboBoxProduct.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBoxProduct.gridx = 1;
    gbc_comboBoxProduct.gridy = 0;
    add(comboBoxProduct, gbc_comboBoxProduct);

    JButton btnRefresh = new JButton("");
    btnRefresh.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            initProduct();
        }
    });
    btnRefresh.setIcon(new ImageIcon(CustomerPanel.class.getResource("/images/icon_refresh.png")));
    GridBagConstraints gbc_btnRefresh = new GridBagConstraints();
    gbc_btnRefresh.insets = new Insets(0, 0, 5, 0);
    gbc_btnRefresh.gridx = 2;
    gbc_btnRefresh.gridy = 0;
    add(btnRefresh, gbc_btnRefresh);

    JLabel lblProductVersion = new JLabel("\u4EA7\u54C1\u7248\u672C\uFF1A");
    GridBagConstraints gbc_lblProductVersion = new GridBagConstraints();
    gbc_lblProductVersion.anchor = GridBagConstraints.EAST;
    gbc_lblProductVersion.insets = new Insets(0, 0, 5, 5);
    gbc_lblProductVersion.gridx = 0;
    gbc_lblProductVersion.gridy = 1;
    add(lblProductVersion, gbc_lblProductVersion);

    textFieldProductVersion = new VersionTextField();
    textFieldProductVersion.setColumns(10);
    GridBagConstraints gbc_textFieldProductVersion = new GridBagConstraints();
    gbc_textFieldProductVersion.anchor = GridBagConstraints.WEST;
    gbc_textFieldProductVersion.insets = new Insets(0, 0, 5, 5);
    gbc_textFieldProductVersion.gridx = 1;
    gbc_textFieldProductVersion.gridy = 1;
    add(textFieldProductVersion, gbc_textFieldProductVersion);

    JLabel lblCompanyName = new JLabel("\u516C\u53F8\u540D\u79F0\uFF1A");
    GridBagConstraints gbc_lblCompanyName = new GridBagConstraints();
    gbc_lblCompanyName.anchor = GridBagConstraints.EAST;
    gbc_lblCompanyName.insets = new Insets(0, 0, 5, 5);
    gbc_lblCompanyName.gridx = 0;
    gbc_lblCompanyName.gridy = 2;
    add(lblCompanyName, gbc_lblCompanyName);

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

    JLabel lblCustomerCode = new JLabel("\u5BA2\u6237\u7F16\u53F7\uFF1A");
    GridBagConstraints gbc_lblCustomerCode = new GridBagConstraints();
    gbc_lblCustomerCode.anchor = GridBagConstraints.EAST;
    gbc_lblCustomerCode.insets = new Insets(0, 0, 5, 5);
    gbc_lblCustomerCode.gridx = 0;
    gbc_lblCustomerCode.gridy = 3;
    add(lblCustomerCode, gbc_lblCustomerCode);

    textFieldCustomerCode = new JTextField();
    GridBagConstraints gbc_textFieldCustomerCode = new GridBagConstraints();
    gbc_textFieldCustomerCode.insets = new Insets(0, 0, 5, 5);
    gbc_textFieldCustomerCode.fill = GridBagConstraints.HORIZONTAL;
    gbc_textFieldCustomerCode.gridx = 1;
    gbc_textFieldCustomerCode.gridy = 3;
    add(textFieldCustomerCode, gbc_textFieldCustomerCode);
    textFieldCustomerCode.setColumns(10);

    JLabel lblCustomerName = new JLabel("\u5BA2\u6237\u540D\u79F0\uFF1A");
    GridBagConstraints gbc_lblCustomerName = new GridBagConstraints();
    gbc_lblCustomerName.anchor = GridBagConstraints.EAST;
    gbc_lblCustomerName.insets = new Insets(0, 0, 5, 5);
    gbc_lblCustomerName.gridx = 0;
    gbc_lblCustomerName.gridy = 4;
    add(lblCustomerName, gbc_lblCustomerName);

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

    JLabel lblLicenseType = new JLabel("\u8BC1\u4E66\u7C7B\u578B\uFF1A");
    GridBagConstraints gbc_lblLicenseType = new GridBagConstraints();
    gbc_lblLicenseType.anchor = GridBagConstraints.EAST;
    gbc_lblLicenseType.insets = new Insets(0, 0, 5, 5);
    gbc_lblLicenseType.gridx = 0;
    gbc_lblLicenseType.gridy = 5;
    add(lblLicenseType, gbc_lblLicenseType);

    comboBoxLicenseType = new JComboBox();
    GridBagConstraints gbc_comboBoxLicenseType = new GridBagConstraints();
    gbc_comboBoxLicenseType.insets = new Insets(0, 0, 5, 5);
    gbc_comboBoxLicenseType.fill = GridBagConstraints.HORIZONTAL;
    gbc_comboBoxLicenseType.gridx = 1;
    gbc_comboBoxLicenseType.gridy = 5;
    add(comboBoxLicenseType, gbc_comboBoxLicenseType);

    JLabel lblExpiredDate = new JLabel("\u8FC7\u671F\u65F6\u95F4\uFF1A");
    GridBagConstraints gbc_lblExpiredDate = new GridBagConstraints();
    gbc_lblExpiredDate.insets = new Insets(0, 0, 5, 5);
    gbc_lblExpiredDate.gridx = 0;
    gbc_lblExpiredDate.gridy = 6;
    add(lblExpiredDate, gbc_lblExpiredDate);

    datePickerExpiredDate = new DatePicker(new Date(), "yyyy-MM-dd", null, null);
    GridBagConstraints gbc_datePicker = new GridBagConstraints();
    gbc_datePicker.anchor = GridBagConstraints.WEST;
    gbc_datePicker.insets = new Insets(0, 0, 5, 5);
    gbc_datePicker.gridx = 1;
    gbc_datePicker.gridy = 6;
    add(datePickerExpiredDate, gbc_datePicker);

    JButton btnSave = new JButton("\u4FDD\u5B58");
    btnSave.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            try {
                //????????
                if (comboBoxProduct.getSelectedIndex() <= 0) {
                    JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "??");
                    return;
                }
                String[] array = StringUtils.split(comboBoxProduct.getSelectedItem().toString(), '-');
                String productCode = array[0];
                String productName = array[1];
                String customerCode = textFieldCustomerCode.getText();

                //??
                File configFile = ResourceUtils.getFile(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) {
                    JOptionPane.showMessageDialog(JOptionPane.getRootFrame(),
                            "???");
                    return;
                }

                String licenseId = new RandomGUID().toString();
                String licenseType = Utility.splitStringAll(comboBoxLicenseType.getSelectedItem().toString(),
                        " - ")[0];
                String companyName = textFieldCompanyName.getText();
                String customerName = textFieldCustomerName.getText();
                String version = textFieldProductVersion.getText();
                Date expiredDate = Utility.parseDate(datePickerExpiredDate.getText());

                License license = new License();
                license.setLicenseId(licenseId);
                license.setLicenseType(licenseType);
                license.setProductName(productName);
                license.setCompanyName(companyName);
                license.setCustomerName(customerName);
                license.setVersion(Version.parseVersion(version));
                license.setCreateDate(new Date());
                license.setExpiredDate(expiredDate);

                LicenseService service = new LicenseService();
                String productPath = Gui.HOME_PATH + File.separator + productCode;
                File licenseDir = new File(productPath, customerCode);
                if (!licenseDir.exists()) {
                    licenseDir.mkdir();
                    //?
                    FileUtils.copyFileToDirectory(new File(productPath, "license.key"), licenseDir);
                }
                File priKeyFile = new File(Gui.HOME_PATH + File.separator + productCode, "private.key");
                File licenseFile = new File(licenseDir, "license.xml");

                service.save(Gui.HOME_PATH, productCode, customerCode, license, priKeyFile, licenseFile);

                //??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(), customerCode + "-" + currentTime + ".zip"));
                //license
                FileUtils.deleteDirectory(licensePath);

                JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), "??");
            } catch (Exception e1) {
                e1.printStackTrace();
                JOptionPane.showMessageDialog(JOptionPane.getRootFrame(), e1.getMessage());
            }

        }
    });
    GridBagConstraints gbc_btnSave = new GridBagConstraints();
    gbc_btnSave.insets = new Insets(0, 0, 5, 5);
    gbc_btnSave.gridx = 1;
    gbc_btnSave.gridy = 7;
    add(btnSave, gbc_btnSave);

    //??
    initData();
}

From source file:com.sec.ose.osi.ui.frm.main.report.JPanReportMain.java

/**
 * This method initializes jPanel   //  w w w. j  a  va2 s . co m
 *    
 * @return javax.swing.JPanel   
 */
private JPanel getJPanelbutton() {
    if (jPanel == null) {
        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
        gridBagConstraints4.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints4.insets = new Insets(10, 0, 0, 10);
        gridBagConstraints4.anchor = GridBagConstraints.NORTH;
        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
        gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints5.insets = new Insets(10, 0, 0, 10);
        gridBagConstraints5.gridx = 0;
        gridBagConstraints5.gridy = 1;

        jPanel = new JPanel();
        jPanel.setLayout(new GridBagLayout());
        jPanel.add(getJButtonReportExport(), gridBagConstraints4);
    }
    return jPanel;
}

From source file:EditorPaneExample16.java

public EditorPaneExample16() {
    super("JEditorPane Example 16");

    pane = new JEditorPane();
    pane.setEditable(true); // Editable
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;//  w  w  w  . j  a va2  s  . com
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridy = 5;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    editableBox = new JCheckBox("Editable JEditorPane");
    panel.add(editableBox, c);
    editableBox.setSelected(true);
    editableBox.setForeground(typeLabel.getForeground());

    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Allocate the empty tree model
    DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty");
    emptyModel = new DefaultTreeModel(emptyRootNode);

    // Create and place the heading tree
    tree = new JTree(emptyModel);
    tree.setPreferredSize(new Dimension(200, 200));
    getContentPane().add(new JScrollPane(tree), "East");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            loadNewPage(selection);
        }
    });

    // Change editability based on the checkbox
    editableBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pane.setEditable(editableBox.isSelected());
            pane.revalidate();
            pane.repaint();
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                TreeNode node = buildHeadingTree(pane.getDocument());
                tree.setModel(new DefaultTreeModel(node));
                enableInput();
                loadingPage = false;
            }
        }
    });

    // Listener for tree selection
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent evt) {
            TreePath path = evt.getNewLeadSelectionPath();
            if (path != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                Object userObject = node.getUserObject();
                if (userObject instanceof Heading) {
                    Heading heading = (Heading) userObject;
                    try {
                        Rectangle textRect = pane.modelToView(heading.getOffset());
                        textRect.y += 3 * textRect.height;
                        pane.scrollRectToVisible(textRect);
                    } catch (BadLocationException e) {
                    }
                }
            }
        }
    });

    // Listener for hypertext events
    pane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            // Ignore hyperlink events if the frame is busy
            if (loadingPage == true) {
                return;
            }
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                JEditorPane sp = (JEditorPane) evt.getSource();
                if (evt instanceof HTMLFrameHyperlinkEvent) {
                    HTMLDocument doc = (HTMLDocument) sp.getDocument();
                    doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt);
                } else {
                    loadNewPage(evt.getURL());
                }
            } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                pane.setCursor(handCursor);
            } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) {
                pane.setCursor(defaultCursor);
            }
        }
    });
}

From source file:EditorPaneExample17.java

public EditorPaneExample17() {
    super("JEditorPane Example 17");

    pane = new JEditorPane();
    pane.setEditable(true); // Editable
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;/*from  ww  w .j  av a2  s  .  c om*/
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridy = 5;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    editableBox = new JCheckBox("Editable JEditorPane");
    panel.add(editableBox, c);
    editableBox.setSelected(true);
    editableBox.setForeground(typeLabel.getForeground());

    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Register a custom EditorKit for HTML
    ClassLoader loader = getClass().getClassLoader();
    if (loader != null) {
        // Java 2
        JEditorPane.registerEditorKitForContentType("text/html",
                "AdvancedSwing.Chapter4.HiddenViewHTMLEditorKit", loader);
    } else {
        // JDK 1.1
        JEditorPane.registerEditorKitForContentType("text/html",
                "AdvancedSwing.Chapter4.HiddenViewHTMLEditorKit");
    }

    // Allocate the empty tree model
    DefaultMutableTreeNode emptyRootNode = new DefaultMutableTreeNode("Empty");
    emptyModel = new DefaultTreeModel(emptyRootNode);

    // Create and place the heading tree
    tree = new JTree(emptyModel);
    tree.setPreferredSize(new Dimension(200, 200));
    getContentPane().add(new JScrollPane(tree), "East");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            loadNewPage(selection);
        }
    });

    // Change editability based on the checkbox
    editableBox.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            pane.setEditable(editableBox.isSelected());
            pane.revalidate();
            pane.repaint();
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                TreeNode node = buildHeadingTree(pane.getDocument());
                tree.setModel(new DefaultTreeModel(node));
                enableInput();
                loadingPage = false;
            }
        }
    });

    // Listener for tree selection
    tree.addTreeSelectionListener(new TreeSelectionListener() {
        public void valueChanged(TreeSelectionEvent evt) {
            TreePath path = evt.getNewLeadSelectionPath();
            if (path != null) {
                DefaultMutableTreeNode node = (DefaultMutableTreeNode) path.getLastPathComponent();
                Object userObject = node.getUserObject();
                if (userObject instanceof Heading) {
                    Heading heading = (Heading) userObject;
                    try {
                        Rectangle textRect = pane.modelToView(heading.getOffset());
                        textRect.y += 3 * textRect.height;
                        pane.scrollRectToVisible(textRect);
                    } catch (BadLocationException e) {
                    }
                }
            }
        }
    });

    // Listener for hypertext events
    pane.addHyperlinkListener(new HyperlinkListener() {
        public void hyperlinkUpdate(HyperlinkEvent evt) {
            // Ignore hyperlink events if the frame is busy
            if (loadingPage == true) {
                return;
            }
            if (evt.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
                JEditorPane sp = (JEditorPane) evt.getSource();
                if (evt instanceof HTMLFrameHyperlinkEvent) {
                    HTMLDocument doc = (HTMLDocument) sp.getDocument();
                    doc.processHTMLFrameHyperlinkEvent((HTMLFrameHyperlinkEvent) evt);
                } else {
                    loadNewPage(evt.getURL());
                }
            } else if (evt.getEventType() == HyperlinkEvent.EventType.ENTERED) {
                pane.setCursor(handCursor);
            } else if (evt.getEventType() == HyperlinkEvent.EventType.EXITED) {
                pane.setCursor(defaultCursor);
            }
        }
    });
}

From source file:de.fhg.igd.iva.explorer.main.CompareViewPanel.java

protected void updateSelection() {
    KnownColormap colormap = (KnownColormap) mapsCombo.getSelectedItem();

    cmView.setColormap(colormap);//from www .j  a v a  2 s  .c  o  m

    statsBars.removeAll();

    Map<ColormapQuality, Double> row = table.row(colormap);

    Insets insets = new Insets(0, 0, 0, 0);
    Insets insets5 = new Insets(0, 5, 0, 0);

    GridBagConstraints gbcName = new GridBagConstraints(0, 0, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_START,
            GridBagConstraints.NONE, insets, 0, 0);
    GridBagConstraints gbcQual = new GridBagConstraints(1, 0, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END,
            GridBagConstraints.NONE, insets5, 0, 0);
    GridBagConstraints gbcRank = new GridBagConstraints(2, 0, 1, 1, 0.0, 1.0, GridBagConstraints.LINE_END,
            GridBagConstraints.NONE, insets5, 0, 0);
    GridBagConstraints gbcStatL = new GridBagConstraints(3, 0, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_START,
            GridBagConstraints.NONE, insets5, 0, 0);
    GridBagConstraints gbcStatR = new GridBagConstraints(4, 0, 1, 1, 1.0, 1.0, GridBagConstraints.LINE_END,
            GridBagConstraints.NONE, insets5, 0, 0);
    GridBagConstraints gbcStat = new GridBagConstraints(3, 0, 2, 1, 1.0, 1.0, GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL, insets5, 0, 0);

    statsBars.add(new JLabel("Name"), gbcName);
    statsBars.add(new JLabel("Score"), gbcQual);
    statsBars.add(new JLabel("Rank"), gbcRank);

    // maybe use a best/worst arrow down marker instead? unicode: \u2193
    statsBars.add(new JLabel("\u2190Worse"), gbcStatL);
    statsBars.add(new JLabel("Better\u2192"), gbcStatR);

    GridBagConstraints gbcSpace = new GridBagConstraints(0, 1, 5, 1, 1.0, 1.0, GridBagConstraints.LINE_START,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0);
    JSeparator spacing = new JSeparator(SwingConstants.HORIZONTAL);
    statsBars.add(spacing, gbcSpace);

    int count = table.rowKeySet().size();

    int rowIdx = 2;
    for (ColormapQuality metric : row.keySet()) {
        double quality = row.get(metric);
        DescriptiveStatistics stats = computeStats(metric);
        int index = Arrays.binarySearch(stats.getSortedValues(), quality);

        int rank = metric.moreIsBetter() ? count - index : index + 1;

        gbcName = (GridBagConstraints) gbcName.clone();
        gbcQual = (GridBagConstraints) gbcQual.clone();
        gbcRank = (GridBagConstraints) gbcRank.clone();
        gbcStat = (GridBagConstraints) gbcStat.clone();

        gbcName.gridy = rowIdx;
        gbcQual.gridy = rowIdx;
        gbcRank.gridy = rowIdx;
        gbcStat.gridy = rowIdx;

        statsBars.add(new JLabel(metric.getName()), gbcName);
        statsBars.add(new JLabel(String.format("%.2f", quality)), gbcQual);
        statsBars.add(new JLabel(Integer.toString(rank)), gbcRank);
        statsBars.add(new JStatBar(metric, stats, quality), gbcStat);
        rowIdx++;
    }

    // I find it strange that both revalidate and repaint must be explicitly called here
    revalidate();
    repaint();
}

From source file:com.simplexrepaginator.RepaginateFrame.java

public RepaginateFrame(FileRepaginator repaginator) {
    super("Simplex Repaginator version " + Repaginate.getVersion());
    setDefaultCloseOperation(DISPOSE_ON_CLOSE);

    this.repaginator = repaginator;

    setJMenuBar(createMenuBar());/*from  w w  w  . ja  va  2s .c  o m*/

    input = createInputButton();
    repaginate = createRepaginateButton();
    unrepaginate = createUnrepaginateButton();
    output = creatOutputButton();

    setLayout(new GridBagLayout());

    final GridBagConstraints c = new GridBagConstraints(0, 0, 1, 1, 1, 1, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0);

    c.gridwidth = 2;
    add(input, c);

    c.gridy++;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.VERTICAL;
    add(repaginate, c);
    c.gridx++;
    add(unrepaginate, c);

    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.BOTH;
    add(output, c);

    Runnable r = new Runnable() {
        @Override
        public void run() {
            UpdateChecker uc = new UpdateChecker();
            try {
                if (!uc.isUpdateAvailable())
                    return;
                final JLabel label = new JLabel("<html>Simplex Repaginator version " + uc.getLatestVersion()
                        + " is available.  " + "Choose <b>File > Check For Updates</b> to download.");
                EventQueue.invokeLater(new Runnable() {
                    @Override
                    public void run() {
                        c.gridy++;
                        c.weighty = 0;
                        c.fill = GridBagConstraints.HORIZONTAL;
                        add(label, c);
                        revalidate();
                    }
                });
            } catch (IOException ioe) {
            }
        }
    };
    new Thread(r).start();

    pack();
    setSize(800, 400);
}

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

/**
 * Creates a new SshToolsConnectionProxyTab object.
 *///from  www.jav  a2s  .  c  om
public SshToolsConnectionProxyTab() {
    super();
    group.add(noProxy);
    group.add(httpProxy);
    group.add(socks4Proxy);
    group.add(socks5Proxy);

    ChangeListener listener = new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (noProxy.isSelected()) {
                username.setEnabled(false);
                password.setEnabled(false);
                proxy.setEnabled(false);

                //port.setEnabled(false);
                port.setForeground(Color.white);
            } else {
                username.setEnabled(true);
                password.setEnabled(true);
                proxy.setEnabled(true);

                //port.setEnabled(true);
                port.setForeground(Color.black);

                if (httpProxy.isSelected()) {
                    port.setText("80");
                } else {
                    port.setText("1080");
                }
            }
        }
    };

    noProxy.getModel().addChangeListener(listener);
    httpProxy.getModel().addChangeListener(listener);
    socks4Proxy.getModel().addChangeListener(listener);
    socks5Proxy.getModel().addChangeListener(listener);

    //  Create the main connection details panel
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(0, 2, 2, 2);
    gbc.weightx = 1.0;
    proxyframe.setBorder(BorderFactory.createTitledBorder("Connect using the following proxy"));

    //  No proxy label
    gbc.insets = new Insets(2, 10, 2, 2);
    UIUtil.jGridBagAdd(proxyframe, noProxy, gbc, GridBagConstraints.RELATIVE);

    // Socks 4 label
    gbc.insets = new Insets(2, 15, 2, 2);
    UIUtil.jGridBagAdd(proxyframe, socks4Proxy, gbc, GridBagConstraints.REMAINDER);

    //gbc.fill = GridBagConstraints.HORIZONTAL;
    // Http Proxy
    gbc.insets = new Insets(2, 10, 2, 2);
    UIUtil.jGridBagAdd(proxyframe, httpProxy, gbc, GridBagConstraints.RELATIVE);

    // Socks 5 label
    gbc.insets = new Insets(2, 15, 2, 2);
    UIUtil.jGridBagAdd(proxyframe, socks5Proxy, gbc, GridBagConstraints.REMAINDER);

    gbc.insets = new Insets(2, 10, 2, 10);

    JPanel connect = new JPanel(new GridBagLayout());
    connect.setBorder(BorderFactory.createTitledBorder("Proxy Details"));
    UIUtil.jGridBagAdd(connect, new JLabel("Host"), gbc, GridBagConstraints.REMAINDER);

    UIUtil.jGridBagAdd(connect, proxy, gbc, GridBagConstraints.REMAINDER);

    UIUtil.jGridBagAdd(connect, new JLabel("Port"), gbc, GridBagConstraints.REMAINDER);
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;

    UIUtil.jGridBagAdd(connect, port, gbc, GridBagConstraints.REMAINDER);
    gbc.fill = GridBagConstraints.HORIZONTAL;

    UIUtil.jGridBagAdd(connect, new JLabel("Username"), gbc, GridBagConstraints.REMAINDER);

    UIUtil.jGridBagAdd(connect, username, gbc, GridBagConstraints.REMAINDER);

    UIUtil.jGridBagAdd(connect, new JLabel("Password"), gbc, GridBagConstraints.REMAINDER);
    gbc.insets = new Insets(2, 10, 10, 10);
    UIUtil.jGridBagAdd(connect, password, gbc, GridBagConstraints.REMAINDER);

    JPanel main = new JPanel(new GridBagLayout());
    gbc.insets = new Insets(2, 2, 2, 2);
    UIUtil.jGridBagAdd(main, proxyframe, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, connect, gbc, GridBagConstraints.REMAINDER);

    IconWrapperPanel iconProxyDetailsPanel = new IconWrapperPanel(new ResourceIcon(PROXY_ICON), main);
    noProxy.setSelected(true);

    //  This panel
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.weightx = 1.0;
    add(iconProxyDetailsPanel, BorderLayout.NORTH);
}

From source file:medsavant.enrichment.app.OntologyAggregatePanel.java

public OntologyAggregatePanel(String page) {
    super(page);//ww w  .ja v  a2  s.c o m
    setLayout(new GridBagLayout());

    chooser = new JComboBox(OntologyListItem.DEFAULT_ITEMS);
    chooser.setMaximumSize(new Dimension(400, chooser.getMaximumSize().height));
    progress = new JProgressBar();
    progress.setPreferredSize(new Dimension(600, progress.getMaximumSize().height));
    progress.setStringPainted(true);

    JPanel banner = new JPanel();
    banner.setLayout(new GridBagLayout());
    banner.setBackground(new Color(245, 245, 245));
    banner.setBorder(BorderFactory.createTitledBorder("Ontology"));

    tree = new TreeTable();

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.anchor = GridBagConstraints.WEST;
    banner.add(chooser, gbc);
    gbc.anchor = GridBagConstraints.EAST;
    banner.add(progress, gbc);

    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    add(banner, gbc);

    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.BOTH;
    add(new JScrollPane(tree), gbc);

    chooser.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (termFetcher != null) {
                termFetcher.cancel(true);
                termFetcher = null;
            }
            recalculate();
        }
    });

    tree.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseReleased(MouseEvent e) {
            if (SwingUtilities.isRightMouseButton(e)) {
                createPopup().show(e.getComponent(), e.getX(), e.getY());
            }
        }
    });
}

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

/**
 * Create the panel./* ww  w .  j  a  va 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);

}

From source file:com.sec.ose.osi.ui.frm.main.report.JPanExportReport.java

private JPanel getJPanMain() {
    if (jPanMain == null) {
        jPanMain = new JPanel();

        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints1.gridx = 0;/*from w  w w .  ja  va  2  s .  c o  m*/
        gridBagConstraints1.gridy = 0;
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints2.gridx = 0;
        gridBagConstraints2.gridy = 1;
        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints3.gridx = 0;
        gridBagConstraints3.gridy = 2;
        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
        gridBagConstraints4.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints4.gridx = 0;
        gridBagConstraints4.gridy = 3;

        jPanMain.add(getJPanelForCreatorInfo(), gridBagConstraints1);
        jPanMain.add(getJPanelForDocumentExportInfo(), gridBagConstraints2);
        jPanMain.add(getJPanelForReportTypeInfo(), gridBagConstraints3);
        jPanMain.add(getJButtonPanel(), gridBagConstraints4);
    }

    return jPanMain;
}