Example usage for java.awt GridBagConstraints GridBagConstraints

List of usage examples for java.awt GridBagConstraints GridBagConstraints

Introduction

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

Prototype

public GridBagConstraints() 

Source Link

Document

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

Usage

From source file:be.ac.ua.comp.scarletnebula.gui.ServerCellRenderer.java

@Override
public Component getListCellRendererComponent(final JList list, final Object value, final int index,
        final boolean isSelected, final boolean cellHasFocus) {
    // Dirty hack: the last item in the serverlist is always a fake server
    // that when double clicked produces an "add new server" wizard.
    if (value == null) {
        return getNewServerServer(list, index, isSelected);
    }//from   www . jav  a 2s  .  co  m
    final Server server = (Server) value;

    final JPanel p = createServerPanel(server, list, index, isSelected);
    final Color foreground = getForegroundColor(list, index, isSelected);

    final JLabel label = getServernameComponent(server, foreground);
    final JLabel tags = getTagComponent(server, foreground);
    // final ChartPanel chartPanel = getChartPanelComponent();

    final GraphPanelCache gcp = GraphPanelCache.get();

    final Component chartOrNothing;

    if (server.getServerStatistics() == null) {
        chartOrNothing = new JLabel();
    } else {
        chartOrNothing = gcp.inBareServerCache(server) ? gcp.getBareChartPanel(server)
                : createAndStoreBareChartPanel(list, server);
    }

    p.setLayout(new GridBagLayout());
    final GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(5, 5, 1, 5);
    c.anchor = GridBagConstraints.FIRST_LINE_START;

    p.add(label, c);
    c.insets = new Insets(0, 5, 5, 5);
    c.gridy = 1;
    p.add(tags, c);

    c.fill = GridBagConstraints.BOTH;
    c.weighty = 1.0;
    c.gridy = 2;
    p.add(chartOrNothing, c);

    return p;

}

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

/**
 * Creates a new HostsTab object./*from   www.  jav a  2s .co  m*/
 *
 * @param hostKeyVerifier
 */
public HostsTab(AbstractKnownHostsKeyVerification hostKeyVerifier) {
    super();
    this.hostKeyVerifier = hostKeyVerifier;
    hosts = new JList(model = new HostsListModel());
    hosts.setVisibleRowCount(10);
    hosts.setCellRenderer(new HostRenderer());
    hosts.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent evt) {
            setAvailableActions();
        }
    });
    remove = new JButton("Remove", new ResourceIcon(REMOVE_ICON));
    remove.addActionListener(this);

    //deny = new JButton("Deny", new ResourceIcon(DENY_ICON));
    //deny.addActionListener(this);
    JPanel b = new JPanel(new GridBagLayout());
    b.setBorder(BorderFactory.createEmptyBorder(0, 8, 0, 0));

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(0, 0, 4, 0);
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.weightx = 1.0;
    UIUtil.jGridBagAdd(b, remove, gbc, GridBagConstraints.REMAINDER);
    gbc.weighty = 1.0;

    //UIUtil.jGridBagAdd(b, deny, gbc, GridBagConstraints.REMAINDER);
    JPanel s = new JPanel(new BorderLayout());
    s.add(new JScrollPane(hosts), BorderLayout.CENTER);
    s.add(b, BorderLayout.EAST);

    IconWrapperPanel w = new IconWrapperPanel(new ResourceIcon(GLOBAL_ICON), s);

    //  This tab
    setLayout(new BorderLayout());
    add(w, BorderLayout.CENTER);
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    reset();
}

From source file:ShowDocument.java

public URLWindow(AppletContext appletContext) {
    super("Show a Document!");
    this.appletContext = appletContext;

    JPanel contentPane = new JPanel(new GridBagLayout());
    setContentPane(contentPane);//from   www.  j ava 2 s .co m
    contentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;

    JLabel label1 = new JLabel("URL of document to show: ", JLabel.TRAILING);
    add(label1, c);

    urlField = new JTextField("http://java.sun.com/", 20);
    label1.setLabelFor(urlField);
    urlField.addActionListener(this);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;
    add(urlField, c);

    JLabel label2 = new JLabel("Window/frame to show it in: ", JLabel.TRAILING);
    c.gridwidth = 1;
    c.weightx = 0.0;
    add(label2, c);

    String[] strings = { "(browser's choice)", //don't specify
            "My Personal Window", //a window named "My Personal Window"
            "_blank", //a new, unnamed window
            "_self", "_parent", "_top" //the Frame that contained this applet
    };
    choice = new JComboBox(strings);
    label2.setLabelFor(choice);
    c.fill = GridBagConstraints.NONE;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.insets = new Insets(5, 0, 0, 0);
    c.anchor = GridBagConstraints.LINE_START;
    add(choice, c);

    JButton button = new JButton("Show document");
    button.addActionListener(this);
    c.weighty = 1.0;
    c.ipadx = 10;
    c.ipady = 10;
    c.insets = new Insets(10, 0, 0, 0);
    c.anchor = GridBagConstraints.PAGE_END;
    add(button, c);
}

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

private void initializeComponent() {
    if (!this.initialized) {
        GridBagLayout gridbag = new GridBagLayout();
        this.setLayout(gridbag);

        GridBagConstraints existingScansPanelConstraints = new GridBagConstraints();
        existingScansPanelConstraints.anchor = GridBagConstraints.WEST;
        existingScansPanelConstraints.fill = GridBagConstraints.BOTH;
        existingScansPanelConstraints.gridx = 0;
        existingScansPanelConstraints.gridy = 0;
        existingScansPanelConstraints.weightx = 1.0;
        existingScansPanelConstraints.weighty = 1.0;
        existingScansPanelConstraints.gridheight = 2;
        existingScansPanelConstraints.gridwidth = 1;
        existingScansPanelConstraints.insets = new Insets(0, 0, 0, 0);

        JPanel existingScansPanel = new JPanel();
        GridBagLayout panelGridbag = new GridBagLayout();
        existingScansPanel.setLayout(panelGridbag);
        this.add(existingScansPanel, existingScansPanelConstraints);

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

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

        this.existingScanDefinitionsListPanel = new ListInputPanel<ScanDefinition>(this, this);
        existingScansPanel.add(this.existingScanDefinitionsListPanel, existingScanDefinitionsListConstraints);

        GridBagConstraints scanButtonConstraints = new GridBagConstraints();
        scanButtonConstraints.anchor = GridBagConstraints.NORTHEAST;
        scanButtonConstraints.fill = GridBagConstraints.BOTH;
        scanButtonConstraints.gridx = 1;
        scanButtonConstraints.gridy = 0;
        scanButtonConstraints.weightx = 1.0;
        scanButtonConstraints.weighty = 1.0;

        this.startScanButton.setActionCommand(AssuranceActions.scanAction);

        this.add(this.startScanButton, scanButtonConstraints);

        GridBagConstraints scanAndMergeButtonConstraints = new GridBagConstraints();
        scanAndMergeButtonConstraints.anchor = GridBagConstraints.SOUTHEAST;
        scanAndMergeButtonConstraints.fill = GridBagConstraints.BOTH;
        scanAndMergeButtonConstraints.gridx = 1;
        scanAndMergeButtonConstraints.gridy = 1;
        scanAndMergeButtonConstraints.weightx = 1.0;
        scanAndMergeButtonConstraints.weighty = 1.0;

        this.startScanAndMergeButton.setActionCommand(AssuranceActions.scanAndMergeAction);

        this.add(this.startScanAndMergeButton, scanAndMergeButtonConstraints);

        this.startScanAndMergeButton.addActionListener(this);
        this.startScanButton.addActionListener(this);

        this.startScanButton.setEnabled(false);
        this.startScanAndMergeButton.setEnabled(false);

        this.addAncestorListener(new AncestorListener() {
            public void ancestorAdded(AncestorEvent event) {
                applicationDelegate.addEventObserver(ScanStartedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ScanCompletedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ScanDefinitionDeletedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ScanDefinitionSavedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ScanDefinitionsLoadedEvent.class,
                        (IEventObserver) event.getSource());
            }//from w  ww  .jav a 2s. co  m

            public void ancestorRemoved(AncestorEvent event) {
                applicationDelegate.removeEventObserver(ScanStartedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ScanCompletedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ScanDefinitionDeletedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ScanDefinitionSavedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ScanDefinitionsLoadedEvent.class,
                        (IEventObserver) event.getSource());
            }

            public void ancestorMoved(AncestorEvent event) {
            }
        });

        this.initialized = true;
    }
}

From source file:gdt.jgui.entity.contact.JContactEditor.java

public JContactEditor() {
    GridBagLayout gridBagLayout = new GridBagLayout();
    gridBagLayout.columnWidths = new int[] { 100, 0, 0 };
    gridBagLayout.rowHeights = new int[] { 0, 0, 0 };
    gridBagLayout.columnWeights = new double[] { 0.0, 1.0, Double.MIN_VALUE };
    gridBagLayout.rowWeights = new double[] { 0.0, 0.0, 0.0 };
    setLayout(gridBagLayout);//from w w w  .j a  v a 2  s.  c  o  m
    JLabel lblTitle = new JLabel("Label");

    GridBagConstraints gbc_lblTitle = new GridBagConstraints();
    gbc_lblTitle.insets = new Insets(5, 5, 5, 5);
    gbc_lblTitle.gridx = 0;
    gbc_lblTitle.gridy = 0;
    gbc_lblTitle.anchor = GridBagConstraints.NORTHWEST;
    add(lblTitle, gbc_lblTitle);
    title = new JTextField();

    GridBagConstraints gbc_title = new GridBagConstraints();
    gbc_title.insets = new Insets(5, 0, 5, 5);
    gbc_title.fill = GridBagConstraints.HORIZONTAL;
    gbc_title.gridx = 1;
    gbc_title.gridy = 0;
    add(title, gbc_title);
    title.setColumns(10);

    JLabel lblPhone = new JLabel("Phone");
    GridBagConstraints gbc_lblphone = new GridBagConstraints();
    gbc_lblphone.insets = new Insets(5, 5, 5, 5);
    gbc_lblphone.gridx = 0;
    gbc_lblphone.gridy = 1;
    gbc_lblphone.anchor = GridBagConstraints.NORTHWEST;
    add(lblPhone, gbc_lblphone);

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

    JLabel lblEmail = new JLabel("Email");
    GridBagConstraints gbc_lblEmail = new GridBagConstraints();
    gbc_lblEmail.insets = new Insets(5, 5, 5, 5);
    gbc_lblEmail.gridx = 0;
    gbc_lblEmail.gridy = 2;
    gbc_lblEmail.anchor = GridBagConstraints.NORTHWEST;
    add(lblEmail, gbc_lblEmail);

    email = new JTextField();
    GridBagConstraints gbc_email = new GridBagConstraints();
    gbc_phone.insets = new Insets(5, 0, 5, 5);
    gbc_email.fill = GridBagConstraints.HORIZONTAL;
    gbc_email.gridx = 1;
    gbc_email.gridy = 2;
    add(email, gbc_email);
    email.setColumns(10);
    JPanel panel = new JPanel();
    GridBagConstraints gbc_panel = new GridBagConstraints();
    gbc_panel.weighty = 1.0;
    gbc_panel.insets = new Insets(5, 0, 5, 5);
    gbc_panel.fill = GridBagConstraints.BOTH;
    gbc_panel.gridx = 0;
    gbc_panel.gridy = 3;
    add(panel, gbc_panel);
    panel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
}

From source file:br.org.acessobrasil.silvinha.vista.panels.PainelSenha.java

public PainelSenha() {

    lblNome = new JLabel(GERAL.USUARIO);
    lblPass = new JLabel(GERAL.SENHA);
    txtName = new JTextField(10);
    txtPass = new JPasswordField(10);

    GridBagLayout bag = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    this.setLayout(bag);

    lblNome.setHorizontalAlignment(JLabel.RIGHT);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1.0;/*from   w  w w .  j a v a2s . c o  m*/
    gbc.insets = new Insets(2, 10, 2, 10);
    this.add(lblNome, gbc);

    txtName.setAlignmentX(SwingConstants.WEST);
    txtName.addActionListener(new ActivateNextTextFieldListener(txtPass));
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = new Insets(2, 0, 2, 10);
    this.add(txtName, gbc);

    lblPass.setHorizontalAlignment(JLabel.RIGHT);
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridwidth = 1;
    gbc.weightx = 1.0;
    gbc.insets = new Insets(2, 10, 2, 10);
    this.add(lblPass, gbc);

    txtPass.setAlignmentX(SwingConstants.WEST);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = new Insets(2, 0, 2, 10);
    this.add(txtPass, gbc);

    setSize(300, 130);
    setLocation(300, 300);
    //      this.setBackground(corDefault);

    op = new JOptionPane(this, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
    //      op.setBackground(corDefault);

}

From source file:edu.harvard.mcz.imagecapture.ChangePasswordDialog.java

/**
 * This method initializes jContentPane//  www.  j  a v a2s  .  com
 * 
 * @return javax.swing.JPanel
 */
private JPanel getJContentPane() {
    if (jContentPane == null) {
        GridBagConstraints gridBagConstraints10 = new GridBagConstraints();
        gridBagConstraints10.gridx = 0;
        gridBagConstraints10.weightx = 0.0;
        gridBagConstraints10.weighty = 1.0;
        gridBagConstraints10.gridy = 6;
        GridBagConstraints gridBagConstraints9 = new GridBagConstraints();
        gridBagConstraints9.gridx = 0;
        gridBagConstraints9.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints9.gridwidth = 2;
        gridBagConstraints9.gridy = 4;
        jLabelResponse = new JLabel();
        jLabelResponse.setText("");
        GridBagConstraints gridBagConstraints8 = new GridBagConstraints();
        gridBagConstraints8.fill = GridBagConstraints.BOTH;
        gridBagConstraints8.gridy = 3;
        gridBagConstraints8.weightx = 1.0;
        gridBagConstraints8.anchor = GridBagConstraints.WEST;
        gridBagConstraints8.gridx = 1;
        GridBagConstraints gridBagConstraints7 = new GridBagConstraints();
        gridBagConstraints7.fill = GridBagConstraints.BOTH;
        gridBagConstraints7.gridy = 2;
        gridBagConstraints7.weightx = 1.0;
        gridBagConstraints7.anchor = GridBagConstraints.WEST;
        gridBagConstraints7.gridx = 1;
        GridBagConstraints gridBagConstraints6 = new GridBagConstraints();
        gridBagConstraints6.fill = GridBagConstraints.BOTH;
        gridBagConstraints6.gridy = 1;
        gridBagConstraints6.weightx = 1.0;
        gridBagConstraints6.anchor = GridBagConstraints.WEST;
        gridBagConstraints6.gridx = 1;
        GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
        gridBagConstraints5.gridx = 0;
        gridBagConstraints5.anchor = GridBagConstraints.EAST;
        gridBagConstraints5.gridy = 5;
        GridBagConstraints gridBagConstraints4 = new GridBagConstraints();
        gridBagConstraints4.gridx = 1;
        gridBagConstraints4.anchor = GridBagConstraints.CENTER;
        gridBagConstraints4.gridy = 5;
        GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
        gridBagConstraints3.gridx = 0;
        gridBagConstraints3.anchor = GridBagConstraints.EAST;
        gridBagConstraints3.gridy = 3;
        jLabel3 = new JLabel();
        jLabel3.setText("New Password Again");
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.gridx = 0;
        gridBagConstraints2.anchor = GridBagConstraints.EAST;
        gridBagConstraints2.gridy = 2;
        jLabel2 = new JLabel();
        jLabel2.setText("New Password");
        GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
        gridBagConstraints11.gridx = 0;
        gridBagConstraints11.anchor = GridBagConstraints.EAST;
        gridBagConstraints11.gridy = 1;
        jLabel1 = new JLabel();
        jLabel1.setText("Old Password");
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.fill = GridBagConstraints.BOTH;
        gridBagConstraints1.gridy = 0;
        gridBagConstraints1.weightx = 1.0;
        gridBagConstraints1.anchor = GridBagConstraints.WEST;
        gridBagConstraints1.gridx = 1;
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.anchor = GridBagConstraints.EAST;
        gridBagConstraints.gridy = 0;
        jLabel = new JLabel();
        jLabel.setText("Change Password For:");
        jContentPane = new JPanel();
        jContentPane.setLayout(new GridBagLayout());
        jContentPane.add(jLabel, gridBagConstraints);
        jContentPane.add(getJTextField(), gridBagConstraints1);
        jContentPane.add(jLabel1, gridBagConstraints11);
        jContentPane.add(jLabel2, gridBagConstraints2);
        jContentPane.add(jLabel3, gridBagConstraints3);
        jContentPane.add(getJButton(), gridBagConstraints4);
        jContentPane.add(getJButton1(), gridBagConstraints5);
        jContentPane.add(getJPasswordFieldOld(), gridBagConstraints6);
        jContentPane.add(getJPasswordField1(), gridBagConstraints7);
        jContentPane.add(getJPasswordField2(), gridBagConstraints8);
        jContentPane.add(jLabelResponse, gridBagConstraints9);
        jContentPane.add(getJPanel(), gridBagConstraints10);
    }
    return jContentPane;
}

From source file:algorithm.OpenStegoRandomLSBSteganography.java

private void createConfigurationGui() {
    initButtons();//w  w w  .  j  av  a 2  s.  com
    panel = new GUIPanel();
    panel.setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 0;
    constraints.gridy = 0;
    constraints.anchor = GridBagConstraints.NORTHWEST;
    panel.add(new JLabel("<html><h2>LSB embedding options</h2></html>"), constraints);
    constraints.gridy++;
    panel.add(new JLabel("Compress payload files (default true):"), constraints);
    constraints.gridx++;
    panel.add(trueCompressionButton, constraints);
    constraints.gridx++;
    panel.add(falseCompressionButton, constraints);
    constraints.gridx = 0;
    constraints.gridy++;
}

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.j av a 2 s.co 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.github.cmisbox.ui.BaseFrame.java

public BaseFrame() {
    super(AWTUtilitiesWrapper.isTranslucencyCapable(BaseFrame.gc) ? BaseFrame.gc : null);
    this.log = LogFactory.getLog(this.getClass());

    this.gradient = false;
    this.setUndecorated(true);
    this.mainPanel = new JPanel(new GridBagLayout()) {

        private static final long serialVersionUID = 1035974033526970010L;

        protected void paintComponent(Graphics g) {
            if ((g instanceof Graphics2D) && BaseFrame.this.gradient) {
                final int R = 0;
                final int G = 0;
                final int B = 0;

                Paint p = new GradientPaint(0.0f, 0.0f, new Color(R, G, B, 192), this.getWidth(),
                        this.getHeight(), new Color(R, G, B, 255), true);
                Graphics2D g2d = (Graphics2D) g;
                g2d.setPaint(p);/*from  w w  w .ja v  a2s.  c  o  m*/
                g2d.fillRect(0, 0, this.getWidth(), this.getHeight());
            } else {
                super.paintComponent(g);
            }
        }
    };

    this.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

    GridBagConstraints gbc = new GridBagConstraints();

    this.mainPanel.setDoubleBuffered(false);
    this.mainPanel.setOpaque(false);
    this.mainPanel.setBorder(BorderFactory.createLineBorder(Color.white));

    JLabel title = new JLabel(this.getWindowTitle(), SwingConstants.CENTER);
    title.setForeground(Color.white);

    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weightx = 100;

    this.mainPanel.add(title, gbc);

    Image closeImg = this.getImage("images/application-exit.png", 32, 32);
    JLabel close = new JLabel(new ImageIcon(closeImg), SwingConstants.RIGHT);

    gbc.fill = GridBagConstraints.NONE;
    gbc.gridx = 2;
    gbc.weightx = 0;

    this.mainPanel.add(close, gbc);

    close.addMouseListener(this.closeAdapter);

    this.getContentPane().add(this.mainPanel, BorderLayout.CENTER);

    this.initComponents();

    this.pack();

    this.mainPanel.setOpaque(!this.gradient);
    if (!this.gradient) {
        this.mainPanel.setBackground(new Color(0, 0, 0, 208));
    }

    this.setLocationRelativeTo(null);
    AWTUtilitiesWrapper.setWindowOpaque(this, false);
    this.setVisible(true);
    this.setAlwaysOnTop(true);

}