List of usage examples for java.awt GridBagConstraints NONE
int NONE
To view the source code for java.awt GridBagConstraints NONE.
Click Source Link
From source file:org.apache.taverna.activities.rest.ui.config.RESTActivityConfigurationPanel.java
private JPanel createGeneralTab() { JPanel jpGeneral = new JPanel(new GridBagLayout()); GridBagConstraints c = new GridBagConstraints(); // All components to be anchored WEST c.anchor = GridBagConstraints.WEST; c.gridx = 0;// w ww . java2 s . c om c.gridy = 0; c.gridwidth = 1; c.insets = new Insets(7, 7, 3, 3); c.weightx = 0.0; c.fill = GridBagConstraints.NONE; JLabel labelMethod = new JLabel("HTTP Method:", infoIcon, JLabel.LEFT); labelMethod.setToolTipText( "<html>HTTP method determines how a request to the remote server will be made.<br><br>" + "Supported HTTP methods are normally used for different purposes:<br>" + "<b>GET</b> - to fetch data;<br>" + "<b>POST</b> - to create new resources;<br>" + "<b>PUT</b> - to update existing resources;<br>" + "<b>DELETE</b> - to remove existing resources.<br><br>" + "Documentation of the server that is about to be used may suggest the<br>" + "HTTP method that should be used.</html>"); jpGeneral.add(labelMethod, c); // the HTTP method combo-box will always contain the same values - it is // the selected // method which is important; therefore, can prepopulate as the set of // values is known c.gridx++; c.insets = new Insets(7, 3, 3, 7); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; cbHTTPMethod = new JComboBox<>(HTTP_METHOD.values()); cbHTTPMethod.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { boolean contentTypeSelEnabled = RESTActivity .hasMessageBodyInputPort((HTTP_METHOD) cbHTTPMethod.getSelectedItem()); jlContentTypeExplanation.setVisible(contentTypeSelEnabled); jlContentType.setVisible(contentTypeSelEnabled); cbContentType.setVisible(contentTypeSelEnabled); jlSendDataAs.setVisible(contentTypeSelEnabled); cbSendDataAs.setVisible(contentTypeSelEnabled); jlContentTypeExplanationPlaceholder.setVisible(!contentTypeSelEnabled); jlContentTypeLabelPlaceholder.setVisible(!contentTypeSelEnabled); jlContentTypeFieldPlaceholder.setVisible(!contentTypeSelEnabled); jlSendDataAsLabelPlaceholder.setVisible(!contentTypeSelEnabled); jlSendDataAsFieldPlaceholder.setVisible(!contentTypeSelEnabled); } }); jpGeneral.add(cbHTTPMethod, c); c.gridx = 0; c.gridy++; c.insets = new Insets(3, 7, 3, 3); c.fill = GridBagConstraints.NONE; c.weightx = 0.0; JLabel labelString = new JLabel("URL Template:", infoIcon, JLabel.LEFT); labelString.setToolTipText("<html>URL template enables to define a URL with <b>configurable<br>" + "parameters</b> that will be used to access a remote server.<br><br>" + "The template may contain zero or more <b>parameters</b> - each<br>" + "enclosed within curly braces <b>\"{\"</b> and <b>\"}\"</b>.<br>" + "Taverna will automatically create an individual input port for<br>" + "this activity for each parameter.<br><br>" + "Values extracted from these input ports during the workflow<br>" + "execution these will be used to replace the parameters to<br>" + "produce complete URLs.<br><br>" + "For example, if the URL template is configured as<br>" + "\"<i>http://www.myexperiment.org/user.xml?id={userID}</i>\", a<br>" + "single input port with the name \"<i>userID</i>\" will be created.</html>"); labelString.setLabelFor(tfURLSignature); jpGeneral.add(labelString, c); c.gridx++; c.insets = new Insets(3, 3, 3, 7); c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1.0; tfURLSignature = new JTextField(40); tfURLSignature.addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { tfURLSignature.selectAll(); } public void focusLost(FocusEvent e) { /* do nothing */ } }); jpGeneral.add(tfURLSignature, c); c.gridx = 0; c.gridwidth = 2; c.gridy++; c.weightx = 0.0; c.fill = GridBagConstraints.NONE; c.insets = new Insets(18, 7, 3, 7); JLabel jlAcceptsExplanation = new JLabel( "Preferred MIME type for data to be fetched from the remote server --"); jpGeneral.add(jlAcceptsExplanation, c); c.gridwidth = 1; c.gridx = 0; c.gridy++; c.insets = new Insets(3, 7, 3, 3); c.weightx = 0.0; c.fill = GridBagConstraints.NONE; JLabel jlAccepts = new JLabel("'Accept' header:", infoIcon, JLabel.LEFT); jlAccepts.setToolTipText( "<html>Select a MIME type from the drop-down menu or type your own.<br>Select blank if you do not want this header to be set.</br>"); jlAccepts.setLabelFor(cbAccepts); jpGeneral.add(jlAccepts, c); c.gridx++; c.insets = new Insets(3, 3, 3, 7); c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; cbAccepts = new JComboBox<>(getMediaTypes()); cbAccepts.setEditable(true); cbAccepts.getEditor().getEditorComponent().addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { cbAccepts.getEditor().selectAll(); } public void focusLost(FocusEvent e) { /* do nothing */ } }); jpGeneral.add(cbAccepts, c); c.gridx = 0; c.gridwidth = 2; c.gridy++; c.insets = new Insets(18, 7, 3, 7); c.weightx = 0.0; c.fill = GridBagConstraints.NONE; jlContentTypeExplanation = new JLabel("MIME type of data that will be sent to the remote server --"); jpGeneral.add(jlContentTypeExplanation, c); c.gridwidth = 1; c.gridx = 0; c.gridy++; c.insets = new Insets(3, 7, 3, 3); c.weightx = 0.0; c.fill = GridBagConstraints.NONE; jlContentType = new JLabel("'Content-Type' header:", infoIcon, JLabel.LEFT); jlContentType.setToolTipText( "<html>Select a MIME type from the drop-down menu or type your own.<br>Select blank if you do not want this header to be set.</html>"); jlContentType.setLabelFor(cbContentType); jpGeneral.add(jlContentType, c); c.gridx++; c.insets = new Insets(3, 3, 3, 7); c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; cbContentType = new JComboBox<>(getMediaTypes()); cbContentType.setEditable(true); cbContentType.getEditor().getEditorComponent().addFocusListener(new FocusListener() { public void focusGained(FocusEvent e) { cbContentType.getEditor().selectAll(); } public void focusLost(FocusEvent e) { /* do nothing */ } }); cbContentType.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { // change selection in the "Send data as" combo-box, based on // the selection of Content-Type String selectedContentType = (String) cbContentType.getSelectedItem(); if (selectedContentType.startsWith("text")) { cbSendDataAs.setSelectedItem(DATA_FORMAT.String); } else { cbSendDataAs.setSelectedItem(DATA_FORMAT.Binary); } } }); jpGeneral.add(cbContentType, c); c.gridx = 0; c.gridwidth = 2; c.gridy++; c.insets = new Insets(18, 7, 3, 7); c.weightx = 0.0; c.fill = GridBagConstraints.NONE; jlContentTypeExplanationPlaceholder = new JLabel(); jlContentTypeExplanationPlaceholder.setPreferredSize(jlContentTypeExplanation.getPreferredSize()); jpGeneral.add(jlContentTypeExplanationPlaceholder, c); c.gridwidth = 1; c.gridx = 0; c.gridy++; c.insets = new Insets(3, 7, 3, 3); c.weightx = 0.0; c.fill = GridBagConstraints.NONE; jlContentTypeLabelPlaceholder = new JLabel(); jlContentTypeLabelPlaceholder.setPreferredSize(jlContentType.getPreferredSize()); jpGeneral.add(jlContentTypeLabelPlaceholder, c); c.gridx++; c.insets = new Insets(3, 3, 3, 7); c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; jlContentTypeFieldPlaceholder = new JLabel(); jlContentTypeFieldPlaceholder.setPreferredSize(cbContentType.getPreferredSize()); jpGeneral.add(jlContentTypeFieldPlaceholder, c); c.gridx = 0; c.gridy++; c.weightx = 0.0; c.fill = GridBagConstraints.NONE; c.insets = new Insets(3, 7, 8, 3); jlSendDataAs = new JLabel("Send data as:", infoIcon, JLabel.LEFT); jlSendDataAs.setToolTipText("Select the format for the data to be sent to the remote server"); jlSendDataAs.setLabelFor(cbSendDataAs); jpGeneral.add(jlSendDataAs, c); c.gridx++; c.insets = new Insets(3, 3, 8, 7); c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; cbSendDataAs = new JComboBox<>(DATA_FORMAT.values()); cbSendDataAs.setEditable(false); jpGeneral.add(cbSendDataAs, c); c.gridx = 0; c.gridy++; c.insets = new Insets(3, 7, 8, 3); c.weightx = 0.0; c.fill = GridBagConstraints.NONE; jlSendDataAsLabelPlaceholder = new JLabel(); jlSendDataAsLabelPlaceholder.setPreferredSize(jlSendDataAs.getPreferredSize()); jpGeneral.add(jlSendDataAsLabelPlaceholder, c); c.gridx++; c.insets = new Insets(3, 3, 8, 7); c.weightx = 1.0; c.fill = GridBagConstraints.HORIZONTAL; jlSendDataAsFieldPlaceholder = new JLabel(); jlSendDataAsFieldPlaceholder.setPreferredSize(cbSendDataAs.getPreferredSize()); jpGeneral.add(jlSendDataAsFieldPlaceholder, c); JPanel finalPanel = new JPanel(new BorderLayout()); finalPanel.add(jpGeneral, BorderLayout.NORTH); return (finalPanel); }
From source file:org.docx4all.swing.ExternalHyperlinkDialog.java
private void fillRow1(JPanel host, GridBagConstraints c) { c.gridx = 0;// ww w .ja va 2 s. c om c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.insets = gridCellInsets; c.ipadx = 0; c.ipady = 0; c.anchor = GridBagConstraints.LINE_START; c.fill = GridBagConstraints.NONE; this.displayTextLabel = new JLabel("Text to display"); host.add(this.displayTextLabel, c); c.gridx = 1; c.gridy = 0; c.gridwidth = 2; c.gridheight = 1; c.weightx = 0.0; c.weighty = 0.0; c.insets = gridCellInsets; c.ipadx = 0; c.ipady = 0; c.anchor = GridBagConstraints.LINE_START; c.fill = GridBagConstraints.HORIZONTAL; this.displayTextField = new JTextField(70); //this.displayTextField.setMinimumSize(new Dimension(100, 70)); //this.displayTextField.setPreferredSize(new Dimension(100, 70)); host.add(this.displayTextField, c); }
From source file:pcgen.gui2.dialog.AboutDialog.java
/** * Construct a GridBagConstraints record using defaults and * some basic supplied details./*from w ww.ja va2 s. c om*/ * * @param xPos The column the field should appear in. * @param yPos The row the field should appear in. * @param anchor Where the field should be positioned. * @return A GridBagConstraints object. */ private GridBagConstraints buildConstraints(int xPos, int yPos, int anchor) { GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = xPos; constraints.gridy = yPos; constraints.fill = GridBagConstraints.NONE; constraints.anchor = anchor; constraints.insets = new Insets(5, 0, 5, 10); return constraints; }
From source file:com.microsoft.azure.hdinsight.spark.ui.SparkSubmissionContentPanel.java
private void addSparkClustersLineItem() { JLabel sparkClusterLabel = new JLabel("Spark clusters(Linux only)"); sparkClusterLabel.setToolTipText(/* ww w. ja v a 2 s. c o m*/ "The HDInsight Spark cluster you want to submit your application to. Only Linux cluster is supported."); GridBagConstraints c11 = new GridBagConstraints(); c11.gridx = 0; c11.gridy = 0; c11.insets = new Insets(margin, margin, 0, margin); add(sparkClusterLabel, new GridBagConstraints(0, displayLayoutCurrentRow, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(margin, margin, 0, margin), 0, 0)); clustersListComboBox = new ComboboxWithBrowseButton(); clustersListComboBox.setButtonIcon(StreamUtil.getImageResourceFile(REFRESH_BUTTON_PATH)); clustersListComboBox.getButton().setToolTipText("Refresh"); clustersListComboBox.getButton().addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { Cursor cursor = getCursor(); setCursor(new Cursor(Cursor.WAIT_CURSOR)); List<IClusterDetail> clusterDetails = ClusterManagerEx.getInstance() .getClusterDetails(submitModel.getProject()); setCursor(cursor); submitModel.setClusterComboBoxModel(clusterDetails); } }); clustersListComboBox.getComboBox().setToolTipText( "The HDInsight Spark cluster you want to submit your application to. Only Linux cluster is supported."); clustersListComboBox.getComboBox().addPropertyChangeListener(new PropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent evt) { if (evt.getPropertyName() == "model" && evt.getNewValue() instanceof DefaultComboBoxModel) { int size = ((DefaultComboBoxModel) evt.getNewValue()).getSize(); setVisibleForFixedErrorMessageLabel(ErrorMessageLabelTag.ClusterName.ordinal(), size <= 0); } } }); add(clustersListComboBox, new GridBagConstraints(1, displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(margin, margin, 0, margin), 0, 0)); errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()] = new JLabel( "Cluster Name Should not be null"); errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()] .setForeground(DarkThemeManager.getInstance().getErrorMessageColor()); clustersListComboBox.getComboBox().addItemListener(new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { setVisibleForFixedErrorMessageLabel(0, clustersListComboBox.getComboBox().getItemCount() == 0); } }); add(errorMessageLabels[ErrorMessageLabelTag.ClusterName.ordinal()], new GridBagConstraints(1, ++displayLayoutCurrentRow, 0, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, margin, 0, 0), 0, 0)); }
From source file:org.executequery.gui.editor.ManageShortcutsPanel.java
private JPanel createMoveButtonsPanel() { JPanel panel = new JPanel(new GridBagLayout()); JButton addButton = ActionUtilities.createButton(this, "addShortcut", GUIUtilities.loadIcon("ShortcutAdd16.png"), "Add shortcut"); JButton deleteButton = ActionUtilities.createButton(this, "deleteShortcut", GUIUtilities.loadIcon("ShortcutDelete16.png"), "Delete shortcut"); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridy = 0;//from w w w. jav a 2 s. c om gbc.gridx = 0; gbc.insets.top = 0; gbc.insets.bottom = 10; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.CENTER; panel.add(addButton, gbc); gbc.gridy++; panel.add(deleteButton, gbc); return panel; }
From source file:org.fhcrc.cpl.viewer.quant.gui.ProteinQuantSummaryFrame.java
License:asdf
/** * Initialize the GUI components//from w w w.j a va 2 s . c om */ protected void initGUI() { //Global stuff setSize(fullWidth, fullHeight); eventPropertiesTable = new QuantEvent.QuantEventPropertiesTable(); eventPropertiesTable.setVisible(true); JScrollPane eventPropsScrollPane = new JScrollPane(); eventPropsScrollPane.setViewportView(eventPropertiesTable); eventPropsScrollPane.setSize(propertiesWidth, propertiesHeight); eventPropertiesDialog = new JDialog(this, "Event Properties"); eventPropertiesDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); eventPropertiesDialog.setSize(propertiesWidth, propertiesHeight); eventPropertiesDialog.setContentPane(eventPropsScrollPane); ListenerHelper helper = new ListenerHelper(this); setTitle("Protein Summary"); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.PAGE_START; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.insets = new Insets(5, 5, 5, 5); gbc.weighty = 1; gbc.weightx = 1; try { (getOwner()).setIconImage(ImageIO.read(WorkbenchFrame.class.getResourceAsStream("icon.gif"))); } catch (Exception e) { } try { Localizer.renderSwixml("org/fhcrc/cpl/viewer/quant/gui/ProteinQuantSummaryFrame.xml", this); assert null != contentPanel; setContentPane(contentPanel); } catch (Exception x) { ApplicationContext.errorMessage("error creating dialog", x); throw new RuntimeException(x); } buttonSelectAllVisible.setEnabled(false); helper.addListener(buttonSelectAllVisible, "buttonSelectAllVisible_actionPerformed"); buttonDeselectAll.setEnabled(false); helper.addListener(buttonDeselectAll, "buttonDeselectAll_actionPerformed"); buildTurkHITsButton.setEnabled(false); helper.addListener(buildTurkHITsButton, "buttonBuildTurkHITs_actionPerformed"); loadSelectedEventsButton.setEnabled(false); helper.addListener(loadSelectedEventsButton, "buttonLoadSelected_actionPerformed"); autoAssessSelectedEventsButton.setEnabled(false); helper.addListener(autoAssessSelectedEventsButton, "buttonAutoAssess_actionPerformed"); showPropertiesButton.setEnabled(false); helper.addListener(showPropertiesButton, "buttonShowProperties_actionPerformed"); showProteinRatiosButton.setEnabled(false); helper.addListener(showProteinRatiosButton, "buttonShowProteinRatios_actionPerformed"); //summary panel summaryPanel.setBorder(BorderFactory.createLineBorder(Color.gray)); summaryPanel.setPreferredSize(new Dimension(fullWidth, summaryPanelHeight)); summaryPanel.setMinimumSize(new Dimension(200, summaryPanelHeight)); gbc.fill = GridBagConstraints.NONE; gbc.gridwidth = 1; summaryPanel.add(buttonSelectAllVisible, gbc); summaryPanel.add(buttonDeselectAll, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; summaryPanel.add(showPropertiesButton, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; summaryPanel.add(showProteinRatiosButton, gbc); gbc.gridwidth = 1; summaryPanel.add(loadSelectedEventsButton, gbc); gbc.gridwidth = GridBagConstraints.RELATIVE; summaryPanel.add(autoAssessSelectedEventsButton, gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; summaryPanel.add(buildTurkHITsButton, gbc); gbc.fill = GridBagConstraints.BOTH; eventsScrollPane = new JScrollPane(); eventsScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); eventsScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); eventsPanel = new JPanel(); eventsPanel.setLayout(new GridBagLayout()); eventsTable = new QuantEventsSummaryTable(); eventsTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); eventsTable.getSelectionModel().addListSelectionListener(new EventsTableListSelectionHandler()); eventsScrollPane.setViewportView(eventsTable); eventsScrollPane.setMinimumSize(new Dimension(400, 400)); gbc.insets = new Insets(0, 0, 0, 0); mainPanel.add(eventsScrollPane, gbc); logRatioHistogramPanel = new PanelWithLogRatioHistAndFields(); logRatioHistogramPanel.setBorder(BorderFactory.createTitledBorder("Log Ratios")); logRatioHistogramPanel.setPreferredSize(new Dimension(width - 10, 300)); gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 100; gbc.gridwidth = GridBagConstraints.REMAINDER; add(logRatioHistogramPanel, gbc); //status message messageLabel = new JLabel(); messageLabel.setBackground(Color.WHITE); messageLabel.setFont(Font.decode("verdana plain 12")); messageLabel.setText(" "); statusPanel = new JPanel(); gbc.weighty = 1; statusPanel.setPreferredSize(new Dimension(width - 10, 50)); statusPanel.add(messageLabel, gbc); add(statusPanel, gbc); //per-protein event summary table; disembodied //todo: move this into its own class? it's getting kind of complicated proteinRatiosTable = new JTable(); proteinRatiosTable.setVisible(true); ListSelectionModel proteinTableSelectionModel = proteinRatiosTable.getSelectionModel(); proteinTableSelectionModel.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); proteinTableSelectionModel.addListSelectionListener(new ProteinTableListSelectionHandler()); JScrollPane proteinRatiosScrollPane = new JScrollPane(); proteinRatiosScrollPane.setViewportView(proteinRatiosTable); proteinRatiosScrollPane.setPreferredSize(new Dimension(proteinDialogWidth, proteinDialogHeight - PROTEINTABLE_HISTPANEL_HEIGHT - PROTEINTABLE_SCATTERPLOTPANEL_HEIGHT - 70)); proteinRatiosDialog = new JDialog(this, "Protein Ratios"); proteinRatiosDialog.setDefaultCloseOperation(JDialog.HIDE_ON_CLOSE); proteinRatiosDialog.setSize(proteinDialogWidth, proteinDialogHeight); JPanel proteinRatiosContentPanel = new JPanel(); gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; proteinRatiosContentPanel.add(proteinRatiosScrollPane, gbc); proteinRatiosDialog.setContentPane(proteinRatiosContentPanel); perProteinLogRatioHistogramPanel = new PanelWithLogRatioHistAndFields(); perProteinLogRatioHistogramPanel.addRangeUpdateListener(new ProteinTableLogRatioHistogramListener()); perProteinLogRatioHistogramPanel.setBorder(BorderFactory.createTitledBorder("Log Ratios")); perProteinLogRatioHistogramPanel .setPreferredSize(new Dimension(proteinDialogWidth - 10, PROTEINTABLE_HISTPANEL_HEIGHT)); gbc.fill = GridBagConstraints.BOTH; gbc.gridwidth = GridBagConstraints.REMAINDER; proteinRatiosDialog.add(perProteinLogRatioHistogramPanel, gbc); perProteinPeptideLogRatioPanel = new JPanel(); perProteinPeptideLogRatioPanel.setBorder(BorderFactory.createTitledBorder("By Peptide")); perProteinPeptideLogRatioPanel .setPreferredSize(new Dimension(proteinDialogWidth - 10, PROTEINTABLE_SCATTERPLOTPANEL_HEIGHT)); proteinRatiosDialog.add(perProteinPeptideLogRatioPanel, gbc); }
From source file:ro.nextreports.designer.wizrep.QueryWizardPanel.java
private void init() { setLayout(new BorderLayout()); ButtonGroup bg = new ButtonGroup(); bg.add(selectionRB);//from w ww .ja v a 2 s . com bg.add(queryRB); bg.add(editRB); selectionRB.setSelected(true); selectionRB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selection(); } }); queryRB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selection(); } }); editRB.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { selection(); } }); editor = new EditorPanel(); parametersPanel = new ParametersPanel(); parametersPanel.setPreferredSize(new Dimension(120, 200)); queryPanel = new QueryBrowserPanel() { protected void selection() { String name = queryPanel.getSelectedFilePath(); if (queryPanel.querySelected()) { ReportPersistence repPersist = ReportPersistenceFactory .createReportPersistence(Globals.getReportPersistenceType()); Report report = repPersist.loadReport(name); context.setAttribute(WizardConstants.LOAD_REPORT, report); String sql = report.getSql(); if (sql == null) { sql = report.getQuery().toString(); } editor.setText(sql); parametersPanel.set(report.getParameters()); } else { context.setAttribute(WizardConstants.LOAD_REPORT, null); editor.setText(""); parametersPanel.set(new ArrayList<QueryParameter>()); } } }; sqlLabel = new JLabel("<html><b>Sql</b></html>"); easyPanel = new EasySelectColumnsPanel(); JPanel qPanel = new JPanel(new GridBagLayout()); JPanel radioPanel = new JPanel(); radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.X_AXIS)); radioPanel.add(selectionRB); radioPanel.add(Box.createHorizontalStrut(5)); radioPanel.add(queryRB); radioPanel.add(Box.createHorizontalStrut(5)); radioPanel.add(editRB); qPanel.add(radioPanel, new GridBagConstraints(0, 0, 4, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); queryLabel = new JLabel(I18NSupport.getString("query.name")); qPanel.add(queryLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); qPanel.add(queryPanel, new GridBagConstraints(1, 1, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 0, 0), 0, 0)); qPanel.add(sqlLabel, new GridBagConstraints(0, 2, 3, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 0, 0), 0, 0)); qPanel.add(editor, new GridBagConstraints(0, 3, 3, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); qPanel.add(parametersPanel, new GridBagConstraints(3, 2, 1, 2, 0.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.VERTICAL, new Insets(0, 5, 5, 5), 0, 0)); qPanel.add(emptyLabel, new GridBagConstraints(0, 4, 4, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0)); qPanel.add(easyPanel, new GridBagConstraints(0, 2, 4, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0)); selection(); add(qPanel, BorderLayout.CENTER); }
From source file:org.esa.snap.ui.tooladapter.dialogs.ToolParameterEditorDialog.java
private JComponent addBoolPropertyEditor(JPanel parent, String label, String propertyName, Boolean value, int line) { parent.add(new JLabel(label), getConstraints(line, 1, 1)); PropertyDescriptor propertyDescriptor = container.getDescriptor(propertyName); CheckBoxEditor boolEditor = new CheckBoxEditor(); JComponent editorComponent = boolEditor.createEditorComponent(propertyDescriptor, valuesContext); ((JCheckBox) editorComponent).setSelected(value); editorComponent.setPreferredSize(new Dimension(30, 30)); GridBagConstraints constraints = getConstraints(line, 0, 1); constraints.fill = GridBagConstraints.NONE; constraints.anchor = GridBagConstraints.LINE_END; parent.add(editorComponent, constraints); return editorComponent; }
From source file:com._17od.upm.gui.MainWindow.java
private void addComponentsToPane() { // Ensure the layout manager is a BorderLayout if (!(getContentPane().getLayout() instanceof GridBagLayout)) { getContentPane().setLayout(new GridBagLayout()); }//from www. j ava 2s . c o m // Create the menubar setJMenuBar(createMenuBar()); GridBagConstraints c = new GridBagConstraints(); // The toolbar Row c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.FIRST_LINE_START; c.insets = new Insets(0, 0, 0, 0); c.weightx = 0; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; Component toolbar = createToolBar(); getContentPane().add(toolbar, c); // Keep the frame background color consistent getContentPane().setBackground(toolbar.getBackground()); // The seperator Row c.gridx = 0; c.gridy = 1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 0); c.weightx = 1; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; getContentPane().add(new JSeparator(), c); // The search field row searchIcon = new JLabel(Util.loadImage("search.gif")); searchIcon.setDisabledIcon(Util.loadImage("search_d.gif")); searchIcon.setEnabled(false); c.gridx = 0; c.gridy = 2; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(5, 1, 5, 1); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; getContentPane().add(searchIcon, c); searchField = new JTextField(15); searchField.setEnabled(false); searchField.setMinimumSize(searchField.getPreferredSize()); searchField.getDocument().addDocumentListener(new DocumentListener() { public void changedUpdate(DocumentEvent e) { // This method never seems to be called } public void insertUpdate(DocumentEvent e) { dbActions.filter(); } public void removeUpdate(DocumentEvent e) { dbActions.filter(); } }); searchField.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { dbActions.resetSearch(); } else if (e.getKeyCode() == KeyEvent.VK_ENTER) { // If the user hits the enter key in the search field and // there's only one item // in the listview then open that item (this code assumes // that the one item in // the listview has already been selected. this is done // automatically in the // DatabaseActions.filter() method) if (accountsListview.getModel().getSize() == 1) { viewAccountMenuItem.doClick(); } } } }); c.gridx = 1; c.gridy = 2; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(5, 1, 5, 1); c.weightx = 0; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; getContentPane().add(searchField, c); resetSearchButton = new JButton(Util.loadImage("stop.gif")); resetSearchButton.setDisabledIcon(Util.loadImage("stop_d.gif")); resetSearchButton.setEnabled(false); resetSearchButton.setToolTipText(Translator.translate(RESET_SEARCH_TXT)); resetSearchButton.setActionCommand(RESET_SEARCH_TXT); resetSearchButton.addActionListener(this); resetSearchButton.setBorder(BorderFactory.createEmptyBorder()); resetSearchButton.setFocusable(false); c.gridx = 2; c.gridy = 2; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(5, 1, 5, 1); c.weightx = 1; c.weighty = 0; c.gridwidth = 1; c.fill = GridBagConstraints.NONE; getContentPane().add(resetSearchButton, c); // The accounts listview row accountsListview = new JList(); accountsListview.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); accountsListview.setSelectedIndex(0); accountsListview.setVisibleRowCount(10); accountsListview.setModel(new SortedListModel()); JScrollPane accountsScrollList = new JScrollPane(accountsListview, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); accountsListview.addFocusListener(new FocusAdapter() { public void focusGained(FocusEvent e) { // If the listview gets focus, there is one ore more items in // the listview and there is nothing // already selected, then select the first item in the list if (accountsListview.getModel().getSize() > 0 && accountsListview.getSelectedIndex() == -1) { accountsListview.setSelectionInterval(0, 0); } } }); accountsListview.addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { dbActions.setButtonState(); } }); accountsListview.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { viewAccountMenuItem.doClick(); } } }); accountsListview.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_ENTER) { viewAccountMenuItem.doClick(); } } }); // Create a shortcut to delete account functionality with DEL(delete) // key accountsListview.addKeyListener(new KeyAdapter() { public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_DELETE) { try { dbActions.reloadDatabaseBefore(new DeleteAccountAction()); } catch (InvalidPasswordException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (ProblemReadingDatabaseFile e1) { // TODO Auto-generated catch block e1.printStackTrace(); } catch (IOException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } } } }); c.gridx = 0; c.gridy = 3; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 1, 1, 1); c.weightx = 1; c.weighty = 1; c.gridwidth = 3; c.fill = GridBagConstraints.BOTH; getContentPane().add(accountsScrollList, c); // The "File Changed" panel c.gridx = 0; c.gridy = 4; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 1, 0, 1); c.ipadx = 3; c.ipady = 3; c.weightx = 0; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.BOTH; databaseFileChangedPanel = new JPanel(); databaseFileChangedPanel.setLayout(new BoxLayout(databaseFileChangedPanel, BoxLayout.X_AXIS)); databaseFileChangedPanel.setBackground(new Color(249, 172, 60)); databaseFileChangedPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); JLabel fileChangedLabel = new JLabel("Database file changed"); fileChangedLabel.setAlignmentX(LEFT_ALIGNMENT); databaseFileChangedPanel.add(fileChangedLabel); databaseFileChangedPanel.add(Box.createHorizontalGlue()); JButton reloadButton = new JButton("Reload"); reloadButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { dbActions.reloadDatabaseFromDisk(); } catch (Exception ex) { dbActions.errorHandler(ex); } } }); databaseFileChangedPanel.add(reloadButton); databaseFileChangedPanel.setVisible(false); getContentPane().add(databaseFileChangedPanel, c); // Add the statusbar c.gridx = 0; c.gridy = 5; c.anchor = GridBagConstraints.CENTER; c.insets = new Insets(0, 1, 1, 1); c.weightx = 1; c.weighty = 0; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; getContentPane().add(statusBar, c); }
From source file:com.limegroup.gnutella.gui.LicenseWindow.java
/** * Constructs the dialog itself.//from w w w.j av a2 s .co m */ protected void constructDialog(Container parent) { // Add the // [ img ] | [ license ] createTopOfWindow(parent); GridBagConstraints c = new GridBagConstraints(); // Add a ----------- // line below img & license JComponent line = new Line(ThemeFileHandler.TABLE_BACKGROUND_COLOR.getValue()); c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(0, 0, 2, 0); parent.add(line, c); // Create the details panel. buildDetails(); // Add the details panel. c.gridwidth = GridBagConstraints.REMAINDER; c.fill = GridBagConstraints.BOTH; c.insets = new Insets(4, 4, 0, 4); c.weighty = 1; c.weightx = 1; parent.add(DETAILS, c); // Add a ------------ // line below the details. line = new Line(ThemeFileHandler.TABLE_BACKGROUND_COLOR.getValue()); c.gridwidth = GridBagConstraints.REMAINDER; c.gridheight = GridBagConstraints.RELATIVE; c.fill = GridBagConstraints.HORIZONTAL; c.insets = new Insets(2, 0, 2, 0); c.ipady = 0; c.weighty = 0; c.weightx = 0; parent.add(line, c); // Add an OK button out of the window. JButton button = new JButton(GUIMediator.getStringResource("GENERAL_OK_BUTTON_LABEL")); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ev) { LicenseWindow.this.dispose(); LicenseWindow.this.setVisible(false); } }); c.gridheight = GridBagConstraints.REMAINDER; c.gridwidth = GridBagConstraints.REMAINDER; c.insets = new Insets(0, 0, 4, 4); c.fill = GridBagConstraints.NONE; c.anchor = GridBagConstraints.EAST; parent.add(button, c); pack(); }