List of usage examples for java.awt GridBagConstraints WEST
int WEST
To view the source code for java.awt GridBagConstraints WEST.
Click Source Link
From source file:burp.BurpExtender.java
private <T> JComboBox<T> createComboBox(String label, Container cont, int buttonY, JButton button) { createSettingsLabel(label, cont);// www .j a v a 2 s . co m JComboBox<T> box = new JComboBox<T>(); box.setMaximumRowCount(16); callbacks.customizeUiComponent(box); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = 1; gbc.fill = GridBagConstraints.HORIZONTAL; cont.add(box, gbc); button.setIcon(refreshSpinner[0]); button.setPreferredSize( new Dimension(refreshSpinner[0].getIconHeight() + 4, refreshSpinner[0].getIconHeight() + 4)); callbacks.customizeUiComponent(button); gbc = new GridBagConstraints(); gbc.gridx = 2; gbc.gridy = buttonY; gbc.anchor = GridBagConstraints.WEST; cont.add(button, gbc); return box; }
From source file:com.ciphertool.zodiacengine.gui.view.SwingUserInterface.java
public void init() { this.addWindowListener(getWindowClosingListener()); this.setTitle(windowTitle); this.setSize(windowWidth, windowHeight); this.setLocationRelativeTo(null); this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); JPanel containerPanel = new JPanel(); getContentPane().add(containerPanel); /*/*from ww w .j a va 2 s . c o m*/ * Use a BorderLayout for the main container so we can use the SOUTH * panel as a status bar and use the NORTH panel as a menu bar, etc. */ containerPanel.setLayout(new BorderLayout()); JPanel bottomPanel = new JPanel(); containerPanel.add(bottomPanel, BorderLayout.SOUTH); bottomPanel.setLayout(new BorderLayout()); JPanel buttonPanel = new JPanel(); bottomPanel.add(buttonPanel, BorderLayout.CENTER); GridLayout gridLayout = new GridLayout(1, 2, 5, 5); buttonPanel.setLayout(gridLayout); buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); startButton = new JButton(startButtonText); startButton.addActionListener(getStartButtonActionListener(false)); buttonPanel.add(startButton); debugButton = new JButton(debugButtonText); debugButton.addActionListener(getStartButtonActionListener(true)); buttonPanel.add(debugButton); continueButton = new JButton(continueButtonText); continueButton.addActionListener(getContinueButtonActionListener()); buttonPanel.add(continueButton); continueButton.setEnabled(false); stopButton = new JButton(stopButtonText); stopButton.addActionListener(getStopButtonActionListener()); buttonPanel.add(stopButton); stopButton.setEnabled(false); JPanel statusPanel = new JPanel(); bottomPanel.add(statusPanel, BorderLayout.SOUTH); statusLabel = new JLabel(statusNotRunning); statusPanel.add(statusLabel); /* * Next make a grid bag for the thirteen input elements with labels on * the left and spinners on the right. */ JPanel mainPanel = new JPanel(); GridBagLayout gridBagLayout = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); constraints.fill = GridBagConstraints.BOTH; constraints.insets = new Insets(5, 5, 5, 5); constraints.anchor = GridBagConstraints.WEST; mainPanel.setLayout(gridBagLayout); mainPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); containerPanel.add(mainPanel, BorderLayout.CENTER); List<Cipher> ciphers = cipherDao.findAll(); cipherMap = new HashMap<String, Cipher>(); cipherComboBox = new JComboBox<String>(); String cipherName; for (Cipher cipher : ciphers) { cipherName = cipher.getName(); cipherMap.put(cipherName, cipher); cipherComboBox.addItem(cipherName); if (cipher.getName().equals(defaultCipher)) { cipherComboBox.setSelectedItem(cipherName); } } JLabel cipherNameLabel = new JLabel(cipherNameText); cipherComboBox.addActionListener(getCipherComboBoxActionListener()); constraints.weightx = LAYOUT_LABEL_WEIGHT; constraints.gridwidth = GridBagConstraints.RELATIVE; gridBagLayout.setConstraints(cipherNameLabel, constraints); mainPanel.add(cipherNameLabel); constraints.weightx = LAYOUT_INPUT_WEIGHT; constraints.gridwidth = GridBagConstraints.REMAINDER; gridBagLayout.setConstraints(cipherComboBox, constraints); mainPanel.add(cipherComboBox); appendGenerationsSpinner(gridBagLayout, constraints, mainPanel); appendRunContinuouslyCheckBox(gridBagLayout, constraints, mainPanel); appendPopulationSpinner(gridBagLayout, constraints, mainPanel); appendLifespanSpinner(gridBagLayout, constraints, mainPanel); appendSurvivalRateSpinner(gridBagLayout, constraints, mainPanel); appendMutationRateSpinner(gridBagLayout, constraints, mainPanel); appendMaxMutationsPerIndividualSpinner(gridBagLayout, constraints, mainPanel); appendCrossoverRateSpinner(gridBagLayout, constraints, mainPanel); appendMutateDuringCrossoverCheckBox(gridBagLayout, constraints, mainPanel); appendFitnessEvaluatorComboBox(gridBagLayout, constraints, mainPanel); appendCrossoverAlgorithmComboBox(gridBagLayout, constraints, mainPanel); appendMutationAlgorithmComboBox(gridBagLayout, constraints, mainPanel); appendSelectionAlgorithmComboBox(gridBagLayout, constraints, mainPanel); appendSelectorComboBox(gridBagLayout, constraints, mainPanel); appendCompareToKnownSolutionCheckBox(gridBagLayout, constraints, mainPanel); SwingUtilities.invokeLater(new Runnable() { public void run() { setVisible(true); toFront(); } }); }
From source file:it.ventuland.ytd.ui.GUIClient.java
private void addComponentsToPane(final Container pane) { this.panel = new JPanel(); this.panel.setLayout(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.insets = new Insets(5, 5, 5, 5); gbc.anchor = GridBagConstraints.WEST; ActionManager lActionManager = new ActionManager(); dlm = new DefaultListModel<String>(); this.urllist = new JList<String>(dlm); // TODO maybe we add a button to remove added URLs from list? //this.userlist.setSelectionMode( ListSelectionModel.MULTIPLE_INTERVAL_SELECTION ); this.urllist.setFocusable(false); textarea = new JTextArea(2, 2); textarea.setEditable(true);/*from w ww . j ava 2 s. c o m*/ textarea.setFocusable(false); JScrollPane leftscrollpane = new JScrollPane(this.urllist); JScrollPane rightscrollpane = new JScrollPane(textarea); this.middlepane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, leftscrollpane, rightscrollpane); this.middlepane.setOneTouchExpandable(true); this.middlepane.setDividerLocation(150); Dimension minimumSize = new Dimension(25, 25); leftscrollpane.setMinimumSize(minimumSize); rightscrollpane.setMinimumSize(minimumSize); this.directorybutton = new JButton("", createImageIcon("images/open.png", "")); gbc.gridx = 0; gbc.gridy = 0; this.directorybutton.addActionListener(lActionManager); this.panel.add(this.directorybutton, gbc); this.saveconfigcheckbox = new JCheckBox("Save config"); this.saveconfigcheckbox.setSelected(false); this.panel.add(this.saveconfigcheckbox); this.saveconfigcheckbox.setEnabled(false); // TODO check if initial download directory exists // assume that at least the users homedir exists String shomedir = System.getProperty("user.home").concat(File.separator); gbc.gridx = 0; gbc.gridy = 2; gbc.gridwidth = 2; gbc.fill = GridBagConstraints.HORIZONTAL; this.directorytextfield = new JTextField(shomedir, 20 + (mIsDebug ? 48 : 0)); this.directorytextfield.setEnabled(false); this.directorytextfield.setFocusable(true); this.directorytextfield.addActionListener(lActionManager); this.panel.add(this.directorytextfield, gbc); JLabel dirhint = new JLabel("Download to folder:"); gbc.gridx = 0; gbc.gridy = 1; this.panel.add(dirhint, gbc); this.middlepane.setPreferredSize(new Dimension(Toolkit.getDefaultToolkit().getScreenSize().width / 3, Toolkit.getDefaultToolkit().getScreenSize().height / 4 + (mIsDebug ? 200 : 0))); gbc.gridx = 0; gbc.gridy = 3; gbc.fill = GridBagConstraints.BOTH; gbc.weighty = 2; gbc.weightx = 2; gbc.gridwidth = 2; this.panel.add(this.middlepane, gbc); // radio buttons for resolution to download mVideoResolutionBtnGrp = new ButtonGroup(); JPanel lRadioPanel = new JPanel(new GridLayout(1, 0)); List<Object> lVidQ = mAppContext.getList("youtube-downloader.video-quality"); JRadioButton lRadioButton = null; for (Object obj : lVidQ) { String lQuality = (String) obj; String lToolTip = mAppContext.getString("youtube-downloader.video-quality." + lQuality + ".tooltip"); boolean lSelected = mAppContext .getBoolean("youtube-downloader.video-quality." + lQuality + ".selected"); boolean lEnabled = mAppContext.getBoolean("youtube-downloader.video-quality." + lQuality + ".enabled"); lRadioButton = new JRadioButton(lQuality); lRadioButton.setName(lQuality); lRadioButton.setActionCommand(lQuality.toLowerCase()); lRadioButton.addActionListener(lActionManager); lRadioButton.setToolTipText(lToolTip); lRadioButton.setSelected(lSelected); lRadioButton.setEnabled(lEnabled); mVideoResolutionBtnGrp.add(lRadioButton); lRadioPanel.add(lRadioButton); } gbc.gridx = 1; gbc.gridy = 0; gbc.gridheight = 0; gbc.gridwidth = 0; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.NORTHEAST; this.panel.add(lRadioPanel, gbc); // radio buttons for video format to download mVideoQualityBtnGrp = new ButtonGroup(); lRadioPanel = new JPanel(new GridLayout(1, 0)); save3dcheckbox = new JCheckBox("3D"); save3dcheckbox.setToolTipText("stereoscopic video"); save3dcheckbox.setSelected(false); save3dcheckbox.setEnabled(true); lRadioPanel.add(save3dcheckbox); List<Object> lVidR = mAppContext.getList("youtube-downloader.video-resolution"); lRadioButton = null; for (Object obj : lVidR) { String lResolution = (String) obj; String lToolTip = mAppContext .getString("youtube-downloader.video-resolution." + lResolution + ".tooltip"); boolean lSelected = mAppContext .getBoolean("youtube-downloader.video-resolution." + lResolution + ".selected"); boolean lEnabled = mAppContext .getBoolean("youtube-downloader.video-resolution." + lResolution + ".enabled"); lRadioButton = new JRadioButton(lResolution); lRadioButton.setName(lResolution); lRadioButton.setActionCommand(lResolution.toLowerCase()); lRadioButton.addActionListener(lActionManager); lRadioButton.setToolTipText(lToolTip); lRadioButton.setSelected(lSelected); lRadioButton.setEnabled(lEnabled); mVideoQualityBtnGrp.add(lRadioButton); lRadioPanel.add(lRadioButton); } gbc.gridx = 1; gbc.gridy = 1; gbc.gridheight = 0; gbc.gridwidth = 0; gbc.fill = GridBagConstraints.NONE; gbc.anchor = GridBagConstraints.NORTHEAST; this.panel.add(lRadioPanel, gbc); JLabel hint = new JLabel("Type, paste or drag'n drop a YouTube video address:"); gbc.fill = 0; gbc.gridwidth = 0; gbc.gridheight = 1; gbc.weightx = 0; gbc.weighty = 0; gbc.gridx = 0; gbc.gridy = 4; gbc.anchor = GridBagConstraints.WEST; this.panel.add(hint, gbc); textinputfield = new JTextField(20); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = 0; gbc.gridy = 5; gbc.gridwidth = 2; textinputfield.setEnabled(true); textinputfield.setFocusable(true); textinputfield.addActionListener(lActionManager); textinputfield.getDocument().addDocumentListener(new UrlInsertListener()); this.panel.add(textinputfield, gbc); this.quitbutton = new JButton("", createImageIcon("images/exit.png", "")); gbc.gridx = 2; gbc.gridy = 5; gbc.gridwidth = 0; this.quitbutton.addActionListener(lActionManager); this.quitbutton.setActionCommand("quit"); this.quitbutton.setToolTipText("Exit."); this.panel.add(this.quitbutton, gbc); pane.add(this.panel); addWindowListener(new GUIWindowAdapter()); this.setDropTarget(new DropTarget(this, new DragDropListener())); textarea.setTransferHandler(null); // otherwise the dropped text would be inserted }
From source file:org.zaproxy.zap.extension.spiderAjax.SpiderPanel.java
/** * /*from w w w . ja v a 2 s . c om*/ * @return the panel toolbar */ private javax.swing.JToolBar getPanelToolbar() { if (panelToolbar == null) { panelToolbar = new javax.swing.JToolBar(); panelToolbar.setLayout(new java.awt.GridBagLayout()); panelToolbar.setEnabled(true); panelToolbar.setFloatable(false); panelToolbar.setRollover(true); panelToolbar.setPreferredSize(new java.awt.Dimension(800, 30)); panelToolbar.setFont(new java.awt.Font("Dialog", java.awt.Font.PLAIN, 12)); panelToolbar.setName("Spider AJAX Toolbar"); GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); GridBagConstraints gridBagConstraints4 = new GridBagConstraints(); GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); GridBagConstraints gridBagConstraintsX = new GridBagConstraints(); GridBagConstraints gridBagConstraints7 = new GridBagConstraints(); GridBagConstraints gridBagConstraintsy = new GridBagConstraints(); gridBagConstraints1.gridx = 0; gridBagConstraints1.gridy = 0; gridBagConstraints1.insets = new java.awt.Insets(0, 0, 0, 0); gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints2.gridx = 1; gridBagConstraints2.gridy = 0; gridBagConstraints2.insets = new java.awt.Insets(0, 0, 0, 0); gridBagConstraints2.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints3.gridx = 2; gridBagConstraints3.gridy = 0; gridBagConstraints3.insets = new java.awt.Insets(0, 0, 0, 0); gridBagConstraints3.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints4.gridx = 3; gridBagConstraints4.gridy = 0; gridBagConstraints4.insets = new java.awt.Insets(0, 0, 0, 0); gridBagConstraints4.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints5.gridx = 4; gridBagConstraints5.gridy = 0; gridBagConstraints5.insets = new java.awt.Insets(0, 0, 0, 0); gridBagConstraints5.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints7.gridx = 6; gridBagConstraints7.gridy = 0; gridBagConstraints7.insets = new java.awt.Insets(0, 0, 0, 0); gridBagConstraints7.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraintsX.gridx = 5; gridBagConstraintsX.gridy = 0; gridBagConstraintsX.weightx = 1.0; gridBagConstraintsX.weighty = 1.0; gridBagConstraintsX.insets = new java.awt.Insets(0, 0, 0, 0); gridBagConstraintsX.anchor = java.awt.GridBagConstraints.EAST; gridBagConstraintsX.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraintsy.gridx = 21; gridBagConstraintsy.gridy = 0; gridBagConstraintsy.insets = new java.awt.Insets(0, 0, 0, 0); gridBagConstraintsy.anchor = java.awt.GridBagConstraints.WEST; filterStatus = new JLabel(this.extension.getMessages().getString("spiderajax.panel.subtitle")); JLabel t1 = new JLabel(); panelToolbar.add(getStartScanButton(), gridBagConstraints1); panelToolbar.add(getStopScanButton(), gridBagConstraints2); panelToolbar.add(filterStatus, gridBagConstraints3); panelToolbar.add(foundLabel, gridBagConstraints4); panelToolbar.add(t1, gridBagConstraintsX); panelToolbar.add(getOptionsButton(), gridBagConstraintsy); } return panelToolbar; }
From source file:ro.nextreports.designer.wizrep.QueryWizardPanel.java
private void init() { setLayout(new BorderLayout()); ButtonGroup bg = new ButtonGroup(); bg.add(selectionRB);//w w w.j ava 2 s .c o m 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:burp.BurpExtender.java
private void createSettingsLabel(String label, Container cont) { JLabel labelField = new JLabel(label); labelField.setHorizontalAlignment(SwingConstants.LEFT); callbacks.customizeUiComponent(labelField); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = 1;//from w w w.j av a 2s . com gbc.gridx = 0; gbc.insets = new Insets(0, 12, 0, 0); gbc.anchor = GridBagConstraints.WEST; cont.add(labelField, gbc); }
From source file:com.microsoft.azure.hdinsight.spark.ui.SparkSubmissionContentPanel.java
private void addSparkClustersLineItem() { JLabel sparkClusterLabel = new JLabel("Spark clusters(Linux only)"); sparkClusterLabel.setToolTipText(//from w w w .ja va2 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:logdruid.ui.DateEditor.java
/** * Create the panel./*w ww.j a v a 2 s.c o m*/ */ public DateEditor(Repository rep) { repository = rep; model = new MyTableModel2(data, header); GridBagLayout gridBagLayout = new GridBagLayout(); gridBagLayout.columnWidths = new int[] { 15, 550, 15 }; gridBagLayout.rowHeights = new int[] { 152, 300 }; gridBagLayout.columnWeights = new double[] { 0.0, 1.0, 0.0 }; gridBagLayout.rowWeights = new double[] { 0.0, 1.0 }; setLayout(gridBagLayout); JPanel panel_1 = new JPanel(); GridBagConstraints gbc_panel_1 = new GridBagConstraints(); gbc_panel_1.fill = GridBagConstraints.BOTH; gbc_panel_1.insets = new Insets(5, 0, 5, 5); gbc_panel_1.gridx = 1; gbc_panel_1.gridy = 0; add(panel_1, gbc_panel_1); panel_1.setLayout(new BorderLayout(0, 0)); table = new JTable(model); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); table.setBorder(UIManager.getBorder("TextPane.border")); table.setPreferredScrollableViewportSize(new Dimension(0, 0)); table.setFillsViewportHeight(true); table.getSelectionModel().addListSelectionListener(new ListSelectionListener() { public void valueChanged(ListSelectionEvent e) { // ((table.getSelectedRow()!=-1)?table.convertRowIndexToModel(table.getSelectedRow()):-1) // persist repository // display selected row if (((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1) >= 0) { /* * recEditor = new RecordingEditor(repository * .getRecordings().get(((table.getSelectedRow()!=-1)?table. * convertRowIndexToModel(table.getSelectedRow()):-1)), * repository); jPanelDetail.removeAll(); */ // jPanelDetail.add(recEditor, gbc_jPanelDetail); DateFormat df = repository.getDateFormat( ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1)); if (df != null) { textFieldName.setText((String) df.getName()); textFieldPattern.setText((String) df.getPattern()); textField.setText((String) df.getDateFormat()); } // jPanelDetail.revalidate(); // jPanelDetail.repaint(); // jPanelDetail.setVisible(true); // reloadTable(); those 2 ******** // jPanelDetail.revalidate(); } } }); JScrollPane scrollPane = new JScrollPane(table); panel_1.add(scrollPane, BorderLayout.CENTER); // Set up column sizes. initColumnSizes(table); JPanel panel = new JPanel(); FlowLayout flowLayout = (FlowLayout) panel.getLayout(); flowLayout.setAlignment(FlowLayout.LEFT); flowLayout.setVgap(2); flowLayout.setHgap(2); panel_1.add(panel, BorderLayout.SOUTH); JButton btnNew = new JButton("New"); panel.add(btnNew); btnNew.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { DateFormat df = new DateFormat("name", "\\w{3}\\s[0-9]{1}/[0-9]{2}/[0-9]{2}\\s\\d\\d:\\d\\d:\\d\\d", "EEE. MM/dd/yy HH:mm:ss"); repository.addDateFormat(df); data.add(new Object[] { df.getName(), df.getPattern(), df.getDateFormat() }); table.repaint(); } }); JButton btnDuplicate = new JButton("Duplicate"); btnDuplicate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1) >= 0) { DateFormat df = repository.getDateFormat( ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1)); repository.addDateFormat(df); reloadTable(); // data.add(new Object[] { table.getRowCount()+1, // df.getName(),df.getDateFormat()}); table.repaint(); } } }); panel.add(btnDuplicate); JButton btnDelete = new JButton("Delete"); btnDelete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int selectedRow = ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1); if (selectedRow >= 0) { repository.deleteDateFormat( ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1)); data.remove( ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1)); reloadTable(); table.setRowSelectionInterval(selectedRow, selectedRow); table.repaint(); } } }); panel.add(btnDelete); jPanelDetail = new JPanel(); gbc_jPanelDetail = new GridBagConstraints(); gbc_jPanelDetail.anchor = GridBagConstraints.NORTH; gbc_jPanelDetail.fill = GridBagConstraints.HORIZONTAL; gbc_jPanelDetail.gridx = 1; gbc_jPanelDetail.gridy = 1; add(jPanelDetail, gbc_jPanelDetail); GridBagLayout gbl_jPanelDetail = new GridBagLayout(); gbl_jPanelDetail.columnWidths = new int[] { 169 }; gbl_jPanelDetail.rowHeights = new int[] { 0, 0, 0, 0, 150, 0 }; gbl_jPanelDetail.columnWeights = new double[] { 1.0, 0.0 }; gbl_jPanelDetail.rowWeights = new double[] { 0.0, 0.0, 0.0, 1.0, 1.0, 0.0 }; jPanelDetail.setLayout(gbl_jPanelDetail); JPanel panel_2 = new JPanel(); panel_2.setBorder(null); GridBagConstraints gbc_panel_2 = new GridBagConstraints(); gbc_panel_2.gridwidth = 2; gbc_panel_2.anchor = GridBagConstraints.NORTHWEST; gbc_panel_2.insets = new Insets(0, 0, 5, 0); gbc_panel_2.gridx = 0; gbc_panel_2.gridy = 0; jPanelDetail.add(panel_2, gbc_panel_2); panel_2.setLayout(new FlowLayout(FlowLayout.LEFT, 5, 5)); JLabel label = new JLabel("Name"); panel_2.add(label); textFieldName = new JTextField(); textFieldName.setColumns(20); panel_2.add(textFieldName); JPanel panel_3 = new JPanel(); FlowLayout flowLayout_1 = (FlowLayout) panel_3.getLayout(); flowLayout_1.setAlignment(FlowLayout.LEFT); panel_3.setBorder(null); GridBagConstraints gbc_panel_3 = new GridBagConstraints(); gbc_panel_3.insets = new Insets(0, 0, 5, 0); gbc_panel_3.gridwidth = 2; gbc_panel_3.anchor = GridBagConstraints.NORTHWEST; gbc_panel_3.gridx = 0; gbc_panel_3.gridy = 1; jPanelDetail.add(panel_3, gbc_panel_3); labelPattern = new JLabel("Pattern"); panel_3.add(labelPattern); textFieldPattern = new JTextField(); textFieldPattern.setColumns(40); panel_3.add(textFieldPattern); JButton btnSave = new JButton("Save"); btnSave.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DateFormat df1 = repository.getDateFormat( ((table.getSelectedRow() != -1) ? table.convertRowIndexToModel(table.getSelectedRow()) : -1)); df1.update(textFieldName.getText(), textFieldPattern.getText(), textField.getText()); reloadTable(); } }); JPanel panel_4 = new JPanel(); FlowLayout flowLayout_2 = (FlowLayout) panel_4.getLayout(); flowLayout_2.setAlignment(FlowLayout.LEFT); GridBagConstraints gbc_panel_4 = new GridBagConstraints(); gbc_panel_4.anchor = GridBagConstraints.WEST; gbc_panel_4.insets = new Insets(0, 0, 5, 5); gbc_panel_4.gridx = 0; gbc_panel_4.gridy = 2; jPanelDetail.add(panel_4, gbc_panel_4); JLabel lblFastDateFormat = new JLabel("FastDateFormat"); panel_4.add(lblFastDateFormat); textField = new JTextField(); panel_4.add(textField); textField.setColumns(30); JPanel panel_5 = new JPanel(); FlowLayout flowLayout_3 = (FlowLayout) panel_5.getLayout(); flowLayout_3.setAlignment(FlowLayout.LEFT); GridBagConstraints gbc_panel_5 = new GridBagConstraints(); gbc_panel_5.insets = new Insets(0, 0, 5, 5); gbc_panel_5.fill = GridBagConstraints.BOTH; gbc_panel_5.gridx = 0; gbc_panel_5.gridy = 3; jPanelDetail.add(panel_5, gbc_panel_5); JLabel lblSampleLabel = new JLabel("Sample"); panel_5.add(lblSampleLabel); JPanel panel_6 = new JPanel(); panel_6.setBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null)); GridBagConstraints gbc_panel_6 = new GridBagConstraints(); gbc_panel_6.ipady = 1; gbc_panel_6.ipadx = 1; gbc_panel_6.insets = new Insets(0, 0, 5, 5); gbc_panel_6.fill = GridBagConstraints.BOTH; gbc_panel_6.gridx = 0; gbc_panel_6.gridy = 4; jPanelDetail.add(panel_6, gbc_panel_6); panel_6.setLayout(new BorderLayout(0, 0)); JTextPane textPane = new JTextPane(); textPane.setBackground(UIManager.getColor("windowBorder")); panel_6.add(textPane); GridBagConstraints gbc_btnSave = new GridBagConstraints(); gbc_btnSave.anchor = GridBagConstraints.WEST; gbc_btnSave.insets = new Insets(0, 0, 0, 5); gbc_btnSave.gridx = 0; gbc_btnSave.gridy = 5; jPanelDetail.add(btnSave, gbc_btnSave); reloadTable(); }
From source file:org.eobjects.datacleaner.windows.OpenAnalysisJobAsTemplateDialog.java
@Override protected JComponent getDialogContent() { final DCPanel panel = new DCPanel(); int row = 0;//w w w . j av a 2 s . c om WidgetUtils.addToGridBag(DCLabel.bright("<html><b>Original value:</b></html>"), panel, 1, row); WidgetUtils.addToGridBag(DCLabel.bright("<html><b>New/mapped value:</b></html>"), panel, 2, row); row++; WidgetUtils.addToGridBag(new JLabel(imageManager.getImageIcon("images/model/datastore.png")), panel, 0, row); WidgetUtils.addToGridBag(DCLabel.bright(_metadata.getDatastoreName()), panel, 1, row, GridBagConstraints.WEST); DCPanel datastoreButtonPanel = new DCPanel(); datastoreButtonPanel.setLayout(new HorizontalLayout(0)); datastoreButtonPanel.add(_datastoreCombobox); datastoreButtonPanel.add(Box.createHorizontalStrut(4)); datastoreButtonPanel.add(_autoMapButton); WidgetUtils.addToGridBag(datastoreButtonPanel, panel, 2, row, GridBagConstraints.WEST); Set<String> tableNames = _sourceColumnComboBoxes.keySet(); for (final String tableName : tableNames) { row++; final JLabel tableLabel = DCLabel.bright("<html><b>" + tableName + "</b></html>"); tableLabel.setIcon(imageManager.getImageIcon("images/model/table.png", IconUtils.ICON_SIZE_SMALL)); WidgetUtils.addToGridBag(tableLabel, panel, 0, row, 2, 1, GridBagConstraints.WEST); final JButton clearButton = new JButton("Clear"); clearButton.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { List<SourceColumnComboBox> comboBoxes = _sourceColumnComboBoxes.get(tableName); for (SourceColumnComboBox comboBox : comboBoxes) { comboBox.setModel(_datastore, false); } } }); final DCPanel clearButtonPanel = new DCPanel(); clearButtonPanel.add(clearButton); WidgetUtils.addToGridBag(clearButtonPanel, panel, 2, row, GridBagConstraints.CENTER); final List<SourceColumnComboBox> comboBoxes = _sourceColumnComboBoxes.get(tableName); for (SourceColumnComboBox comboBox : comboBoxes) { row++; WidgetUtils.addToGridBag( new JLabel(imageManager.getImageIcon("images/model/column.png", IconUtils.ICON_SIZE_SMALL)), panel, 0, row); WidgetUtils.addToGridBag(DCLabel.bright(comboBox.getName()), panel, 1, row, GridBagConstraints.WEST); WidgetUtils.addToGridBag(comboBox, panel, 2, row, GridBagConstraints.WEST); } } row++; if (!_variableTextFields.isEmpty()) { final JLabel tableLabel = DCLabel.bright("<html><b>Job-level variables</b></html>"); tableLabel.setIcon( imageManager.getImageIcon("images/filetypes/analysis_job.png", IconUtils.ICON_SIZE_SMALL)); WidgetUtils.addToGridBag(tableLabel, panel, 0, row, 2, 1, GridBagConstraints.WEST); for (Entry<String, JXTextField> entry : _variableTextFields.entrySet()) { row++; String variableId = entry.getKey(); JXTextField textField = entry.getValue(); WidgetUtils.addToGridBag( new JLabel( imageManager.getImageIcon("images/model/variable.png", IconUtils.ICON_SIZE_SMALL)), panel, 0, row); WidgetUtils.addToGridBag(DCLabel.bright(variableId), panel, 1, row, GridBagConstraints.WEST); WidgetUtils.addToGridBag(textField, panel, 2, row, GridBagConstraints.WEST); } row++; } final DCPanel openButtonPanel = new DCPanel(); openButtonPanel.add(_openButton); WidgetUtils.addToGridBag(openButtonPanel, panel, 2, row, GridBagConstraints.EAST); return WidgetUtils.scrolleable(panel); }
From source file:com.att.aro.ui.view.videotab.VideoTab.java
/** * MidPanel contains Video Manifests/*w w w . ja va 2 s.c o m*/ */ private JPanel buildManifestsGroup() { JPanel pane; pane = new JPanel(new GridBagLayout()); int section = 0; videoManifestPanel = new VideoManifestPanel(overviewRoute, aroView); pane.add(videoManifestPanel, new GridBagConstraints(0, section++, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, noInsets, 0, 0)); bpObservable.registerObserver(videoManifestPanel); JPanel wrapper = getTitledWrapper("video.tab.manifest.title", new LoadManifestDialog(aroView)); wrapper.add(pane, new GridBagConstraints(0, 1, 1, 1, 1.0, 0.0, GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, noInsets, 0, 0)); pane.setBorder(BorderFactory.createLineBorder(Color.WHITE)); return wrapper; }