List of usage examples for java.awt GridBagLayout setConstraints
public void setConstraints(Component comp, GridBagConstraints constraints)
From source file:ContainerEventDemo.java
public ContainerEventDemo() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); // Initialize an empty list of buttons. buttonList = new Vector<JButton>(10, 10); // Create all the components. addButton = new JButton("Add a button"); addButton.setActionCommand(ADD);//from w ww .java 2 s. c o m addButton.addActionListener(this); removeButton = new JButton("Remove a button"); removeButton.setActionCommand(REMOVE); removeButton.addActionListener(this); buttonPanel = new JPanel(new GridLayout(1, 1)); buttonPanel.setPreferredSize(new Dimension(200, 75)); buttonPanel.addContainerListener(this); display = new JTextArea(); display.setEditable(false); JScrollPane scrollPane = new JScrollPane(display); scrollPane.setPreferredSize(new Dimension(200, 75)); clearButton = new JButton("Clear text area"); clearButton.setActionCommand(CLEAR); clearButton.addActionListener(this); c.fill = GridBagConstraints.BOTH; // Fill entire cell. c.weighty = 1.0; // Button area and message area have equal height. c.gridwidth = GridBagConstraints.REMAINDER; // end of row gridbag.setConstraints(scrollPane, c); add(scrollPane); c.weighty = 0.0; gridbag.setConstraints(clearButton, c); add(clearButton); c.weightx = 1.0; // Add/remove buttons have equal width. c.gridwidth = 1; // NOT end of row gridbag.setConstraints(addButton, c); add(addButton); c.gridwidth = GridBagConstraints.REMAINDER; // end of row gridbag.setConstraints(removeButton, c); add(removeButton); c.weighty = 1.0; // Button area and message area have equal height. gridbag.setConstraints(buttonPanel, c); add(buttonPanel); setPreferredSize(new Dimension(400, 400)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:Main.java
public Main() { super(new GridBagLayout()); GridBagLayout gridbag = (GridBagLayout) getLayout(); GridBagConstraints c = new GridBagConstraints(); // Initialize an empty list of buttons. buttonList = new Vector<JButton>(10, 10); // Create all the components. addButton = new JButton("Add a button"); addButton.setActionCommand(ADD);/*www. j a v a 2s.c o m*/ addButton.addActionListener(this); removeButton = new JButton("Remove a button"); removeButton.setActionCommand(REMOVE); removeButton.addActionListener(this); buttonPanel = new JPanel(new GridLayout(1, 1)); buttonPanel.setPreferredSize(new Dimension(200, 75)); buttonPanel.addContainerListener(this); display = new JTextArea(); display.setEditable(false); JScrollPane scrollPane = new JScrollPane(display); scrollPane.setPreferredSize(new Dimension(200, 75)); clearButton = new JButton("Clear text area"); clearButton.setActionCommand(CLEAR); clearButton.addActionListener(this); c.fill = GridBagConstraints.BOTH; // Fill entire cell. c.weighty = 1.0; // Button area and message area have equal height. c.gridwidth = GridBagConstraints.REMAINDER; // end of row gridbag.setConstraints(scrollPane, c); add(scrollPane); c.weighty = 0.0; gridbag.setConstraints(clearButton, c); add(clearButton); c.weightx = 1.0; // Add/remove buttons have equal width. c.gridwidth = 1; // NOT end of row gridbag.setConstraints(addButton, c); add(addButton); c.gridwidth = GridBagConstraints.REMAINDER; // end of row gridbag.setConstraints(removeButton, c); add(removeButton); c.weighty = 1.0; // Button area and message area have equal height. gridbag.setConstraints(buttonPanel, c); add(buttonPanel); setPreferredSize(new Dimension(400, 400)); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendCrossoverRateSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {// w ww .j av a2 s.co m SpinnerModel crossoverRateModel = new SpinnerNumberModel(crossoverInitial, CROSSOVER_MIN, CROSSOVER_MAX, CROSSOVER_STEP); crossoverRateSpinner = new JSpinner(crossoverRateModel); JLabel crossoverRateLabel = new JLabel(crossoverRateText); crossoverRateLabel.setLabelFor(crossoverRateSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(crossoverRateLabel, constraints); mainPanel.add(crossoverRateLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(crossoverRateSpinner, constraints); mainPanel.add(crossoverRateSpinner); }
From source file:be.agiv.security.demo.Main.java
private void invokeClaimsAwareService() { GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints gridBagConstraints = new GridBagConstraints(); JPanel contentPanel = new JPanel(gridBagLayout); final JLabel ipStsLabel = new JLabel("IP-STS:"); gridBagConstraints.gridx = 0;//from w ww . ja v a2 s . c o m gridBagConstraints.gridy = 0; gridBagConstraints.anchor = GridBagConstraints.WEST; gridBagConstraints.ipadx = 5; gridBagLayout.setConstraints(ipStsLabel, gridBagConstraints); contentPanel.add(ipStsLabel); final JTextField ipStsTextField = new JTextField( "https://auth.beta.agiv.be/ipsts/Services/DaliSecurityTokenServiceConfiguration.svc/IWSTrust13", 60); gridBagConstraints.gridx++; gridBagLayout.setConstraints(ipStsTextField, gridBagConstraints); contentPanel.add(ipStsTextField); JLabel realmLabel = new JLabel("Realm:"); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagLayout.setConstraints(realmLabel, gridBagConstraints); contentPanel.add(realmLabel); JTextField realmTextField = new JTextField(AGIVSecurity.BETA_REALM, 30); gridBagConstraints.gridx++; gridBagLayout.setConstraints(realmTextField, gridBagConstraints); contentPanel.add(realmTextField); final CredentialPanel credentialPanel = new CredentialPanel(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(credentialPanel, gridBagConstraints); contentPanel.add(credentialPanel); final JLabel rStsLabel = new JLabel("R-STS:"); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagConstraints.gridwidth = 1; gridBagLayout.setConstraints(rStsLabel, gridBagConstraints); contentPanel.add(rStsLabel); final JTextField rStsTextField = new JTextField( "https://auth.beta.agiv.be/sts/Services/SalvadorSecurityTokenServiceConfiguration.svc/IWSTrust13", 60); gridBagConstraints.gridx++; gridBagLayout.setConstraints(rStsTextField, gridBagConstraints); contentPanel.add(rStsTextField); JLabel serviceRealmLabel = new JLabel("Service realm:"); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagLayout.setConstraints(serviceRealmLabel, gridBagConstraints); contentPanel.add(serviceRealmLabel); JTextField serviceRealmTextField = new JTextField(ClaimsAwareServiceFactory.SERVICE_REALM, 60); gridBagConstraints.gridx++; gridBagLayout.setConstraints(serviceRealmTextField, gridBagConstraints); contentPanel.add(serviceRealmTextField); JLabel urlLabel = new JLabel("Service URL:"); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagLayout.setConstraints(urlLabel, gridBagConstraints); contentPanel.add(urlLabel); JTextField urlTextField = new JTextField(ClaimsAwareServiceFactory.SERVICE_LOCATION, 60); gridBagConstraints.gridx++; gridBagLayout.setConstraints(urlTextField, gridBagConstraints); contentPanel.add(urlTextField); final JCheckBox noWsPolicyCheckBox = new JCheckBox("WSDL without WS-Policy"); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(noWsPolicyCheckBox, gridBagConstraints); contentPanel.add(noWsPolicyCheckBox); final JCheckBox useWsSecureConversationCheckBox = new JCheckBox("Use WS-SecureConversation"); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(useWsSecureConversationCheckBox, gridBagConstraints); contentPanel.add(useWsSecureConversationCheckBox); final JCheckBox usePreviousSecurityCheckBox = new JCheckBox("Use previous AGIV Security"); final JCheckBox cancelPreviousSecureConversationToken = new JCheckBox("Cancel previous conversation token"); usePreviousSecurityCheckBox.setEnabled(null != this.agivSecurity); cancelPreviousSecureConversationToken.setEnabled(false); usePreviousSecurityCheckBox.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { LOG.debug("use previous security: " + usePreviousSecurityCheckBox.isSelected()); boolean newSecurity = !usePreviousSecurityCheckBox.isSelected(); ipStsLabel.setEnabled(newSecurity); ipStsTextField.setEditable(newSecurity); credentialPanel.setEnabled(newSecurity); rStsLabel.setEnabled(newSecurity); rStsTextField.setEnabled(newSecurity); cancelPreviousSecureConversationToken.setEnabled(!newSecurity); } }); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(usePreviousSecurityCheckBox, gridBagConstraints); contentPanel.add(usePreviousSecurityCheckBox); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(cancelPreviousSecureConversationToken, gridBagConstraints); contentPanel.add(cancelPreviousSecureConversationToken); JPanel expiresPanel = new JPanel(); gridBagConstraints.gridx = 0; gridBagConstraints.gridy++; gridBagConstraints.gridwidth = 2; gridBagLayout.setConstraints(expiresPanel, gridBagConstraints); contentPanel.add(expiresPanel); JLabel expiresLabelLabel = new JLabel("Secure conversation token expires:"); expiresLabelLabel.setEnabled(null != this.agivSecurity); expiresPanel.add(expiresLabelLabel); JLabel expiresLabel = new JLabel(); expiresLabel.setEnabled(null != this.agivSecurity); expiresPanel.add(expiresLabel); if (null != this.agivSecurity) { if (false == this.agivSecurity.getSecureConversationTokens().isEmpty()) { SecurityToken secureConversationToken = this.agivSecurity.getSecureConversationTokens().values() .iterator().next(); expiresLabel.setText(secureConversationToken.getExpires().toString()); } } int dialogResult = JOptionPane.showConfirmDialog(this, contentPanel, "Claims Aware Service", JOptionPane.OK_CANCEL_OPTION); if (dialogResult == JOptionPane.CANCEL_OPTION) { return; } final String location = urlTextField.getText(); final String serviceRealm = serviceRealmTextField.getText(); final String ipStsLocation = ipStsTextField.getText(); final String rStsLocation = rStsTextField.getText(); final String username = credentialPanel.getUsername(); final String password = credentialPanel.getPassword(); final File pkcs12File = credentialPanel.getPKCS12File(); final String realm = realmTextField.getText(); ExecutorService executor = Executors.newFixedThreadPool(1); FutureTask<ArrayOfClaimInfo> futureTask = new FutureTask<ArrayOfClaimInfo>( new Callable<ArrayOfClaimInfo>() { public ArrayOfClaimInfo call() throws Exception { Service service; if (noWsPolicyCheckBox.isSelected()) { service = ClaimsAwareServiceFactory.getInstanceNoWSPolicy(); } else { service = ClaimsAwareServiceFactory.getInstance(); } IService iservice = service.getWS2007FederationHttpBindingIService(new AddressingFeature()); BindingProvider bindingProvider = (BindingProvider) iservice; if (false == usePreviousSecurityCheckBox.isSelected()) { if (null != username) { Main.this.agivSecurity = new AGIVSecurity(ipStsLocation, rStsLocation, realm, username, password); } else { Main.this.agivSecurity = new AGIVSecurity(ipStsLocation, rStsLocation, realm, pkcs12File, password); } Main.this.agivSecurity.addSTSListener(Main.this); if (Main.this.proxyEnable) { agivSecurity.setProxy(Main.this.proxyHost, Main.this.proxyPort, Main.this.proxyType); } } if (cancelPreviousSecureConversationToken.isSelected()) { Main.this.agivSecurity.cancelSecureConversationTokens(); } Main.this.agivSecurity.enable(bindingProvider, location, useWsSecureConversationCheckBox.isSelected(), serviceRealm); ArrayOfClaimInfo result = iservice.getData(0); return result; } }) { @Override protected void done() { try { ArrayOfClaimInfo result = get(); List<ClaimInfo> claims = result.getClaimInfo(); StringBuffer message = new StringBuffer(); for (ClaimInfo claim : claims) { message.append(claim.getName()); message.append(" = "); message.append(claim.getValue()); message.append("\n"); } JOptionPane.showMessageDialog(Main.this, message.toString(), "Claims Aware Service Result", JOptionPane.INFORMATION_MESSAGE); } catch (final Exception e) { try { SwingUtilities.invokeAndWait(new Runnable() { public void run() { Main.this.statusBar.setErrorStatus(e.getMessage()); } }); } catch (Exception e1) { } showException(e); } } }; executor.execute(futureTask); }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendGenerationsSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {/* w w w. ja v a 2s .c om*/ SpinnerModel generationsModel = new SpinnerNumberModel(generationsInitial, GENERATIONS_MIN, GENERATIONS_MAX, GENERATIONS_STEP); generationsSpinner = new JSpinner(generationsModel); generationsSpinner.setEnabled(false); JLabel generationsLabel = new JLabel(generationsText); generationsLabel.setLabelFor(generationsSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(generationsLabel, constraints); mainPanel.add(generationsLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(generationsSpinner, constraints); mainPanel.add(generationsSpinner); }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendMutationAlgorithmComboBox(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {//w w w. ja v a2s . com mutationAlgorithmComboBox = new JComboBox<String>(); for (MutationAlgorithmType mutationAlgorithmType : MutationAlgorithmType.values()) { mutationAlgorithmComboBox.addItem(mutationAlgorithmType.name()); } mutationAlgorithmComboBox.setSelectedItem(MutationAlgorithmType.CONSERVATIVE.name()); JLabel mutationAlgorithmNameLabel = new JLabel(mutationAlgorithmNameText); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(mutationAlgorithmNameLabel, constraints); mainPanel.add(mutationAlgorithmNameLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(mutationAlgorithmComboBox, constraints); mainPanel.add(mutationAlgorithmComboBox); }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendFitnessEvaluatorComboBox(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {/*from ww w . j a v a 2 s. c o m*/ fitnessEvaluatorComboBox = new JComboBox<String>(); for (FitnessEvaluatorType fitnessEvaluatorType : FitnessEvaluatorType.values()) { fitnessEvaluatorComboBox.addItem(fitnessEvaluatorType.name()); } fitnessEvaluatorComboBox.setSelectedItem(FitnessEvaluatorType.CIPHER_SOLUTION_UNIQUE_WORD.name()); JLabel fitnessEvaluatorNameLabel = new JLabel(fitnessEvaluatorNameText); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(fitnessEvaluatorNameLabel, constraints); mainPanel.add(fitnessEvaluatorNameLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(fitnessEvaluatorComboBox, constraints); mainPanel.add(fitnessEvaluatorComboBox); }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendSelectionAlgorithmComboBox(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {/*from www . j ava2s.c om*/ selectionAlgorithmComboBox = new JComboBox<String>(); for (SelectionAlgorithmType selectionAlgorithmType : SelectionAlgorithmType.values()) { selectionAlgorithmComboBox.addItem(selectionAlgorithmType.name()); } selectionAlgorithmComboBox.setSelectedItem(SelectionAlgorithmType.PROBABILISTIC.name()); JLabel selectionAlgorithmNameLabel = new JLabel(selectionAlgorithmNameText); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(selectionAlgorithmNameLabel, constraints); mainPanel.add(selectionAlgorithmNameLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(selectionAlgorithmComboBox, constraints); mainPanel.add(selectionAlgorithmComboBox); }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendCrossoverAlgorithmComboBox(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {/*from ww w .ja va 2s . c o m*/ crossoverAlgorithmComboBox = new JComboBox<String>(); for (CrossoverAlgorithmType crossoverAlgorithmType : CrossoverAlgorithmType.values()) { crossoverAlgorithmComboBox.addItem(crossoverAlgorithmType.name()); } crossoverAlgorithmComboBox.setSelectedItem(CrossoverAlgorithmType.LOWEST_COMMON_GROUP.name()); JLabel crossoverAlgorithmNameLabel = new JLabel(crossoverAlgorithmNameText); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(crossoverAlgorithmNameLabel, constraints); mainPanel.add(crossoverAlgorithmNameLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(crossoverAlgorithmComboBox, constraints); mainPanel.add(crossoverAlgorithmComboBox); }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
private void appendMaxMutationsPerIndividualSpinner(GridBagLayout gridBagLayout, GridBagConstraints constraints, JPanel mainPanel) {/* ww w. j a v a2 s . co m*/ SpinnerModel maxMutationsPerIndividualModel = new SpinnerNumberModel(maxMutationsPerIndividualInitial, MAX_MUTATION_MIN, MAX_MUTATION_MAX, MAX_MUTATION_STEP); maxMutationsPerIndividualSpinner = new JSpinner(maxMutationsPerIndividualModel); JLabel maxMutationsPerIndividualLabel = new JLabel(maxMutationsPerIndividualText); maxMutationsPerIndividualLabel.setLabelFor(maxMutationsPerIndividualSpinner); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(maxMutationsPerIndividualLabel, constraints); mainPanel.add(maxMutationsPerIndividualLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(maxMutationsPerIndividualSpinner, constraints); mainPanel.add(maxMutationsPerIndividualSpinner); }