Example usage for java.awt GridBagConstraints EAST

List of usage examples for java.awt GridBagConstraints EAST

Introduction

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

Prototype

int EAST

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

Click Source Link

Document

Put the component on the right side of its display area, centered vertically.

Usage

From source file:SocketApplet.java

/** Initialize the GUI nicely. */
public void init() {
    Label aLabel;/*from  w  w  w. j a  va2 s  . c o  m*/

    setLayout(new GridBagLayout());
    int LOGO_COL = 1;
    int LABEL_COL = 2;
    int TEXT_COL = 3;
    int BUTTON_COL = 1;
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 100.0;
    gbc.weighty = 100.0;

    gbc.gridx = LABEL_COL;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.EAST;
    add(aLabel = new Label("Name:", Label.CENTER), gbc);
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.gridx = TEXT_COL;
    gbc.gridy = 0;
    add(nameTF = new TextField(10), gbc);

    gbc.gridx = LABEL_COL;
    gbc.gridy = 1;
    gbc.anchor = GridBagConstraints.EAST;
    add(aLabel = new Label("Password:", Label.CENTER), gbc);
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.gridx = TEXT_COL;
    gbc.gridy = 1;
    add(passTF = new TextField(10), gbc);
    passTF.setEchoChar('*');

    gbc.gridx = LABEL_COL;
    gbc.gridy = 2;
    gbc.anchor = GridBagConstraints.EAST;
    add(aLabel = new Label("Domain:", Label.CENTER), gbc);
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.gridx = TEXT_COL;
    gbc.gridy = 2;
    add(domainTF = new TextField(10), gbc);
    sendButton = new Button("Send data");
    gbc.gridx = BUTTON_COL;
    gbc.gridy = 3;
    gbc.gridwidth = 3;
    add(sendButton, gbc);

    whence = getCodeBase();

    // Now the action begins...
    sendButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            String name = nameTF.getText();
            if (name.length() == 0) {
                showStatus("Name required");
                return;
            }
            String domain = domainTF.getText();
            if (domain.length() == 0) {
                showStatus("Domain required");
                return;
            }
            showStatus("Connecting to host " + whence.getHost() + " as " + nameTF.getText());

            try {
                Socket s = new Socket(getCodeBase().getHost(), 3333);
                PrintWriter pf = new PrintWriter(s.getOutputStream(), true);
                // send login name
                pf.println(nameTF.getText());
                // passwd
                pf.println(passTF.getText());
                // and domain
                pf.println(domainTF.getText());

                BufferedReader is = new BufferedReader(new InputStreamReader(s.getInputStream()));
                String response = is.readLine();
                showStatus(response);
            } catch (IOException e) {
                showStatus("ERROR: " + e.getMessage());
            }
        }
    });
}

From source file:EditorPaneExample18.java

public EditorPaneExample18() {
    super("JEditorPane Example 18");

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

    // Add a menu bar
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);//from  w w w  . jav a2  s  . c  o m

    // Populate it
    createMenuBar();

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

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;
    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.gridy = 6;
    c.weightx = 0.0;
    JButton saveButton = new JButton("Save");
    panel.add(saveButton, c);
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            EditorKit kit = pane.getEditorKit();
            try {
                if (kit instanceof RTFEditorKit) {
                    kit.write(System.out, pane.getDocument(), 0, pane.getDocument().getLength());
                    System.out.flush();
                } else {
                    if (writer == null) {
                        writer = new OutputStreamWriter(System.out);
                        pane.write(writer);
                        writer.flush();
                    }
                    kit.write(writer, pane.getDocument(), 0, pane.getDocument().getLength());
                    writer.flush();
                }
            } catch (Exception e) {
                System.out.println("Write failed");
            }
        }
    });

    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 1.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));

                createMenuBar();
                enableMenuBar(true);
                getRootPane().revalidate();

                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:org.openconcerto.erp.core.finance.accounting.ui.BilanPanel.java

public BilanPanel() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();

    this.add(new JLabel("Vous allez gnrer le fichier result_2033A.pdf contenant le bilan simplifi."), c);
    c.gridy++;/*from  w ww .  j av a 2s  . c om*/
    try {
        this.add(new JLabel("Il se trouvera dans le dossier "
                + new File(TemplateNXProps.getInstance().getStringProperty("Location2033APDF"))
                        .getCanonicalPath()),
                c);
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    /*
     * PdfGenerator_2033A p = new PdfGenerator_2033A(); p.generateFrom(new
     * Map2033A().getMap2033A());
     */

    JButton buttonFermer = new JButton("Fermer");
    buttonFermer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            ((JFrame) SwingUtilities.getRoot(BilanPanel.this)).dispose();
        }
    });

    JButton buttonOuvrirDossier = new JButton("Ouvrir dossier");
    buttonOuvrirDossier.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String file = TemplateNXProps.getInstance().getStringProperty("Location2033APDF");
            File f = new File(file);
            FileUtils.browseFile(f);
        };
    });

    // FIXME impossible de gnrer si le fichier est ouvert
    JButton buttonGenerer = new JButton("Gnrer");
    buttonGenerer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            Map2033A map = new Map2033A(new JProgressBar());
            map.generateMap2033A();
        };
    });

    c.gridx = GridBagConstraints.RELATIVE;
    c.gridwidth = 1;
    c.weightx = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(buttonOuvrirDossier, c);

    c.gridy++;
    c.anchor = GridBagConstraints.EAST;
    c.weightx = 1;
    buttonGenerer.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(buttonGenerer, c);
    c.weightx = 0;
    this.add(buttonFermer, c);
}

From source file:org.zaproxy.zap.view.MainToolbarPanel.java

public void initialise() {
    setLayout(new java.awt.GridBagLayout());
    setPreferredSize(DisplayUtils.getScaledDimension(getMaximumSize().width, 25));
    setMaximumSize(DisplayUtils.getScaledDimension(getMaximumSize().width, 25));
    this.setBorder(BorderFactory.createEtchedBorder());

    expandButtons = new ButtonGroup();

    GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
    GridBagConstraints gridBagConstraints2 = new GridBagConstraints();

    gridBagConstraints1.gridx = 0;//from  w ww  . j a  va 2  s .  c  o  m
    gridBagConstraints1.gridy = 0;
    gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST;

    gridBagConstraints2.gridx = 1;
    gridBagConstraints2.gridy = 0;
    gridBagConstraints2.weightx = 1.0;
    gridBagConstraints2.weighty = 1.0;
    gridBagConstraints2.anchor = java.awt.GridBagConstraints.EAST;
    gridBagConstraints2.fill = java.awt.GridBagConstraints.HORIZONTAL;

    JToolBar t1 = new JToolBar();
    t1.setEnabled(true);
    t1.setPreferredSize(new java.awt.Dimension(80000, 25));
    t1.setMaximumSize(new java.awt.Dimension(80000, 25));

    add(getToolbar(), gridBagConstraints1);
    add(t1, gridBagConstraints2);

    toolbar.add(getModeSelect());
    toolbar.add(getBtnNew());
    toolbar.add(getBtnOpen());
    toolbar.add(getBtnSave());
    toolbar.add(getBtnSnapshot());
    toolbar.add(getBtnSession());
    toolbar.add(getBtnOptions());

    toolbar.addSeparator();
    toolbar.add(getShowAllTabs());
    toolbar.add(getHideAllTabs());
    toolbar.add(getShowTabIconNames());
    toolbar.addSeparator();

    toolbar.add(getBtnExpandSites());
    toolbar.add(getBtnExpandReports());
    toolbar.add(getBtnExpandFull());

    toolbar.addSeparator();
}

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);//from w w w .java2  s  .  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:org.openconcerto.erp.core.finance.accounting.ui.EtatJournauxPanel.java

public EtatJournauxPanel() {
    super();/*from   w w w  .j  a  v  a  2 s. co  m*/

    this.tabbedJournaux = new JTabbedPane();

    this.setLayout(new GridBagLayout());

    final GridBagConstraints c = new DefaultGridBagConstraints();
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 1;
    c.weighty = 1;

    this.add(this.tabbedJournaux, c);

    JButton buttonImpression = new JButton("Impression");
    JButton buttonClose = new JButton("Fermer");
    c.gridx = 0;
    c.gridy++;
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    this.add(buttonImpression, c);
    c.gridx++;
    c.weightx = 0;
    this.add(buttonClose, c);

    buttonClose.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ((JFrame) SwingUtilities.getRoot(EtatJournauxPanel.this)).dispose();
        };
    });
    buttonImpression.addActionListener(new ImpressionJournauxAction());
}

From source file:org.jets3t.gui.ProgressPanel.java

private void initGui() {
    // Initialise skins factory.
    skinsFactory = SkinsFactory.getInstance(applicationProperties);

    // Set Skinned Look and Feel.
    LookAndFeel lookAndFeel = skinsFactory.createSkinnedMetalTheme("SkinnedLookAndFeel");
    try {/*from  ww w  . jav a2  s  .c om*/
        UIManager.setLookAndFeel(lookAndFeel);
    } catch (UnsupportedLookAndFeelException e) {
        log.error("Unable to set skinned LookAndFeel", e);
    }

    this.setLayout(new GridBagLayout());

    statusMessageLabel = skinsFactory.createSkinnedJHtmlLabel("ProgressPanelStatusMessageLabel");
    statusMessageLabel.setText(" ");
    statusMessageLabel.setHorizontalAlignment(JLabel.CENTER);
    this.add(statusMessageLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    progressBar = skinsFactory.createSkinnedJProgressBar("ProgressPanelProgressBar", 0, 100);
    this.add(progressBar, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, insetsDefault, 0, 0));

    // Display the cancel button if a cancel event listener is available.
    cancelButton = skinsFactory.createSkinnedJButton("ProgressPanelCancelButton");
    guiUtils.applyIcon(cancelButton, "/images/nuvola/16x16/actions/cancel.png");
    cancelButton.setActionCommand("Cancel");
    cancelButton.addActionListener(this);
    cancelButton.setEnabled(cancelEventTrigger != null);

    this.add(cancelButton, new GridBagConstraints(2, 0, 1, 1, 0, 0, GridBagConstraints.EAST,
            GridBagConstraints.NONE, insetsDefault, 0, 0));
}

From source file:org.openconcerto.erp.core.finance.accounting.ui.GrandLivrePanel.java

public GrandLivrePanel() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();
    c.weightx = 1;/*from w w w.  jav  a 2 s .c om*/
    this.tabbedClasse = new JTabbedPane();

    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;
    c.weighty = 1;
    c.gridx = 0;

    c.gridy = 0;
    c.gridwidth = 2;
    this.add(this.tabbedClasse, c);

    JButton buttonImpression = new JButton("Impression");
    JButton buttonClose = new JButton("Fermer");
    c.gridx = 0;
    c.gridy++;
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    this.add(buttonImpression, c);
    c.gridx++;
    c.weightx = 0;
    this.add(buttonClose, c);

    buttonClose.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            ((JFrame) SwingUtilities.getRoot(GrandLivrePanel.this)).dispose();
        };
    });
    buttonImpression.addActionListener(new ImpressionGrandLivreAction());
}

From source file:org.zaproxy.zap.extension.brk.impl.http.BreakAddDialog.java

private JPanel getJPanel() {
    if (jPanel == null) {
        GridBagConstraints gridBagConstraints15 = new GridBagConstraints();
        java.awt.GridBagConstraints gridBagConstraints13 = new GridBagConstraints();

        javax.swing.JLabel jLabel2 = new JLabel();

        java.awt.GridBagConstraints gridBagConstraints3 = new GridBagConstraints();

        java.awt.GridBagConstraints gridBagConstraints2 = new GridBagConstraints();

        jPanel = new JPanel();
        jPanel.setLayout(new GridBagLayout());
        jPanel.setPreferredSize(new java.awt.Dimension(400, 90));
        jPanel.setMinimumSize(new java.awt.Dimension(400, 90));
        gridBagConstraints2.gridx = 1;/*from  w w w.j  av a  2  s.c  o  m*/
        gridBagConstraints2.gridy = 5;
        gridBagConstraints2.insets = new java.awt.Insets(2, 2, 2, 2);
        gridBagConstraints2.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints3.gridx = 2;
        gridBagConstraints3.gridy = 5;
        gridBagConstraints3.insets = new java.awt.Insets(2, 2, 2, 10);
        gridBagConstraints3.anchor = java.awt.GridBagConstraints.EAST;

        gridBagConstraints13.gridx = 0;
        gridBagConstraints13.gridy = 5;
        gridBagConstraints13.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints13.weightx = 1.0D;
        gridBagConstraints13.insets = new java.awt.Insets(2, 10, 2, 5);

        gridBagConstraints15.weightx = 1.0;
        gridBagConstraints15.weighty = 0.0D;
        gridBagConstraints15.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints15.insets = new java.awt.Insets(2, 10, 5, 10);
        gridBagConstraints15.gridwidth = 3;
        gridBagConstraints15.gridx = 0;
        gridBagConstraints15.gridy = 2;
        gridBagConstraints15.anchor = java.awt.GridBagConstraints.NORTHWEST;
        gridBagConstraints15.ipadx = 0;
        gridBagConstraints15.ipady = 10;

        jPanel.add(getJScrollPane(), gridBagConstraints15);
        jPanel.add(jLabel2, gridBagConstraints13);
        jPanel.add(getBtnCancel(), gridBagConstraints2);
        jPanel.add(getBtnAdd(), gridBagConstraints3);
    }
    return jPanel;
}

From source file:EditorPaneExample20.java

public EditorPaneExample20() {
    super("JEditorPane Example 20");

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

    // Add a menu bar
    menuBar = new JMenuBar();
    setJMenuBar(menuBar);/*w  w w  .j  a va2s  .c om*/

    // Populate it
    createMenuBar();

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

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;
    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.gridy = 6;
    c.weightx = 0.0;
    JButton saveButton = new JButton("Save");
    panel.add(saveButton, c);
    saveButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            EditorKit kit = pane.getEditorKit();
            try {
                if (kit instanceof RTFEditorKit) {
                    kit.write(System.out, pane.getDocument(), 0, pane.getDocument().getLength());
                    System.out.flush();
                } else {
                    if (writer == null) {
                        writer = new OutputStreamWriter(System.out);
                        pane.write(writer);
                        writer.flush();
                    }
                    kit.write(writer, pane.getDocument(), 0, pane.getDocument().getLength());
                    writer.flush();
                }
            } catch (Exception e) {
                System.out.println("Write failed");
            }
        }
    });

    c.gridx = 1;
    insertButton = new JButton("Insert HTML");
    panel.add(insertButton, c);
    insertButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (insertFrame == null) {
                insertFrame = new HTMLInsertFrame("HTML Insertion", pane);
                Point pt = EditorPaneExample20.this.getLocationOnScreen();
                Dimension d = EditorPaneExample20.this.getSize();
                insertFrame.setLocation(pt.x + d.width, pt.y);
                insertFrame.addWindowListener(new WindowAdapter() {
                    public void windowClosing(WindowEvent evt) {
                        insertFrame.dispose();
                        insertFrame = null;
                        setInsertButtonState();
                    }
                });
                insertButton.setEnabled(false);
                insertFrame.setVisible(true);
            }
        }
    });
    insertButton.setEnabled(false);

    c.gridx = 1;
    c.gridy = 0;
    c.weightx = 1.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.EnhancedHTMLEditorKit",
                loader);
    } else {
        // JDK 1.1
        JEditorPane.registerEditorKitForContentType("text/html",
                "AdvancedSwing.Chapter4.EnhancedHTMLEditorKit");
    }

    // 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));

                createMenuBar();
                enableMenuBar(true);
                getRootPane().revalidate();

                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);
            }
        }
    });
}