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:net.sf.taverna.t2.activities.wsdlsir.views.WSDLActivityConfigurationView.java

private void initComponents() {

    this.setModalityType(Dialog.ModalityType.DOCUMENT_MODAL);

    int gridy = 0;

    // title panel
    JPanel titlePanel = new JPanel(new BorderLayout());
    titlePanel.setBackground(Color.WHITE);
    JLabel titleLabel = new JLabel("Security configuration");
    titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 13.5f));
    titleLabel.setBorder(new EmptyBorder(10, 10, 0, 10));
    DialogTextArea titleMessage = new DialogTextArea("Select a security profile for the service");
    titleMessage.setMargin(new Insets(5, 20, 10, 10));
    titleMessage.setFont(titleMessage.getFont().deriveFont(11f));
    titleMessage.setEditable(false);//from w ww.ja v a  2 s  .  c o  m
    titleMessage.setFocusable(false);
    titlePanel.setBorder(new EmptyBorder(10, 10, 0, 10));
    titlePanel.add(titleLabel, BorderLayout.NORTH);
    titlePanel.add(titleMessage, BorderLayout.CENTER);
    addDivider(titlePanel, SwingConstants.BOTTOM, true);

    // Main panel
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new GridBagLayout());
    mainPanel.setBorder(new EmptyBorder(10, 10, 10, 10));

    //Create the radio buttons
    noSecurityRadioButton = new JRadioButton("None");
    noSecurityRadioButton.addItemListener(this);

    wsSecurityAuthNRadioButton = new JRadioButton("WS-Security username and password authentication");
    wsSecurityAuthNRadioButton.addItemListener(this);

    httpSecurityAuthNRadioButton = new JRadioButton("HTTP username and password authentication");
    httpSecurityAuthNRadioButton.addItemListener(this);

    SAMLSecurityAuthNRadioButton = new JRadioButton("SAML WEB SSO profile authentication");
    SAMLSecurityAuthNRadioButton.addItemListener(this);

    //Group the radio buttons
    buttonGroup = new ButtonGroup();
    buttonGroup.add(noSecurityRadioButton);
    buttonGroup.add(wsSecurityAuthNRadioButton);
    buttonGroup.add(httpSecurityAuthNRadioButton);
    buttonGroup.add(SAMLSecurityAuthNRadioButton);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;

    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(noSecurityRadioButton, gbc);

    noSecurityLabel = new JLabel("Service requires no security");
    noSecurityLabel.setFont(noSecurityLabel.getFont().deriveFont(11f));
    //      addDivider(noSecurityLabel, SwingConstants.BOTTOM, false);
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(0, 40, 10, 10);
    mainPanel.add(noSecurityLabel, gbc);

    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(httpSecurityAuthNRadioButton, gbc);

    ActionListener usernamePasswordListener = new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            // Get Credential Manager UI to get the username and password for the service
            CredentialManagerUI credManagerUI = CredentialManagerUI.getInstance();
            if (credManagerUI != null)
                credManagerUI.newPasswordForService(oldBean.getWsdl());
        }
    };

    httpSecurityAuthNLabel = new JLabel(
            "Service requires HTTP username and password in order to authenticate the user");
    httpSecurityAuthNLabel.setFont(httpSecurityAuthNLabel.getFont().deriveFont(11f));
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(0, 40, 10, 10);
    mainPanel.add(httpSecurityAuthNLabel, gbc);

    // Set username and password button;
    setHttpUsernamePasswordButton = new JButton("Set username and password");
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.insets = new Insets(0, 40, 10, 10);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0; // add any vertical space to this component
    mainPanel.add(setHttpUsernamePasswordButton, gbc);
    setHttpUsernamePasswordButton.addActionListener(usernamePasswordListener);

    /////SAML

    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(SAMLSecurityAuthNRadioButton, gbc);

    ActionListener getCookieListener = new ActionListener() {

        /**
         * This listener will use the CallPreparator to obtain the cookies (included shibsession_XXX cookie) and 
         * save it in the Credential Manager (as the password for user "nomatter")
         */
        public void actionPerformed(ActionEvent e) {
            try {
                WSDLParser parser = new WSDLParser(newBean.getWsdl());
                List<String> endpoints = parser.getOperationEndpointLocations(newBean.getOperation());
                for (String endpoint : endpoints) //Actually i am only expecting one endpoint
                {
                    if (debug)
                        System.out
                                .println("Obtaining a SAML cookies to save in credential manager:" + endpoint);

                    Cookie[] cookies = CallPreparator.createCookieForCallToEndpoint(endpoint);

                    // Uncomment for just the shibsession cookie
                    //                  Cookie[] cookiessession = new Cookie[1];
                    //                  for (Cookie cook : cookies)
                    //                     if (cook.getName().contains("shibsession"))
                    //                        cookiessession[0]=cook;
                    //                  cookies=cookiessession;

                    CredentialManager credman = CredentialManager.getInstance();
                    credman.saveUsernameAndPasswordForService(
                            new UsernamePassword("nomatter", serializetoString(cookies)), new URI(endpoint));
                }
            } catch (WSDLException ex) {
                System.err.println(
                        "Problem getting or saving SAML cookie: " + newBean.getWsdl() + ". " + ex.getMessage());
                ex.printStackTrace();
            } catch (ParserConfigurationException ex) {
                System.err.println(
                        "Problem getting or saving SAML cookie: " + newBean.getWsdl() + ". " + ex.getMessage());
                ex.printStackTrace();
            } catch (Exception ex) {
                System.err.println(
                        "Problem getting or saving SAML cookie: " + newBean.getWsdl() + ". " + ex.getMessage());
                ex.printStackTrace();
            }
        }
    };

    SAMLSecurityAuthNLabel = new JLabel("<html>"
            + "Service requires SAML Web SSO profile to be perfomed in order to authenticate the user. "
            + "A cookie will be saved in your Credential Manger. "
            + "In the case that it stops working, please delete the entry in your Credential Manager or re-authenticate"
            + "</html>");
    SAMLSecurityAuthNLabel.setFont(SAMLSecurityAuthNLabel.getFont().deriveFont(11f));
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(3, 40, 10, 10);
    mainPanel.add(SAMLSecurityAuthNLabel, gbc);

    // Set username and password button;
    setSAMLGETCookieButton = new JButton("Authenticate and save Authentication data in Credential Manger");
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.insets = new Insets(0, 40, 10, 10);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0; // add any vertical space to this component
    mainPanel.add(setSAMLGETCookieButton, gbc);
    setSAMLGETCookieButton.addActionListener(getCookieListener);

    //END SAML

    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(wsSecurityAuthNRadioButton, gbc);

    wsSecurityAuthNLabel = new JLabel(
            "Service requires WS-Security username and password in order to authenticate the user");
    wsSecurityAuthNLabel.setFont(wsSecurityAuthNLabel.getFont().deriveFont(11f));
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(0, 40, 0, 0);
    mainPanel.add(wsSecurityAuthNLabel, gbc);

    // Password type list
    passwordTypeComboBox = new JComboBox(passwordTypes);
    passwordTypeComboBox.setRenderer(new ComboBoxTooltipRenderer());
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(10, 40, 0, 0);
    mainPanel.add(passwordTypeComboBox, gbc);

    // 'Add timestamp' checkbox
    addTimestampCheckBox = new JCheckBox("Add a timestamp to SOAP message");
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 40, 10, 10);
    mainPanel.add(addTimestampCheckBox, gbc);

    // Set username and password button;
    setWsdlUsernamePasswordButton = new JButton("Set username and password");
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.insets = new Insets(0, 40, 10, 10);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0; // add any vertical space to this component
    mainPanel.add(setWsdlUsernamePasswordButton, gbc);
    setWsdlUsernamePasswordButton.addActionListener(usernamePasswordListener);

    addDivider(mainPanel, SwingConstants.BOTTOM, true);

    // OK/Cancel button panel
    JPanel okCancelPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JButton okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            okPressed();
        }
    });
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            cancelPressed();
        }
    });
    okCancelPanel.add(cancelButton);
    okCancelPanel.add(okButton);

    // Enable/disable controls based on what is the current security profiles
    String securityProfile = oldBean.getSecurityProfile();
    if (securityProfile == null) {
        noSecurityRadioButton.setSelected(true);
    } else {
        if (securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_PLAINTEXTPASSWORD)
                || securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_DIGESTPASSWORD)
                || securityProfile.equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD)
                || securityProfile.equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD)) {
            wsSecurityAuthNRadioButton.setSelected(true);
        }
        if (securityProfile.equals(SecurityProfiles.HTTP_BASIC_AUTHN)
                || securityProfile.equals(SecurityProfiles.HTTP_DIGEST_AUTHN)) {
            httpSecurityAuthNRadioButton.setSelected(true);
        }
        if (securityProfile.equals(SecurityProfiles.SAMLWEBSSOAUTH)) {
            SAMLSecurityAuthNRadioButton.setSelected(true);
        }
        if (securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_PLAINTEXTPASSWORD)
                || securityProfile
                        .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD)) {
            passwordTypeComboBox.setSelectedItem(PLAINTEXT_PASSWORD);
        } else if (securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_DIGESTPASSWORD)
                || securityProfile.equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD)) {
            passwordTypeComboBox.setSelectedItem(DIGEST_PASSWORD);
        }
        if (securityProfile.equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD)
                || securityProfile
                        .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD)) {
            addTimestampCheckBox.setSelected(true);
        } else {
            addTimestampCheckBox.setSelected(false);
        }
    }

    // Put everything together
    JPanel layoutPanel = new JPanel(new BorderLayout());
    layoutPanel.add(titlePanel, BorderLayout.NORTH);
    layoutPanel.add(mainPanel, BorderLayout.CENTER);
    layoutPanel.add(okCancelPanel, BorderLayout.SOUTH);
    layoutPanel.setPreferredSize(new Dimension(550, 490));

    this.getContentPane().add(layoutPanel);
    this.pack();
}

From source file:captureplugin.drivers.defaultdriver.AdditionalParams.java

/**
 * Create Details-Panel//from  ww  w  .  ja v a2 s .  co m
 * @return Details-Panel
 */
private JPanel createDetailsPanel() {
    JPanel panel = new JPanel(new GridBagLayout());

    GridBagConstraints c = new GridBagConstraints();

    c.weighty = 0.5;
    c.weightx = 1.0;
    c.insets = new Insets(0, 0, 5, 0);
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = GridBagConstraints.REMAINDER;

    GridBagConstraints l = new GridBagConstraints();

    l.weightx = 1.0;
    l.insets = new Insets(0, 0, 5, 0);
    l.fill = GridBagConstraints.HORIZONTAL;
    l.gridwidth = GridBagConstraints.REMAINDER;

    panel.add(new JLabel(mLocalizer.msg("Name", "Name")), l);

    mName = new JTextField();

    panel.add(mName, l);

    panel.add(new JLabel(mLocalizer.msg("Parameter", "Parameter")), l);

    mParam = new ParamInputField(new CaptureParamLibrary(mConfig), "", false);
    panel.add(mParam, c);

    return panel;
}

From source file:QuoteServerThread.java

public void init() {
        //Initialize networking stuff.
        String host = getCodeBase().getHost();

        try {/*from   w w  w .java  2  s . c  o m*/
            address = InetAddress.getByName(host);
        } catch (UnknownHostException e) {
            System.out.println("Couldn't get Internet address: Unknown host");
            // What should we do?
        }

        try {
            socket = new DatagramSocket();
        } catch (IOException e) {
            System.out.println("Couldn't create new DatagramSocket");
            return;
        }

        //Set up the UI.
        GridBagLayout gridBag = new GridBagLayout();
        GridBagConstraints c = new GridBagConstraints();
        setLayout(gridBag);

        Label l1 = new Label("Quote of the Moment:", Label.CENTER);
        c.anchor = GridBagConstraints.SOUTH;
        c.gridwidth = GridBagConstraints.REMAINDER;
        gridBag.setConstraints(l1, c);
        add(l1);

        display = new Label("(no quote received yet)", Label.CENTER);
        c.anchor = GridBagConstraints.NORTH;
        c.weightx = 1.0;
        c.fill = GridBagConstraints.HORIZONTAL;
        gridBag.setConstraints(display, c);
        add(display);

        Label l2 = new Label("Enter the port (on host " + host + ") to send the request to:", Label.RIGHT);
        c.anchor = GridBagConstraints.SOUTH;
        c.gridwidth = 1;
        c.weightx = 0.0;
        c.weighty = 1.0;
        c.fill = GridBagConstraints.NONE;
        gridBag.setConstraints(l2, c);
        add(l2);

        portField = new TextField(6);
        gridBag.setConstraints(portField, c);
        add(portField);

        Button button = new Button("Send");
        gridBag.setConstraints(button, c);
        add(button);

        portField.addActionListener(this);
        button.addActionListener(this);
    }

From source file:burp.BurpExtender.java

private JPanel createMainPanel() {
    JPanel main = new JPanel();
    main.setLayout(new GridBagLayout());

    // Create Settings Panel
    JPanel settings = new JPanel(new GridBagLayout());

    createTitle("Settings", settings);
    KeyListener projectEnter = new KeyAdapter() {
        @Override//from w  w w  .  ja  v a 2s. co m
        public void keyPressed(KeyEvent k) {
            if (k.getKeyCode() == KeyEvent.VK_ENTER)
                updateProjects();
        }
    };

    serverUrl = labelTextField("Server URL: ", settings,
            callbacks.loadExtensionSetting(BurpExtender.SERVER_KEY));
    serverUrl.addKeyListener(projectEnter);
    serverUrl.addFocusListener(new JTextFieldSettingFocusListener(BurpExtender.SERVER_KEY, callbacks));

    apiKey = labelTextField("API Key: ", settings, callbacks.loadExtensionSetting(BurpExtender.API_KEY));
    apiKey.addKeyListener(projectEnter);
    apiKey.addFocusListener(new JTextFieldSettingFocusListener(BurpExtender.API_KEY, callbacks));

    JButton targetRefresh = new JButton();
    targetRefresh.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            updateTargets();
        }
    });
    targetUrl = createComboBox("Target URL: ", settings, 3, targetRefresh);

    projectRefresh = new JButton();
    projectRefresh.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            Thread updateThread = new Thread() {
                public void run() {
                    NameValuePair selected = getProject();
                    if (selected != null)
                        callbacks.saveExtensionSetting(BurpExtender.PROJECT_KEY, selected.getValue());
                    updateProjects();
                }
            };
            updateThread.start();
        }
    });
    projectBox = createComboBox("Projects: ", settings, 4, projectRefresh);

    GridBagConstraints setGBC = new GridBagConstraints();
    setGBC.gridy = 3;
    setGBC.anchor = GridBagConstraints.NORTHWEST;
    main.add(settings, setGBC);

    // Separator
    Insets ins = new Insets(10, 10, 2, 10);

    JSeparator sep = new JSeparator(JSeparator.HORIZONTAL);
    callbacks.customizeUiComponent(sep);
    GridBagConstraints sepGBC = new GridBagConstraints();
    sepGBC.gridwidth = 3;
    sepGBC.gridx = 0;
    sepGBC.fill = GridBagConstraints.HORIZONTAL;
    sepGBC.insets = ins;
    main.add(sep, sepGBC);

    // Create Export Button
    JButton exportBtn = new JButton();
    exportBtn.setText("Send to Code Dx");
    exportBtn.addActionListener(new ExportActionListener(this, callbacks));
    callbacks.customizeUiComponent(exportBtn);
    GridBagConstraints btnGBC = new GridBagConstraints();
    btnGBC.gridx = 0;
    btnGBC.weightx = 1.0;
    btnGBC.weighty = 1.0;
    btnGBC.insets = ins;
    btnGBC.anchor = GridBagConstraints.NORTHWEST;
    main.add(exportBtn, btnGBC);

    updateTargets();
    return main;
}

From source file:com.frostwire.gui.bittorrent.PartialFilesDialog.java

private void setupToggleAllSelectionCheckbox() {
    GridBagConstraints c;//from  w  w w.  j a va 2  s . co  m
    _checkBoxToggleAll = new JCheckBox(I18n.tr("Select/Unselect all files"), true);
    _checkBoxToggleAll.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            onCheckBoxToggleAll(e);
        }
    });

    c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1.0;
    c.insets = new Insets(5, 5, 5, 5);
    panel.add(_checkBoxToggleAll, c);
}

From source file:org.openconcerto.erp.core.finance.accounting.element.AnalytiqueSQLElement.java

public SQLComponent createComponent() {
    return new BaseSQLComponent(this) {
        public void addViews() {
            this.setLayout(new GridBagLayout());
            final GridBagConstraints c = new DefaultGridBagConstraints();
            c.anchor = GridBagConstraints.NORTHWEST;
            c.gridwidth = 4;//from   w w  w .j a  v  a 2 s  . c o  m
            c.gridheight = 8;

            vecteurTabAxe = new Vector();

            repartitionsAxe = new Vector();
            repartitionElemsAxe = new Vector();
            postesAxe = new Vector();

            tabAxes = new JTabbedPane();

            /***********************************************************************************
             * * CREATION DES ONGLETS
             **********************************************************************************/

            // on recupere les axes existant
            // SELECT ID, NOM FROM AXE
            SQLBase base = getTable().getBase();
            SQLSelect sel = new SQLSelect(base);
            sel.addSelect(getTable().getKey());
            sel.addSelect(getTable().getField("NOM"));
            sel.addRawOrder("AXE_ANALYTIQUE.NOM");
            String req = sel.asString();

            Object ob = getTable().getBase().getDataSource().execute(req, new ArrayListHandler());

            List myList = (List) ob;
            if (myList.size() != 0) {

                // on cre les onglets et on stocke les axes
                for (int i = 0; i < myList.size(); i++) {

                    // ID, nom
                    Object[] objTmp = (Object[]) myList.get(i);

                    axes.add(new Axe(Integer.parseInt(objTmp[0].toString()), objTmp[1].toString()));

                    // on recupere les repartitions et les lements associs  l'axe
                    RepartitionAxeAnalytiquePanel repAxeComp = new RepartitionAxeAnalytiquePanel(
                            ((Axe) axes.get(i)).getId());

                    repartitionsAxe.add(repAxeComp.getRepartitions());
                    repartitionElemsAxe.add(repAxeComp.getRepartitionElems());
                    postesAxe.add(repAxeComp.getPostes());
                    tabAxes.addTab(((Axe) axes.get(i)).getNom(), repAxeComp);

                    vecteurTabAxe.add(i, new String(String.valueOf(i)));
                }

                System.out.println("Size ----> " + axes.size());
            } else {
                ajouterAxe("Nouvel Axe");
            }

            c.fill = GridBagConstraints.BOTH;
            c.weightx = 1;
            c.weighty = 1;
            this.add(tabAxes, c);

            tabAxes.addMouseListener(new MouseAdapter() {

                public void mousePressed(final MouseEvent e) {

                    final int index = tabAxes.indexAtLocation(e.getX(), e.getY());

                    validAxeText();

                    if (e.getClickCount() == 2) {

                        actionModifierAxe(e, index);
                    }

                    if (e.getButton() == MouseEvent.BUTTON3) {
                        actionDroitOnglet(index, e);
                    }
                }
            });

            tabAxes.addAncestorListener(new AncestorListener() {

                public void ancestorAdded(AncestorEvent event) {

                    validAxeText();

                }

                public void ancestorRemoved(AncestorEvent event) {

                    validAxeText();

                }

                public void ancestorMoved(AncestorEvent event) {

                    validAxeText();

                }
            });

            /***********************************************************************************
             * * AJOUT D'UN AXE
             **********************************************************************************/
            JButton boutonAddAxe = new JButton("Ajouter un axe");
            boutonAddAxe.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent arg0) {

                    if (ajoutAxeFrame == null) {
                        ajoutAxeFrame = new AjouterAxeAnalytiqueFrame(a);
                    }
                    ajoutAxeFrame.pack();
                    ajoutAxeFrame.setVisible(true);
                }
            });

            c.gridx += 4;
            c.gridwidth = 1;
            c.gridheight = 1;
            c.weightx = 0;
            c.weighty = 0;
            c.fill = GridBagConstraints.HORIZONTAL;
            this.add(boutonAddAxe, c);

            /***********************************************************************************
             * * SUPPRESSION D'UN AXE
             **********************************************************************************/
            JButton boutonDelAxe = new JButton("Supprimer un axe");
            boutonDelAxe.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent arg0) {

                    supprimerAxe(Integer.parseInt(vecteurTabAxe.get(tabAxes.getSelectedIndex()).toString()));

                }
            });

            c.gridy++;
            this.add(boutonDelAxe, c);

            JButton boutonSet = new JButton("SetVal");
            boutonSet.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent arg0) {
                    setVal();
                }
            });

            c.gridy++;
            this.add(boutonSet, c);

            JButton boutonCheck = new JButton("Check");
            boutonCheck.addActionListener(new ActionListener() {

                public void actionPerformed(ActionEvent arg0) {
                    checkID();
                }
            });

            c.gridy++;
            this.add(boutonCheck, c);
        }
    };
}

From source file:es.mityc.firmaJava.libreria.pkcs7.ValidaTarjeta.java

/**
 * This method initializes jPanel   // w  w  w  . j  a  va2  s  .  c  om
 *    
 * @return javax.swing.JPanel   
 */
private JPanel getJPanel() {
    if (jPanel == null) {
        GridBagConstraints gridBagConstraints12 = new GridBagConstraints(); // Ttulo
        gridBagConstraints12.anchor = GridBagConstraints.WEST;
        gridBagConstraints12.gridx = 0;
        gridBagConstraints12.gridy = 0;
        gridBagConstraints12.gridwidth = 3;
        gridBagConstraints12.insets = new Insets(0, 10, 20, 0);
        GridBagConstraints gridBagConstraints21 = new GridBagConstraints(); // Botn Cancelar
        gridBagConstraints21.gridx = 2;
        gridBagConstraints21.gridy = 4;
        gridBagConstraints21.insets = new Insets(20, 10, 10, 10);
        gridBagConstraints21.anchor = GridBagConstraints.WEST;
        GridBagConstraints gridBagConstraints11 = new GridBagConstraints(); // Botn Aceptar
        gridBagConstraints11.gridx = 1;
        gridBagConstraints11.gridy = 4;
        gridBagConstraints11.insets = new Insets(20, 10, 10, 10);
        gridBagConstraints11.anchor = GridBagConstraints.EAST;
        GridBagConstraints gridBagConstraints6 = new GridBagConstraints(); // Campo del PIN
        gridBagConstraints6.anchor = GridBagConstraints.WEST;
        gridBagConstraints6.gridy = 3;
        gridBagConstraints6.gridx = 1;
        GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); // Etiqueta PIN
        gridBagConstraints5.anchor = GridBagConstraints.EAST;
        gridBagConstraints5.gridx = 0;
        gridBagConstraints5.gridy = 3;
        gridBagConstraints5.insets = new Insets(10, 10, 10, 10);
        GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); // Botn Examinar
        gridBagConstraints4.gridx = 3;
        gridBagConstraints4.gridy = 2;
        gridBagConstraints4.insets = new Insets(10, 10, 10, 10);
        GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); // Campo Librera
        gridBagConstraints3.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints3.gridy = 2;
        gridBagConstraints3.gridx = 1;
        gridBagConstraints3.gridwidth = 2;
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); // Etiqueta Librera
        gridBagConstraints2.anchor = GridBagConstraints.EAST;
        gridBagConstraints2.gridx = 0;
        gridBagConstraints2.gridy = 2;
        gridBagConstraints2.insets = new Insets(10, 10, 10, 10);
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); // Selector de Tarjetas
        gridBagConstraints1.anchor = GridBagConstraints.WEST;
        gridBagConstraints1.gridy = 1;
        gridBagConstraints1.gridx = 1;
        gridBagConstraints1.weightx = 1.0;
        gridBagConstraints1.gridwidth = 2;
        GridBagConstraints gridBagConstraints = new GridBagConstraints(); // Etiqueta Tarjetas
        gridBagConstraints.anchor = GridBagConstraints.EAST;
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.insets = new Insets(10, 10, 10, 10);

        jTituloLabel = new JLabel();
        jTituloLabel.setText(I18n.getResource(LIBRERIAXADES_VALIDARTARJETA_TEXTO_6));
        jPinLabel = new JLabel();
        jPinLabel.setText(I18n.getResource(LIBRERIAXADES_VALIDARTARJETA_TEXTO_7));
        jLibreriaLabel = new JLabel();
        jLibreriaLabel.setText(I18n.getResource(LIBRERIAXADES_VALIDARTARJETA_TEXTO_8));
        jTarjetaLabel = new JLabel();
        jTarjetaLabel.setText(I18n.getResource(LIBRERIAXADES_VALIDARTARJETA_TEXTO_9));
        jPanel = new JPanel();
        jPanel.setLayout(new GridBagLayout());
        jPanel.add(jTarjetaLabel, gridBagConstraints);
        jPanel.add(getJTarjetaComboBox(), gridBagConstraints1);
        jPanel.add(jLibreriaLabel, gridBagConstraints2);
        jPanel.add(getJTextField(), gridBagConstraints3);
        jPanel.add(getJExaminarButton(), gridBagConstraints4);
        jPanel.add(jPinLabel, gridBagConstraints5);
        jPanel.add(getJPinPasswordField(), gridBagConstraints6);
        jPanel.add(getJAceptarButton(), gridBagConstraints11);
        jPanel.add(getJCancelarButton(), gridBagConstraints21);
        jPanel.add(jTituloLabel, gridBagConstraints12);
    }

    return jPanel;
}

From source file:org.jfree.chart.demo.CompassDemo.java

/**
 * Initialises the user interface.//from   w w w .  j  a v  a  2s. c  o  m
 *
 * @throws Exception if there are any exceptions.
 */
void jbInit() throws Exception {
    this.titledBorder1 = new TitledBorder("");
    this.titledBorder2 = new TitledBorder("");
    this.titledBorder3 = new TitledBorder("");
    setLayout(this.gridLayout1);
    this.panelCompassHolder.setLayout(this.borderLayout);
    this.windNullCheckBox.setHorizontalTextPosition(SwingConstants.LEADING);
    this.windNullCheckBox.setText("Null");
    this.windNullCheckBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            checkWindNullActionPerformed(e);
        }
    });
    this.shipNullCheckBox.setHorizontalTextPosition(SwingConstants.LEFT);
    this.shipNullCheckBox.setText("Null");
    this.shipNullCheckBox.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            checkShipNullActionPerformed(e);
        }
    });

    this.spinShip.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            if (DEBUG) {
                System.out.println("compassDemo:spinShipPropertyChange");
            }
            final Spinner spinner = (Spinner) evt.getSource();
            if (spinner.isEnabled()) {
                shipData.setValue(new Double(spinner.getValue()));
            }
        }
    });

    this.spinWind.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(final PropertyChangeEvent evt) {
            if (DEBUG) {
                System.out.println("compassDemo:spinWindPropertyChange");
            }
            final Spinner spinner = (Spinner) evt.getSource();
            if (spinner.isEnabled()) {
                compassData.setValue(new Double(spinner.getValue()));
            }
        }
    });
    this.jPanel12.setLayout(this.gridLayout2);
    this.jPanel2.setBorder(this.titledBorder1);
    this.jPanel2.setLayout(this.gridBagLayout2);
    this.jPanel1.setBorder(this.titledBorder2);
    this.jPanel1.setLayout(this.gridBagLayout1);
    this.titledBorder1.setTitle("Second Pointer");
    this.titledBorder2.setTitle("First Pointer");
    this.titledBorder3.setTitle("Plot Options");
    this.pick2Pointer.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            pick2PointerActionPerformed(e);
        }
    });
    this.pick1Pointer.addActionListener(new java.awt.event.ActionListener() {
        public void actionPerformed(final ActionEvent e) {
            pick1PointerActionPerformed(e);
        }
    });
    add(this.panelCompassHolder, null);
    this.panelCompassHolder.add(this.jPanel12, BorderLayout.SOUTH);
    this.jPanel12.add(this.jPanel1, null);

    this.jPanel1.add(this.pick1Pointer, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    this.jPanel1.add(this.windNullCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    this.jPanel1.add(this.spinWind, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    this.jPanel12.add(this.jPanel2, null);

    this.jPanel2.add(this.pick2Pointer, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0));

    this.jPanel2.add(this.shipNullCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0,
            GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));

    this.jPanel2.add(this.spinShip, new GridBagConstraints(2, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER,
            GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));

    this.panelCompassHolder.add(this.panelCompass, BorderLayout.CENTER);

}

From source file:de.codesourcery.gittimelapse.MyFrame.java

public MyFrame(File file, GitHelper gitHelper) throws RevisionSyntaxException, MissingObjectException,
        IncorrectObjectTypeException, AmbiguousObjectException, IOException, GitAPIException {
    super("GIT timelapse: " + file.getAbsolutePath());
    if (gitHelper == null) {
        throw new IllegalArgumentException("gitHelper must not be NULL");
    }// ww w .  j  a  va  2s. c  om

    this.gitHelper = gitHelper;
    this.file = file;
    this.diffPanel = new DiffPanel();

    final JDialog dialog = new JDialog((Frame) null, "Please wait...", false);
    dialog.getContentPane().setLayout(new BorderLayout());
    dialog.getContentPane().add(new JLabel("Please wait, locating revisions..."), BorderLayout.CENTER);
    dialog.pack();
    dialog.setVisible(true);

    final IProgressCallback callback = new IProgressCallback() {

        @Override
        public void foundCommit(ObjectId commitId) {
            System.out.println("*** Found commit " + commitId);
        }
    };

    System.out.println("Locating commits...");
    commitList = gitHelper.findCommits(file, callback);

    dialog.setVisible(false);

    if (commitList.isEmpty()) {
        throw new RuntimeException("Found no commits");
    }
    setMenuBar(createMenuBar());

    diffModeChooser.setModel(new DefaultComboBoxModel<MyFrame.DiffDisplayMode>(DiffDisplayMode.values()));
    diffModeChooser.setSelectedItem(DiffDisplayMode.ALIGN_CHANGES);
    diffModeChooser.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final ObjectId commit = commitList.getCommit(revisionSlider.getValue() - 1);
            try {
                diffPanel.showRevision(commit);
            } catch (IOException | PatchApplyException e1) {
                e1.printStackTrace();
            }
        }
    });

    diffModeChooser.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            Component result = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            DiffDisplayMode mode = (DiffDisplayMode) value;
            switch (mode) {
            case ALIGN_CHANGES:
                setText("Align changes");
                break;
            case REGULAR:
                setText("Regular");
                break;
            default:
                setText(mode.toString());
            }
            return result;
        }
    });

    revisionSlider = new JSlider(1, commitList.size());

    revisionSlider.setPaintLabels(true);
    revisionSlider.setPaintTicks(true);

    addKeyListener(keyListener);
    getContentPane().addKeyListener(keyListener);

    if (commitList.size() < 10) {
        revisionSlider.setMajorTickSpacing(1);
        revisionSlider.setMinorTickSpacing(1);
    } else {
        revisionSlider.setMajorTickSpacing(5);
        revisionSlider.setMinorTickSpacing(1);
    }

    final ObjectId latestCommit = commitList.getLatestCommit();
    if (latestCommit != null) {
        revisionSlider.setValue(1 + commitList.indexOf(latestCommit));
        revisionSlider.setToolTipText(latestCommit.getName());
    }

    revisionSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            if (!revisionSlider.getValueIsAdjusting()) {
                final ObjectId commit = commitList.getCommit(revisionSlider.getValue() - 1);
                long time = -System.currentTimeMillis();
                try {
                    diffPanel.showRevision(commit);
                } catch (IOException | PatchApplyException e1) {
                    e1.printStackTrace();
                } finally {
                    time += System.currentTimeMillis();
                }
                if (Main.DEBUG_MODE) {
                    System.out.println("Rendering time: " + time);
                }
            }
        }
    });

    getContentPane().setLayout(new GridBagLayout());

    GridBagConstraints cnstrs = new GridBagConstraints();
    cnstrs.gridx = 0;
    cnstrs.gridy = 0;
    cnstrs.gridwidth = 1;
    cnstrs.gridheight = 1;
    cnstrs.weightx = 0;
    cnstrs.weighty = 0;
    cnstrs.fill = GridBagConstraints.NONE;

    getContentPane().add(new JLabel("Diff display mode:"), cnstrs);

    cnstrs = new GridBagConstraints();
    cnstrs.gridx = 1;
    cnstrs.gridy = 0;
    cnstrs.gridwidth = 1;
    cnstrs.gridheight = 1;
    cnstrs.weightx = 0;
    cnstrs.weighty = 0;
    cnstrs.fill = GridBagConstraints.NONE;

    getContentPane().add(diffModeChooser, cnstrs);

    cnstrs = new GridBagConstraints();
    cnstrs.gridx = 2;
    cnstrs.gridy = 0;
    cnstrs.gridwidth = 1;
    cnstrs.gridheight = 1;
    cnstrs.weightx = 1.0;
    cnstrs.weighty = 0;
    cnstrs.fill = GridBagConstraints.HORIZONTAL;

    getContentPane().add(revisionSlider, cnstrs);

    cnstrs = new GridBagConstraints();
    cnstrs.gridx = 0;
    cnstrs.gridy = 1;
    cnstrs.gridwidth = 3;
    cnstrs.gridheight = 1;
    cnstrs.weightx = 1;
    cnstrs.weighty = 1;
    cnstrs.fill = GridBagConstraints.BOTH;

    getContentPane().add(diffPanel, cnstrs);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    if (latestCommit != null) {
        diffPanel.showRevision(latestCommit);
    }
}

From source file:com.versul.testes.JRViewerPanel.java

private void initComponents() {
    scrollPane = new javax.swing.JScrollPane();
    scrollPane.getHorizontalScrollBar().setUnitIncrement(5);
    scrollPane.getVerticalScrollBar().setUnitIncrement(5);

    pnlInScroll = new javax.swing.JPanel();
    pnlPage = new javax.swing.JPanel();
    jPanel4 = new javax.swing.JPanel();
    pnlLinks = new javax.swing.JPanel();
    jPanel5 = new javax.swing.JPanel();
    jPanel6 = new javax.swing.JPanel();
    jPanel7 = new javax.swing.JPanel();
    jPanel8 = new javax.swing.JPanel();
    jLabel1 = new javax.swing.JLabel();
    jPanel9 = new javax.swing.JPanel();
    lblPage = new PageRenderer();

    setMinimumSize(new java.awt.Dimension(450, 150));
    setPreferredSize(new java.awt.Dimension(450, 150));

    setLayout(new java.awt.BorderLayout());
    addComponentListener(new java.awt.event.ComponentAdapter() {
        public void componentResized(java.awt.event.ComponentEvent evt) {
            pnlMainComponentResized(evt);
        }//  w w w . j a  v  a  2 s . co m
    });

    scrollPane.setHorizontalScrollBarPolicy(javax.swing.JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
    scrollPane.setVerticalScrollBarPolicy(javax.swing.JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    pnlInScroll.setLayout(new java.awt.GridBagLayout());

    pnlPage.setLayout(new java.awt.BorderLayout());
    pnlPage.setMinimumSize(new java.awt.Dimension(100, 100));
    pnlPage.setPreferredSize(new java.awt.Dimension(100, 100));

    jPanel4.setLayout(new java.awt.GridBagLayout());
    jPanel4.setMinimumSize(new java.awt.Dimension(100, 120));
    jPanel4.setPreferredSize(new java.awt.Dimension(100, 120));

    pnlLinks.setLayout(null);
    pnlLinks.setMinimumSize(new java.awt.Dimension(5, 5));
    pnlLinks.setPreferredSize(new java.awt.Dimension(5, 5));
    pnlLinks.setOpaque(false);
    pnlLinks.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mousePressed(java.awt.event.MouseEvent evt) {
            pnlLinksMousePressed(evt);
        }

        public void mouseReleased(java.awt.event.MouseEvent evt) {
            pnlLinksMouseReleased(evt);
        }
    });
    pnlLinks.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
        public void mouseDragged(java.awt.event.MouseEvent evt) {
            pnlLinksMouseDragged(evt);
        }
    });

    GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    jPanel4.add(pnlLinks, gridBagConstraints);

    jPanel5.setBackground(java.awt.Color.gray);
    jPanel5.setMinimumSize(new java.awt.Dimension(5, 5));
    jPanel5.setPreferredSize(new java.awt.Dimension(5, 5));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
    jPanel4.add(jPanel5, gridBagConstraints);

    jPanel6.setMinimumSize(new java.awt.Dimension(5, 5));
    jPanel6.setPreferredSize(new java.awt.Dimension(5, 5));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 2;
    jPanel4.add(jPanel6, gridBagConstraints);

    jPanel7.setBackground(java.awt.Color.gray);
    jPanel7.setMinimumSize(new java.awt.Dimension(5, 5));
    jPanel7.setPreferredSize(new java.awt.Dimension(5, 5));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
    jPanel4.add(jPanel7, gridBagConstraints);

    jPanel8.setBackground(java.awt.Color.gray);
    jPanel8.setMinimumSize(new java.awt.Dimension(5, 5));
    jPanel8.setPreferredSize(new java.awt.Dimension(5, 5));
    jLabel1.setText("jLabel1");
    jPanel8.add(jLabel1);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 2;
    jPanel4.add(jPanel8, gridBagConstraints);

    jPanel9.setMinimumSize(new java.awt.Dimension(5, 5));
    jPanel9.setPreferredSize(new java.awt.Dimension(5, 5));
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 2;
    gridBagConstraints.gridy = 0;
    jPanel4.add(jPanel9, gridBagConstraints);

    lblPage.setBackground(java.awt.Color.white);
    lblPage.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0)));
    lblPage.setOpaque(true);
    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 0;
    gridBagConstraints.gridy = 0;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.gridheight = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.weighty = 1.0;
    jPanel4.add(lblPage, gridBagConstraints);

    pnlPage.add(jPanel4, java.awt.BorderLayout.CENTER);

    gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
    pnlInScroll.add(pnlPage, gridBagConstraints);

    scrollPane.setViewportView(pnlInScroll);
    add(scrollPane, java.awt.BorderLayout.CENTER);

}