List of usage examples for java.awt GridBagConstraints BOTH
int BOTH
To view the source code for java.awt GridBagConstraints BOTH.
Click Source Link
From source file:org.intermine.install.swing.source.SourcePropertiesPanel.java
/** * Set the source to edit. Replaces the components displayed in the panel with new * ones for the properties of the given source. * // ww w . java 2 s. co m * @param projectHome The project home directory. * @param project The Project. * @param s The Source. */ public void setSource(File projectHome, Project project, Source s) { source = s; SourceInfo sourceInfo = null; if (source != null) { String sourceType = source.getType(); sourceInfo = SourceInfoLoader.getInstance().getSourceInfo(sourceType); if (sourceInfo == null) { try { sourceInfo = SourceInfoLoader.getInstance().findDerivedSourceInfo(sourceType, project, projectHome); if (sourceInfo == null) { logger.warn("There is no source type information for the type " + sourceType); } } catch (IOException e) { logger.warn("IOException while searching for derived type information for " + sourceType, e); /* String message = Messages.getMessage("sourcetype.loadfail.title", sourceType); logger.error(message, e); JOptionPane.showMessageDialog(this, message, Messages.getMessage("sourcetype.loadfail.title"), JOptionPane.ERROR_MESSAGE); return; */ } } } propertyNames.clear(); propertyInfo.clear(); sourceProperties.clear(); if (sourceInfo != null) { for (PropertyDescriptor p : sourceInfo.getSource().getProperty()) { propertyNames.add(p.getName()); propertyInfo.put(p.getName(), p); } } if (source != null) { for (Property p : source.getProperty()) { propertyNames.add(p.getName()); sourceProperties.put(p.getName(), p); } } int numProperties = propertyNames.size(); removeAll(); setPreferredSize(null); GridBagConstraints cons = GridBagHelper.defaultConstraints(); propertyWrappers = new PropertyComponentWrapper[numProperties]; Iterator<String> propIter = propertyNames.iterator(); for (int index = 0; propIter.hasNext(); index++) { String propertyName = propIter.next(); PropertyDescriptor descriptor = propertyInfo.get(propertyName); Property property = sourceProperties.get(propertyName); cons.gridx = 0; cons.gridy = index; cons.gridwidth = 1; cons.weightx = 0; add(new JLabel(propertyName), cons); boolean locationProperty = isLocation(descriptor, property); String value = null; if (property != null) { if (locationProperty) { value = property.getLocation(); } else { value = property.getValue(); } } PropertyComponentWrapper wrapper = PropertyComponentCreator.createComponentFor(propertyName, descriptor, value); propertyWrappers[index] = wrapper; cons.gridx = 1; cons.gridwidth = GridBagConstraints.REMAINDER; cons.weightx = 1; add(wrapper.getDisplayComponent(), cons); } // To provide flexible space. cons.gridx = 0; cons.gridy = numProperties; cons.weightx = 1; cons.weighty = 1; cons.gridwidth = GridBagConstraints.REMAINDER; cons.fill = GridBagConstraints.BOTH; add(spacerPanel, cons); revalidate(); Dimension min = getMinimumSize(); Dimension pref = getPreferredSize(); setPreferredSize(new Dimension(min.width + MIN_SIZE_MARGIN, pref.height)); }
From source file:geva.Operator.Operations.UserSelect.java
/** * Helper for adding a control to a GridBagLayout control * @param container The control to add <var>control</var> to * @param control The control being added to <var>container</var> * @param gridX The grid column to add the control * @param gridY The grid row to add the control * @param gridW The number of columns to span * @param gridH The number of rows to span * @param weightX The amount of horizontal space this column should take * relative to other columns/*from w w w . j a va 2 s . c o m*/ * @param weightY The amount of vertical space this column should take * relative to other rows */ protected static void gridAdd(Container container, Container control, int gridX, int gridY, int gridW, int gridH, double weightX, double weightY) { container.add(control, new GridBagConstraints(gridX, gridY, gridW, gridH, weightX, weightY, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(1, 1, 1, 1), 0, 0)); }
From source file:org.jtrfp.trcl.gui.ConfigWindow.java
public ConfigWindow() { setTitle("Settings"); setSize(340, 540);//from ww w . j a v a2 s .c om if (config == null) config = new TRConfiguration(); JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP); getContentPane().add(tabbedPane, BorderLayout.CENTER); JPanel generalTab = new JPanel(); tabbedPane.addTab("General", new ImageIcon(ConfigWindow.class .getResource("/org/freedesktop/tango/22x22/mimetypes/application-x-executable.png")), generalTab, null); GridBagLayout gbl_generalTab = new GridBagLayout(); gbl_generalTab.columnWidths = new int[] { 0, 0 }; gbl_generalTab.rowHeights = new int[] { 0, 188, 222, 0 }; gbl_generalTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_generalTab.rowWeights = new double[] { 0.0, 1.0, 0.0, Double.MIN_VALUE }; generalTab.setLayout(gbl_generalTab); JPanel settingsLoadSavePanel = new JPanel(); GridBagConstraints gbc_settingsLoadSavePanel = new GridBagConstraints(); gbc_settingsLoadSavePanel.insets = new Insets(0, 0, 5, 0); gbc_settingsLoadSavePanel.anchor = GridBagConstraints.WEST; gbc_settingsLoadSavePanel.gridx = 0; gbc_settingsLoadSavePanel.gridy = 0; generalTab.add(settingsLoadSavePanel, gbc_settingsLoadSavePanel); settingsLoadSavePanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Overall Settings", TitledBorder.LEADING, TitledBorder.TOP, null, null)); FlowLayout flowLayout_1 = (FlowLayout) settingsLoadSavePanel.getLayout(); flowLayout_1.setAlignment(FlowLayout.LEFT); JButton btnSave = new JButton("Export..."); btnSave.setToolTipText("Export these settings to an external file"); settingsLoadSavePanel.add(btnSave); btnSave.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { exportSettings(); } }); JButton btnLoad = new JButton("Import..."); btnLoad.setToolTipText("Import an external settings file"); settingsLoadSavePanel.add(btnLoad); btnLoad.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { importSettings(); } }); JButton btnConfigReset = new JButton("Reset"); btnConfigReset.setToolTipText("Reset all settings to defaults"); settingsLoadSavePanel.add(btnConfigReset); btnConfigReset.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { defaultSettings(); } }); JPanel registeredPODsPanel = new JPanel(); registeredPODsPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Registered PODs", TitledBorder.LEFT, TitledBorder.TOP, null, null)); GridBagConstraints gbc_registeredPODsPanel = new GridBagConstraints(); gbc_registeredPODsPanel.insets = new Insets(0, 0, 5, 0); gbc_registeredPODsPanel.fill = GridBagConstraints.BOTH; gbc_registeredPODsPanel.gridx = 0; gbc_registeredPODsPanel.gridy = 1; generalTab.add(registeredPODsPanel, gbc_registeredPODsPanel); GridBagLayout gbl_registeredPODsPanel = new GridBagLayout(); gbl_registeredPODsPanel.columnWidths = new int[] { 272, 0 }; gbl_registeredPODsPanel.rowHeights = new int[] { 76, 0, 0 }; gbl_registeredPODsPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_registeredPODsPanel.rowWeights = new double[] { 1.0, 1.0, Double.MIN_VALUE }; registeredPODsPanel.setLayout(gbl_registeredPODsPanel); JPanel podListPanel = new JPanel(); GridBagConstraints gbc_podListPanel = new GridBagConstraints(); gbc_podListPanel.insets = new Insets(0, 0, 5, 0); gbc_podListPanel.fill = GridBagConstraints.BOTH; gbc_podListPanel.gridx = 0; gbc_podListPanel.gridy = 0; registeredPODsPanel.add(podListPanel, gbc_podListPanel); podListPanel.setLayout(new BorderLayout(0, 0)); JScrollPane podListScrollPane = new JScrollPane(); podListPanel.add(podListScrollPane, BorderLayout.CENTER); podList = new JList(podLM); podList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); podListScrollPane.setViewportView(podList); JPanel podListOpButtonPanel = new JPanel(); podListOpButtonPanel.setBorder(null); GridBagConstraints gbc_podListOpButtonPanel = new GridBagConstraints(); gbc_podListOpButtonPanel.anchor = GridBagConstraints.NORTH; gbc_podListOpButtonPanel.gridx = 0; gbc_podListOpButtonPanel.gridy = 1; registeredPODsPanel.add(podListOpButtonPanel, gbc_podListOpButtonPanel); FlowLayout flowLayout = (FlowLayout) podListOpButtonPanel.getLayout(); flowLayout.setAlignment(FlowLayout.LEFT); JButton addPodButton = new JButton("Add..."); addPodButton.setIcon( new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png"))); addPodButton.setToolTipText("Add a POD to the registry to be considered when running a game."); podListOpButtonPanel.add(addPodButton); addPodButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { addPOD(); } }); JButton removePodButton = new JButton("Remove"); removePodButton.setIcon(new ImageIcon( ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png"))); removePodButton.setToolTipText("Remove a POD file from being considered when playing a game"); podListOpButtonPanel.add(removePodButton); removePodButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { podLM.removeElement(podList.getSelectedValue()); } }); JButton podEditButton = new JButton("Edit..."); podEditButton.setIcon(null); podEditButton.setToolTipText("Edit the selected POD path"); podListOpButtonPanel.add(podEditButton); podEditButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { editPODPath(); } }); JPanel missionPanel = new JPanel(); GridBagConstraints gbc_missionPanel = new GridBagConstraints(); gbc_missionPanel.fill = GridBagConstraints.BOTH; gbc_missionPanel.gridx = 0; gbc_missionPanel.gridy = 2; generalTab.add(missionPanel, gbc_missionPanel); missionPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Missions", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagLayout gbl_missionPanel = new GridBagLayout(); gbl_missionPanel.columnWidths = new int[] { 0, 0 }; gbl_missionPanel.rowHeights = new int[] { 0, 0, 0 }; gbl_missionPanel.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_missionPanel.rowWeights = new double[] { 1.0, 0.0, Double.MIN_VALUE }; missionPanel.setLayout(gbl_missionPanel); JScrollPane scrollPane = new JScrollPane(); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.insets = new Insets(0, 0, 5, 0); gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 0; gbc_scrollPane.gridy = 0; missionPanel.add(scrollPane, gbc_scrollPane); missionList = new JList(missionLM); missionList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); scrollPane.setViewportView(missionList); JPanel missionListOpButtonPanel = new JPanel(); GridBagConstraints gbc_missionListOpButtonPanel = new GridBagConstraints(); gbc_missionListOpButtonPanel.anchor = GridBagConstraints.NORTH; gbc_missionListOpButtonPanel.gridx = 0; gbc_missionListOpButtonPanel.gridy = 1; missionPanel.add(missionListOpButtonPanel, gbc_missionListOpButtonPanel); JButton addVOXButton = new JButton("Add..."); addVOXButton.setIcon( new ImageIcon(ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-add.png"))); addVOXButton.setToolTipText("Add an external VOX file as a mission"); missionListOpButtonPanel.add(addVOXButton); addVOXButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { addVOX(); } }); final JButton removeVOXButton = new JButton("Remove"); removeVOXButton.setIcon(new ImageIcon( ConfigWindow.class.getResource("/org/freedesktop/tango/16x16/actions/list-remove.png"))); removeVOXButton.setToolTipText("Remove the selected mission"); missionListOpButtonPanel.add(removeVOXButton); removeVOXButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { missionLM.remove(missionList.getSelectedIndex()); } }); final JButton editVOXButton = new JButton("Edit..."); editVOXButton.setToolTipText("Edit the selected Mission's VOX path"); missionListOpButtonPanel.add(editVOXButton); editVOXButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { editVOXPath(); } }); missionList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent evt) { final String val = (String) missionList.getSelectedValue(); if (val == null) missionList.setSelectedIndex(0); else if (isBuiltinVOX(val)) { removeVOXButton.setEnabled(false); editVOXButton.setEnabled(false); } else { removeVOXButton.setEnabled(true); editVOXButton.setEnabled(true); } } }); JPanel soundTab = new JPanel(); tabbedPane.addTab("Sound", new ImageIcon( ConfigWindow.class.getResource("/org/freedesktop/tango/22x22/devices/audio-card.png")), soundTab, null); GridBagLayout gbl_soundTab = new GridBagLayout(); gbl_soundTab.columnWidths = new int[] { 0, 0 }; gbl_soundTab.rowHeights = new int[] { 65, 51, 70, 132, 0, 0, 0 }; gbl_soundTab.columnWeights = new double[] { 1.0, Double.MIN_VALUE }; gbl_soundTab.rowWeights = new double[] { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE }; soundTab.setLayout(gbl_soundTab); JPanel checkboxPanel = new JPanel(); GridBagConstraints gbc_checkboxPanel = new GridBagConstraints(); gbc_checkboxPanel.insets = new Insets(0, 0, 5, 0); gbc_checkboxPanel.fill = GridBagConstraints.BOTH; gbc_checkboxPanel.gridx = 0; gbc_checkboxPanel.gridy = 0; soundTab.add(checkboxPanel, gbc_checkboxPanel); chckbxLinearInterpolation = new JCheckBox("Linear Filtering"); chckbxLinearInterpolation.setToolTipText("Use the GPU's TMU to smooth playback of low-rate samples."); chckbxLinearInterpolation.setHorizontalAlignment(SwingConstants.LEFT); checkboxPanel.add(chckbxLinearInterpolation); chckbxLinearInterpolation.addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { needRestart = true; } }); chckbxBufferLag = new JCheckBox("Buffer Lag"); chckbxBufferLag.setToolTipText("Improves efficiency, doubles latency."); checkboxPanel.add(chckbxBufferLag); JPanel modStereoWidthPanel = new JPanel(); FlowLayout flowLayout_2 = (FlowLayout) modStereoWidthPanel.getLayout(); flowLayout_2.setAlignment(FlowLayout.LEFT); modStereoWidthPanel.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "MOD Stereo Width", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_modStereoWidthPanel = new GridBagConstraints(); gbc_modStereoWidthPanel.anchor = GridBagConstraints.NORTH; gbc_modStereoWidthPanel.insets = new Insets(0, 0, 5, 0); gbc_modStereoWidthPanel.fill = GridBagConstraints.HORIZONTAL; gbc_modStereoWidthPanel.gridx = 0; gbc_modStereoWidthPanel.gridy = 1; soundTab.add(modStereoWidthPanel, gbc_modStereoWidthPanel); modStereoWidthSlider = new JSlider(); modStereoWidthSlider.setPaintTicks(true); modStereoWidthSlider.setMinorTickSpacing(25); modStereoWidthPanel.add(modStereoWidthSlider); final JLabel modStereoWidthLbl = new JLabel("NN%"); modStereoWidthPanel.add(modStereoWidthLbl); JPanel bufferSizePanel = new JPanel(); FlowLayout flowLayout_3 = (FlowLayout) bufferSizePanel.getLayout(); flowLayout_3.setAlignment(FlowLayout.LEFT); bufferSizePanel.setBorder( new TitledBorder(null, "Buffer Size", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_bufferSizePanel = new GridBagConstraints(); gbc_bufferSizePanel.anchor = GridBagConstraints.NORTH; gbc_bufferSizePanel.insets = new Insets(0, 0, 5, 0); gbc_bufferSizePanel.fill = GridBagConstraints.HORIZONTAL; gbc_bufferSizePanel.gridx = 0; gbc_bufferSizePanel.gridy = 2; soundTab.add(bufferSizePanel, gbc_bufferSizePanel); audioBufferSizeCB = new JComboBox(); audioBufferSizeCB.setModel(new DefaultComboBoxModel(AudioBufferSize.values())); bufferSizePanel.add(audioBufferSizeCB); soundOutputSelectorGUI = new SoundOutputSelectorGUI(); soundOutputSelectorGUI.setBorder( new TitledBorder(null, "Output Driver", TitledBorder.LEADING, TitledBorder.TOP, null, null)); GridBagConstraints gbc_soundOutputSelectorGUI = new GridBagConstraints(); gbc_soundOutputSelectorGUI.anchor = GridBagConstraints.NORTH; gbc_soundOutputSelectorGUI.insets = new Insets(0, 0, 5, 0); gbc_soundOutputSelectorGUI.fill = GridBagConstraints.HORIZONTAL; gbc_soundOutputSelectorGUI.gridx = 0; gbc_soundOutputSelectorGUI.gridy = 3; soundTab.add(soundOutputSelectorGUI, gbc_soundOutputSelectorGUI); modStereoWidthSlider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent arg0) { modStereoWidthLbl.setText(modStereoWidthSlider.getValue() + "%"); needRestart = true; } }); JPanel okCancelPanel = new JPanel(); getContentPane().add(okCancelPanel, BorderLayout.SOUTH); okCancelPanel.setLayout(new BorderLayout(0, 0)); JButton btnOk = new JButton("OK"); btnOk.setToolTipText("Apply these settings and close the window"); okCancelPanel.add(btnOk, BorderLayout.WEST); btnOk.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { applySettings(); ConfigWindow.this.setVisible(false); } }); JButton btnCancel = new JButton("Cancel"); btnCancel.setToolTipText("Close the window without applying settings"); okCancelPanel.add(btnCancel, BorderLayout.EAST); JLabel lblConfigpath = new JLabel(TRConfiguration.getConfigFilePath().getAbsolutePath()); lblConfigpath.setIcon(null); lblConfigpath.setToolTipText("Default config file path"); lblConfigpath.setHorizontalAlignment(SwingConstants.CENTER); lblConfigpath.setFont(new Font("Dialog", Font.BOLD, 6)); okCancelPanel.add(lblConfigpath, BorderLayout.CENTER); btnCancel.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent arg0) { ConfigWindow.this.setVisible(false); } }); }
From source file:gov.nij.er.ui.EntityResolutionDemo.java
private void layoutUI() { JPanel panel = new JPanel(); panel.setLayout(new GridBagLayout()); JScrollPane rawDataTreeScrollPane = new JScrollPane(rawDataTree); JScrollPane parametersTableScrollPane = new JScrollPane(parametersTable); JScrollPane resolvedDataTreeScrollPane = new JScrollPane(resolvedDataTree); Insets insets = new Insets(5, 5, 5, 5); panel.add(new JLabel("Raw Data:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, insets, 0, 0)); panel.add(new JLabel("Resolved Data:"), new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, insets, 0, 0)); panel.add(rawDataTreeScrollPane, new GridBagConstraints(0, 1, 1, 1, 0.5, 0.5, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, insets, 0, 0)); panel.add(resolvedDataTreeScrollPane, new GridBagConstraints(1, 1, 1, 1, 0.5, 0.5, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, insets, 0, 0)); panel.add(rawRecordCountLabel, new GridBagConstraints(0, 2, 1, 1, 0.5, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, insets, 0, 0)); JPanel resolvedLabelPanel = new JPanel(); resolvedLabelPanel.setLayout(new GridBagLayout()); resolvedLabelPanel.add(resolvedRecordCountLabel, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.EAST, GridBagConstraints.BOTH, insets, 0, 0)); resolvedLabelPanel.add(filterForSelectedCheckBox, new GridBagConstraints(1, 0, 1, 1, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); panel.add(resolvedLabelPanel, new GridBagConstraints(1, 2, 1, 1, 0.5, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, insets, 0, 0)); JPanel bottomPanel = new JPanel(); bottomPanel.setLayout(new GridBagLayout()); bottomPanel.add(new JLabel("Parameters:"), new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, insets, 0, 0)); bottomPanel.add(parametersTableScrollPane, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, insets, 0, 0)); bottomPanel.add(resolveButton, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, insets, 0, 0)); panel.add(bottomPanel, new GridBagConstraints(0, 3, 2, 1, 1.0, 0.5, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, insets, 0, 0)); this.setContentPane(panel); }
From source file:be.vds.jtbdive.client.view.core.dive.profile.DiveProfileGraphicDetailPanel.java
private Component createControls() { JPanel controlPanel = new JPanel(new GridBagLayout()); controlPanel.setOpaque(false);//from w w w . j a v a 2 s .co m GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(5, 5, 5, 5); GridBagLayoutManager.addComponent(controlPanel, createInstantDataPanel(), c, 0, 0, 1, 1, 0, 0, GridBagConstraints.BOTH, GridBagConstraints.CENTER); GridBagLayoutManager.addComponent(controlPanel, createWarningsPanel(), c, 0, 1, 1, 1, 0, 0, GridBagConstraints.BOTH, GridBagConstraints.CENTER); GridBagLayoutManager.addComponent(controlPanel, createOptionsPanel(), c, 0, 2, 1, 1, 0, 0, GridBagConstraints.BOTH, GridBagConstraints.CENTER); GridBagLayoutManager.addComponent(controlPanel, createEditorButton(), c, 0, 3, 1, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH); GridBagLayoutManager.addComponent(controlPanel, createImportExportButtons(), c, 0, 4, 1, 1, 0, 0, GridBagConstraints.HORIZONTAL, GridBagConstraints.NORTH); GridBagLayoutManager.addComponent(controlPanel, Box.createVerticalGlue(), c, 0, 5, 1, 1, 1, 1, GridBagConstraints.VERTICAL, GridBagConstraints.CENTER); return controlPanel; }
From source file:net.sf.taverna.t2.workbench.cagrid.CaGridComponent.java
private void addResultPanel() { GridBagConstraints c = new GridBagConstraints(); c.gridx = 0;//from www . ja va 2 s . c o m c.gridy = ++row; c.fill = GridBagConstraints.BOTH; c.weightx = 0.01; c.weighty = 0.01; c.anchor = GridBagConstraints.SOUTHEAST; c.gridwidth = GridBagConstraints.REMAINDER; resultPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); resultPanel.setDividerLocation(200); resultPanel.setBorder(null); runListModel = new DefaultListModel(); runList = new JList(runListModel); runList.setBorder(new EmptyBorder(5, 5, 5, 5)); runList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); runListPanel = new JPanel(new BorderLayout()); runListPanel.setBorder(LineBorder.createGrayLineBorder()); JLabel worklflowRunsLabel = new JLabel("Workflow Runs"); worklflowRunsLabel.setBorder(new EmptyBorder(5, 5, 5, 5)); removeCaGridRunsButton = new JButton("Remove"); // button to remove previous workflow runs removeCaGridRunsButton.setAlignmentX(JComponent.RIGHT_ALIGNMENT); removeCaGridRunsButton.setEnabled(false); removeCaGridRunsButton.setToolTipText("Remove caGrid run(s)"); removeCaGridRunsButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int[] selected = runList.getSelectedIndices(); for (int i = selected.length - 1; i >= 0; i--) { CaGridRun cr = (CaGridRun) runListModel.get(selected[i]); //delete the EPR file File file = new File(new File(System.getProperty("user.home")), cr.workflowid + ".epr"); file.delete(); System.out.println(cr.workflowid + ".epr deleted"); runListModel.remove(selected[i]); } // Set the first item as selected - if there is one if (runListModel.size() > 0) { runList.setSelectedIndex(0); } else { resultText.setText(""); resultText.revalidate(); } } }); runListPanel.add(worklflowRunsLabel, BorderLayout.NORTH); runListPanel.add(removeCaGridRunsButton, BorderLayout.BEFORE_FIRST_LINE); JScrollPane scrollPane = new JScrollPane(runList); scrollPane.setBorder(null); runListPanel.add(scrollPane, BorderLayout.CENTER); // loadWorkflowRunsFromStoredEPRFiles(): add CaGridRun to runList for each EPR // add two buttons: remove and refresh status runList.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { if (!e.getValueIsAdjusting()) { Object selection = runList.getSelectedValue(); if (selection instanceof CaGridRun) { removeCaGridRunsButton.setEnabled(true); CaGridRun dataflowRun = (CaGridRun) selection; // update status and refresh outputPanel String resultDisplayString = updateResultDisplayString(dataflowRun); resultText.setText(resultDisplayString); resultText.setLineWrap(true); resultText.setEditable(false); outputPanel.revalidate(); revalidate(); } else { removeCaGridRunsButton.setEnabled(false); revalidate(); } } } }); resultPanel.setTopComponent(runListPanel); //each output should be a (xml) string outputPanel = new JScrollPane(); resultText = new JTextArea(); outputPanel = new JScrollPane(resultText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); //outputPanel = new JPanel(new BorderLayout()); outputPanel.setBorder(LineBorder.createGrayLineBorder()); outputPanel.setBackground(Color.WHITE); //outputPanel.add(new JLabel("Workflow Execution Outputs shows here.", JLabel.CENTER), null); resultPanel.setBottomComponent(outputPanel); add(resultPanel, c); //add runComponent to the GUI ArrayList<CaGridRun> loadedRunList = loadWorkflowRunsFromStoredEPRFiles(null, (String) services.getSelectedItem()); if (loadedRunList != null) { for (int m = 0; m < loadedRunList.size(); m++) { CaGridRun cr = (CaGridRun) loadedRunList.get(m); runListModel.add(0, cr); } System.out.println(loadedRunList.size() + " EPR loaded."); runList.setSelectedIndex(0); } }
From source file:org.opendatakit.briefcase.ui.CharsetConverterDialog.java
/** * Create the dialog./*w ww . jav a 2s .co m*/ */ public CharsetConverterDialog(Window owner) { super(owner, ModalityType.DOCUMENT_MODAL); setTitle(DIALOG_TITLE); setBounds(100, 100, 600, 530); getContentPane().setLayout(new BorderLayout()); JPanel contentPanel = new JPanel(); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); GridBagLayout gbl_contentPanel = new GridBagLayout(); contentPanel.setLayout(gbl_contentPanel); { JLabel lblNewLabel = new JLabel(SELECT_FILE_LABEL); GridBagConstraints gbc_lblNewLabel = new GridBagConstraints(); gbc_lblNewLabel.anchor = GridBagConstraints.WEST; gbc_lblNewLabel.gridwidth = 2; gbc_lblNewLabel.insets = new Insets(0, 0, 5, 0); gbc_lblNewLabel.gridx = 0; gbc_lblNewLabel.gridy = 0; contentPanel.add(lblNewLabel, gbc_lblNewLabel); } { tfFile = new JTextField(); tfFile.setEditable(false); GridBagConstraints gbc_tfFile = new GridBagConstraints(); gbc_tfFile.weightx = 1.0; gbc_tfFile.insets = new Insets(0, 0, 5, 5); gbc_tfFile.fill = GridBagConstraints.HORIZONTAL; gbc_tfFile.gridx = 0; gbc_tfFile.gridy = 1; contentPanel.add(tfFile, gbc_tfFile); tfFile.setColumns(10); } { JButton btnBrowse = new JButton(SELECT_FILE_BUTTON); btnBrowse.setActionCommand(BROWSE_COMMAND); btnBrowse.addActionListener(this); GridBagConstraints gbc_btnBrowse = new GridBagConstraints(); gbc_btnBrowse.insets = new Insets(0, 0, 5, 0); gbc_btnBrowse.gridx = 1; gbc_btnBrowse.gridy = 1; contentPanel.add(btnBrowse, gbc_btnBrowse); } { JLabel lblEncoding = new JLabel(SELECT_SOURCE_ENCODING_LABEL); GridBagConstraints gbc_lblEncoding = new GridBagConstraints(); gbc_lblEncoding.anchor = GridBagConstraints.WEST; gbc_lblEncoding.insets = new Insets(0, 0, 5, 5); gbc_lblEncoding.gridx = 0; gbc_lblEncoding.gridy = 2; contentPanel.add(lblEncoding, gbc_lblEncoding); } { listCharset = new JList<CharsetEntry>(); listCharset.setVisibleRowCount(7); listCharset.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); GridBagConstraints gbc_cbCharset = new GridBagConstraints(); gbc_cbCharset.gridwidth = 2; gbc_cbCharset.insets = new Insets(0, 0, 5, 0); gbc_cbCharset.fill = GridBagConstraints.BOTH; gbc_cbCharset.gridx = 0; gbc_cbCharset.gridy = 3; JScrollPane listScrollPane = new JScrollPane(listCharset); contentPanel.add(listScrollPane, gbc_cbCharset); } { JLabel lblPreview = new JLabel(PREVIEW_LABEL); GridBagConstraints gbc_lblPreview = new GridBagConstraints(); gbc_lblPreview.anchor = GridBagConstraints.WEST; gbc_lblPreview.insets = new Insets(0, 0, 5, 5); gbc_lblPreview.gridx = 0; gbc_lblPreview.gridy = 4; contentPanel.add(lblPreview, gbc_lblPreview); } { JScrollPane scrollPane = new JScrollPane(); GridBagConstraints gbc_scrollPane = new GridBagConstraints(); gbc_scrollPane.weighty = 1.0; gbc_scrollPane.weightx = 1.0; gbc_scrollPane.gridwidth = 2; gbc_scrollPane.fill = GridBagConstraints.BOTH; gbc_scrollPane.gridx = 0; gbc_scrollPane.gridy = 5; contentPanel.add(scrollPane, gbc_scrollPane); { previewArea = new JTextArea(); previewArea.setLineWrap(true); previewArea.setRows(10); previewArea.setFont(UIManager.getDefaults().getFont("Label.font").deriveFont(Font.PLAIN)); previewArea.setEditable(false); scrollPane.setViewportView(previewArea); } } { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { cbOverride = new JCheckBox(REPLACE_EXISTING_FILE_LABEL); cbOverride.setSelected(false); buttonPane.add(cbOverride); } { JButton okButton = new JButton(CONVERT_BUTTON_LABEL); okButton.setActionCommand(CONVERT_COMMAND); okButton.addActionListener(this); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { cancelButton = new JButton(CANCEL_BUTTON_LABEL); cancelButton.setActionCommand(CANCEL_COMMAND); cancelButton.addActionListener(this); buttonPane.add(cancelButton); } } }
From source file:org.executequery.gui.ExecuteSqlScriptPanel.java
private void init() throws Exception { fileNameField = WidgetFactory.createTextField(); connectionsCombo = WidgetFactory.createComboBox(); combosGroup = new TableSelectionCombosGroup(connectionsCombo); actionOnErrorCombo = WidgetFactory.createComboBox(); ActionOnError[] actionsOnError = { ActionOnError.HALT, ActionOnError.CONTINUE }; actionOnErrorCombo.setModel(new DefaultComboBoxModel(actionsOnError)); outputPanel = new LoggingOutputPanel(); statusBar = new SqlTextPaneStatusBar(); statusBar.setBorder(BorderFactory.createEmptyBorder(2, 0, 0, 1)); JButton button = WidgetFactory.createInlineFieldButton("Browse"); button.setActionCommand("browse"); button.addActionListener(this); button.setMnemonic('r'); logOutputCheckBox = new JCheckBox( "<html> <i>Note:</i> This will slow down the process significantly </html>"); JPanel mainPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridy = 0;/* w w w . j av a 2 s . com*/ gbc.gridx = 0; gbc.gridheight = 1; gbc.insets.top = 7; gbc.insets.bottom = 5; gbc.insets.right = 5; gbc.insets.left = 5; gbc.anchor = GridBagConstraints.NORTHWEST; mainPanel.add(new JLabel("Connection:"), gbc); gbc.gridx = 1; gbc.weightx = 1.0; gbc.insets.top = 5; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(connectionsCombo, gbc); gbc.gridy++; gbc.gridx = 0; gbc.weightx = 0; gbc.gridwidth = 1; gbc.insets.top = 5; mainPanel.add(new JLabel("Action on Error:"), gbc); gbc.gridx = 1; gbc.weightx = 1.0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.HORIZONTAL; gbc.insets.top = 0; mainPanel.add(actionOnErrorCombo, gbc); gbc.gridy++; gbc.gridx = 0; gbc.weightx = 0; gbc.gridwidth = 1; gbc.insets.top = 5; mainPanel.add(new JLabel("Input File:"), gbc); gbc.gridx = 1; gbc.weightx = 1.0; gbc.insets.top = 0; mainPanel.add(fileNameField, gbc); gbc.gridx = 2; gbc.weightx = 0; gbc.insets.left = 0; gbc.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(button, gbc); gbc.gridy++; gbc.gridx = 0; gbc.insets.top = 5; gbc.insets.left = 5; mainPanel.add(new JLabel("Log output:"), gbc); gbc.gridx = 1; gbc.insets.top = 2; gbc.insets.left = 0; mainPanel.add(logOutputCheckBox, gbc); gbc.gridy++; gbc.gridx = 0; gbc.weighty = 1.0; gbc.weightx = 1.0; gbc.insets.top = 5; gbc.insets.left = 5; gbc.insets.bottom = 0; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; mainPanel.add(outputPanel, gbc); gbc.gridy++; gbc.gridx = 0; gbc.weighty = 0; gbc.insets.bottom = 5; gbc.fill = GridBagConstraints.HORIZONTAL; mainPanel.add(statusBar, gbc); mainPanel.setBorder(BorderFactory.createEtchedBorder()); int minimumButtonWidth = 85; startButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Start", "start"); rollbackButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Commit", "commit"); commitButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Rollback", "rollback"); stopButton = new MinimumWidthActionButton(minimumButtonWidth, this, "Stop", "stop"); rollbackButton.setEnabled(false); commitButton.setEnabled(false); stopButton.setEnabled(false); JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 2, 5)); buttonPanel.add(startButton); buttonPanel.add(rollbackButton); buttonPanel.add(commitButton); buttonPanel.add(stopButton); add(mainPanel, BorderLayout.CENTER); add(buttonPanel, BorderLayout.SOUTH); setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); EventMediator.registerListener(this); }
From source file:org.intermine.install.swing.NewDerivedTypeDialog.java
/** * Common initialisation: lays out the child components and wires up the necessary * event listeners. // w w w . j av a2 s.co m */ private void init() { setName("New Derived Type Dialog"); setTitle(Messages.getMessage("source.derived.title")); progressDialog.setTitle(Messages.getMessage("makesource.title")); nameField.setEnabled(false); typeField.setEnabled(false); buttonPanel = new ButtonPanel(createAction, new CancelAction()); progressDialog.setInformationLabel(Messages.getMessage("makesource.message")); progressDialog.pack(); Container cp = getContentPane(); GridBagConstraints cons = GridBagHelper.setup(cp); cp.add(new JLabel(Messages.getMessage("source.name")), cons); cons.gridy++; cp.add(new JLabel(Messages.getMessage("source.derived.parent")), cons); cons.gridy++; cp.add(new JLabel(Messages.getMessage("source.derived.type")), cons); cons.gridy = 0; cons.gridx++; cons.weightx = 1; cp.add(nameField, cons); cons.gridy++; cp.add(typeField, cons); cons.gridy++; cp.add(derivedTypeField, cons); cons.gridx = 0; cons.gridy++; cons.gridwidth = GridBagConstraints.REMAINDER; cons.weighty = 1; cons.fill = GridBagConstraints.BOTH; cp.add(spacerPanel, cons); cons.gridy++; cons.weighty = 0; cons.fill = GridBagConstraints.HORIZONTAL; cp.add(buttonPanel, cons); derivedTypeField.getDocument().addDocumentListener(new DerivedTypeDocumentListener()); pack(); }
From source file:de.tor.tribes.ui.components.TimePicker.java
public void addHourLabels() { jPanelHour.removeAll();// w ww .j ava 2 s . c om for (int i = 0; i < hourLabels.length; i++) { GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = i % 12; gbc.gridy = i / 12; gbc.fill = GridBagConstraints.BOTH; gbc.weightx = 1; gbc.weighty = 1; hourLabels[i].uncross(); jPanelHour.add(hourLabels[i], gbc); } selectedHour = hourLabels[pHour]; selectedHour.cross(); }