List of usage examples for java.awt Insets Insets
public Insets(int top, int left, int bottom, int right)
From source file:org.esa.snap.rcp.statistics.ChartPagePanel.java
private JPanel createChartBottomPanel(final ChartPanel chartPanel) { final AbstractButton zoomAllButton = ToolButtonFactory .createButton(UIUtils.loadImageIcon("icons/view-fullscreen.png"), false); zoomAllButton.setToolTipText("Zoom all."); zoomAllButton.setName("zoomAllButton."); zoomAllButton.addActionListener(e -> { chartPanel.restoreAutoBounds();/*from w w w.j a v a 2 s . co m*/ chartPanel.repaint(); }); final AbstractButton propertiesButton = ToolButtonFactory .createButton(UIUtils.loadImageIcon("icons/Edit24.gif"), false); propertiesButton.setToolTipText("Edit properties."); propertiesButton.setName("propertiesButton."); propertiesButton.addActionListener(e -> chartPanel.doEditChartProperties()); final AbstractButton saveButton = ToolButtonFactory .createButton(UIUtils.loadImageIcon("icons/Export24.gif"), false); saveButton.setToolTipText("Save chart as image."); saveButton.setName("saveButton."); saveButton.addActionListener(e -> { try { chartPanel.doSaveAs(); } catch (IOException e1) { JOptionPane.showMessageDialog(chartPanel, "Could not save chart:\n" + e1.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); } }); final AbstractButton printButton = ToolButtonFactory .createButton(UIUtils.loadImageIcon("icons/Print24.gif"), false); printButton.setToolTipText("Print chart."); printButton.setName("printButton."); printButton.addActionListener(e -> chartPanel.createChartPrintJob()); final TableLayout tableLayout = new TableLayout(6); tableLayout.setColumnFill(4, TableLayout.Fill.HORIZONTAL); tableLayout.setColumnWeightX(4, 1.0); JPanel buttonPanel = new JPanel(tableLayout); tableLayout.setRowPadding(0, new Insets(0, 4, 0, 0)); buttonPanel.add(zoomAllButton); tableLayout.setRowPadding(0, new Insets(0, 0, 0, 0)); buttonPanel.add(propertiesButton); buttonPanel.add(saveButton); buttonPanel.add(printButton); buttonPanel.add(new JPanel()); buttonPanel.add(getHelpButton()); return buttonPanel; }
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:com.sshtools.common.ui.SshToolsConnectionPanel.java
/** * * * @param parent/*from w w w. ja v a 2 s . c om*/ * @param profile * @param optionalTabs * * @return */ public static SshToolsConnectionProfile showConnectionDialog(Component parent, SshToolsConnectionProfile profile, SshToolsConnectionTab[] optionalTabs) { // If no properties are provided, then use the default if (profile == null) { int port = DEFAULT_PORT; String port_S = Integer.toString(DEFAULT_PORT); port_S = PreferencesStore.get(SshTerminalPanel.PREF_DEFAULT_SIMPLE_PORT, port_S); try { port = Integer.parseInt(port_S); } catch (NumberFormatException e) { log.warn("Could not parse the port number from defaults file (property name" + SshTerminalPanel.PREF_DEFAULT_SIMPLE_PORT + ", property value= " + port_S + ")."); } profile = new SshToolsConnectionProfile(); profile.setHost(PreferencesStore.get(SshToolsApplication.PREF_CONNECTION_LAST_HOST, "")); profile.setPort(PreferencesStore.getInt(SshToolsApplication.PREF_CONNECTION_LAST_PORT, port)); profile.setUsername(PreferencesStore.get(SshToolsApplication.PREF_CONNECTION_LAST_USER, "")); } final SshToolsConnectionPanel conx = new SshToolsConnectionPanel(true); if (optionalTabs != null) { for (int i = 0; i < optionalTabs.length; i++) { conx.addTab(optionalTabs[i]); } } conx.setConnectionProfile(profile); JDialog d = null; Window w = (Window) SwingUtilities.getAncestorOfClass(Window.class, parent); if (w instanceof JDialog) { d = new JDialog((JDialog) w, "Connection Profile", true); } else if (w instanceof JFrame) { d = new JDialog((JFrame) w, "Connection Profile", true); } else { d = new JDialog((JFrame) null, "Connection Profile", true); } final JDialog dialog = d; class UserAction { boolean connect; } final UserAction userAction = new UserAction(); // Create the bottom button panel final JButton cancel = new JButton("Cancel"); cancel.setMnemonic('c'); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { userAction.connect = false; dialog.setVisible(false); } }); final JButton connect = new JButton("Connect"); connect.setMnemonic('t'); connect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { if (conx.validateTabs()) { userAction.connect = true; dialog.setVisible(false); } } }); dialog.getRootPane().setDefaultButton(connect); JPanel buttonPanel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.anchor = GridBagConstraints.CENTER; gbc.insets = new Insets(6, 6, 0, 0); gbc.weighty = 1.0; UIUtil.jGridBagAdd(buttonPanel, connect, gbc, GridBagConstraints.RELATIVE); UIUtil.jGridBagAdd(buttonPanel, cancel, gbc, GridBagConstraints.REMAINDER); JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0)); southPanel.add(buttonPanel); // JPanel mainPanel = new JPanel(new BorderLayout()); mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4)); mainPanel.add(conx, BorderLayout.CENTER); mainPanel.add(southPanel, BorderLayout.SOUTH); // Show the dialog dialog.getContentPane().setLayout(new GridLayout(1, 1)); dialog.getContentPane().add(mainPanel); dialog.pack(); dialog.setResizable(false); UIUtil.positionComponent(SwingConstants.CENTER, dialog); //show the simple box and act on the answer. SshToolsSimpleConnectionPrompt stscp = SshToolsSimpleConnectionPrompt.getInstance(); StringBuffer sb = new StringBuffer(); userAction.connect = !stscp.getHostname(sb, profile.getHost()); boolean advanced = stscp.getAdvanced(); if (advanced) { userAction.connect = false; profile.setHost(sb.toString()); conx.hosttab.setConnectionProfile(profile); dialog.setVisible(true); } // Make sure we didn't cancel if (!userAction.connect) { return null; } conx.applyTabs(); if (!advanced) profile.setHost(sb.toString()); if (!advanced) { int port = DEFAULT_PORT; String port_S = Integer.toString(DEFAULT_PORT); port_S = PreferencesStore.get(SshTerminalPanel.PREF_DEFAULT_SIMPLE_PORT, port_S); try { port = Integer.parseInt(port_S); } catch (NumberFormatException e) { log.warn("Could not parse the port number from defaults file (property name" + SshTerminalPanel.PREF_DEFAULT_SIMPLE_PORT + ", property value= " + port_S + ")."); } profile.setPort(port); } if (!advanced) profile.setUsername(""); PreferencesStore.put(SshToolsApplication.PREF_CONNECTION_LAST_HOST, profile.getHost()); // only save user inputed configuration if (advanced) { PreferencesStore.put(SshToolsApplication.PREF_CONNECTION_LAST_USER, profile.getUsername()); PreferencesStore.putInt(SshToolsApplication.PREF_CONNECTION_LAST_PORT, profile.getPort()); } // Return the connection properties return profile; }
From source file:com.sec.ose.osi.ui.frm.main.report.JPanExportReport.java
private JPanel getJPanelForDocumentExportInfo() { if (jPanelForDocumentExportInfo == null) { GridBagConstraints gridBagConstraints5 = new GridBagConstraints(); gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints5.gridx = -1;/* w w w. jav a2 s . c o m*/ gridBagConstraints5.gridy = -1; gridBagConstraints5.gridwidth = 1; gridBagConstraints5.anchor = GridBagConstraints.CENTER; gridBagConstraints5.weightx = 1.0; gridBagConstraints5.weighty = 0.0; gridBagConstraints5.insets = new Insets(0, 0, 10, 5); // margin // top, left, bottom, right jPanelForDocumentExportInfo = new JPanel(); jPanelForDocumentExportInfo.setLayout(new GridBagLayout()); jPanelForDocumentExportInfo.setBorder(BorderFactory.createTitledBorder(null, "Report Export Location", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51))); jPanelForDocumentExportInfo.add(getJPanelDocumentExportInfo(), gridBagConstraints5); } return jPanelForDocumentExportInfo; }
From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectAdd.java
/** * This method initializes jPanelPjtList * //from w ww .j a v a 2 s . c o m * @return javax.swing.JPanel */ private JPanel getJPanelPjtList() { if (jPanelPjtList == null) { GridBagConstraints gridBagConstraints3 = new GridBagConstraints(); gridBagConstraints3.gridy = 1; gridBagConstraints3.fill = GridBagConstraints.BOTH; gridBagConstraints3.gridwidth = 2; gridBagConstraints3.weighty = 0.1; gridBagConstraints3.insets = new Insets(0, 10, 10, 10); gridBagConstraints3.ipadx = 0; gridBagConstraints3.weightx = 0.1; gridBagConstraints3.gridx = 0; GridBagConstraints gridBagConstraints2 = new GridBagConstraints(); gridBagConstraints2.insets = new Insets(10, 10, 10, 0); GridBagConstraints gridBagConstraints1 = new GridBagConstraints(); gridBagConstraints1.fill = GridBagConstraints.HORIZONTAL; gridBagConstraints1.gridy = 0; gridBagConstraints1.weightx = 0.1; gridBagConstraints1.insets = new Insets(10, 10, 10, 10); gridBagConstraints1.ipadx = 0; gridBagConstraints1.ipady = 0; gridBagConstraints1.gridx = 1; jLabelFilter = new JLabel(); jLabelFilter.setText("Filter :"); jPanelPjtList = new JPanel(); jPanelPjtList.setLayout(new GridBagLayout()); jPanelPjtList.setBorder(BorderFactory.createTitledBorder(null, "Project List", TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, new Font("Dialog", Font.BOLD, 12), new Color(51, 51, 51))); jPanelPjtList.add(jLabelFilter, gridBagConstraints2); jPanelPjtList.add(getJTextFieldFilter(), gridBagConstraints1); jPanelPjtList.add(getJScrollPanePjtList(), gridBagConstraints3); } return jPanelPjtList; }
From source file:de.codesourcery.flocking.ui.NumberInputField.java
/** * Create instance.//from www.j a v a 2 s .co m * * <p>Creates a resizable panel that holds a label, a textfield and a slider * for entering/adjusting a numeric value.</p> * * @param label the label to display * @param model the model that is used to read/write the value to be edited. If the model returns <code>null</code> values, * these will be treated as "0" (or "0.0" respectively). * @param minValue valid minimum value (inclusive) the user may enter * @param maxValue vali maximum value (inclusive) the user may enter * @param onlyIntValues whether the user may enter only integers or integers <b>and</b> floating-point numbers. */ public NumberInputField(String label, IModel<T> model, double minValue, double maxValue, final boolean onlyIntValues) { if (model == null) { throw new IllegalArgumentException("model must not be NULL."); } this.model = model; this.minValue = minValue; this.maxValue = maxValue; this.onlyIntValues = onlyIntValues; textField = new JTextField("0"); textField.setColumns(5); textField.setHorizontalAlignment(JTextField.RIGHT); slider = new JSlider(0, SLIDER_RESOLUTION); textField.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (selfTriggeredEvent) { return; } final String s = textField.getText(); if (!StringUtils.isBlank(s)) { Number number = null; try { if (onlyIntValues) { number = Long.parseLong(s.trim()); } else { number = Double.parseDouble(s.trim()); } } catch (Exception ex) { textField.setText(numberToString(NumberInputField.this.model.getObject())); return; } updateModelValue(number); } } }); textField.setText(numberToString(model.getObject())); slider.getModel().setValue(calcSliderValue(model.getObject())); slider.addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { if (selfTriggeredEvent) { return; } final double percentage = slider.getModel().getValue() / (double) SLIDER_RESOLUTION; // 0...1 final double range = Math.abs(NumberInputField.this.maxValue - NumberInputField.this.minValue); final double newValue = NumberInputField.this.minValue + range * percentage; updateModelValue(newValue); } }); slider.setMinimumSize(new Dimension(100, 20)); slider.setPreferredSize(new Dimension(100, 20)); // do layout setLayout(new GridBagLayout()); GridBagConstraints cnstrs = new GridBagConstraints(); cnstrs.fill = GridBagConstraints.NONE; cnstrs.weightx = 0; cnstrs.weighty = 0; cnstrs.gridx = 0; cnstrs.gridy = 0; final JLabel l = new JLabel(label); l.setMinimumSize(new Dimension(1500, 20)); l.setPreferredSize(new Dimension(150, 20)); l.setVerticalAlignment(SwingConstants.TOP); add(l, cnstrs); cnstrs = new GridBagConstraints(); cnstrs.fill = GridBagConstraints.NONE; cnstrs.weightx = 0; cnstrs.weighty = 0; cnstrs.gridx = 1; cnstrs.gridy = 0; cnstrs.insets = new Insets(0, 0, 0, 10); add(textField, cnstrs); cnstrs = new GridBagConstraints(); cnstrs.fill = GridBagConstraints.HORIZONTAL; cnstrs.weightx = 1.0; cnstrs.weighty = 1.0; cnstrs.gridx = 2; cnstrs.gridy = 0; add(slider, cnstrs); }
From source file:FontChooser.java
private void createUserInterface() { final JPanel content = new JPanel(new GridBagLayout()); final GridBagConstraints gbc = new GridBagConstraints(); setContentPane(content);//from www .j av a 2s . c o m content.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); gbc.anchor = GridBagConstraints.WEST; gbc.insets = new Insets(2, 2, 2, 2); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridx = gbc.gridy = 0; content.add(new JLabel("Font"), gbc); ++gbc.gridx; content.add(new JLabel("Size"), gbc); if (_selectStyles) { ++gbc.gridx; content.add(new JLabel("Style"), gbc); } ++gbc.gridy; gbc.gridx = 0; _fontNamesCmb = new JComboBox( GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()); content.add(_fontNamesCmb, gbc); ++gbc.gridx; _fontSizesCmb.setEditable(true); content.add(_fontSizesCmb, gbc); if (_selectStyles) { ++gbc.gridx; content.add(_boldChk, gbc); ++gbc.gridy; content.add(_italicChk, gbc); } gbc.gridx = 0; ++gbc.gridy; gbc.gridwidth = GridBagConstraints.REMAINDER; gbc.fill = GridBagConstraints.BOTH; gbc.anchor = GridBagConstraints.CENTER; content.add(createPreviewPanel(), gbc); ++gbc.gridy; gbc.fill = GridBagConstraints.HORIZONTAL; content.add(createButtonsPanel(), gbc); pack(); setResizable(true); }
From source file:org.eevolution.form.VCRP.java
private void jbInit() throws Exception { northPanel.setLayout(new java.awt.GridBagLayout()); resourceLabel.setText(Msg.translate(Env.getCtx(), "S_Resource_ID")); northPanel.add(resourceLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); northPanel.add(resource, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); dateFromLabel.setText(Msg.translate(Env.getCtx(), "DateFrom")); northPanel.add(dateFromLabel, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0)); northPanel.add(dateFrom, new GridBagConstraints(3, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0)); chartPanel.setPreferredSize(new Dimension(750, 550)); centerPanel.add(chartPanel, BorderLayout.CENTER); confirmPanel.addActionListener(this); }
From source file:au.org.ala.delta.intkey.ui.FindInCharactersDialog.java
public FindInCharactersDialog(Intkey intkeyApp, IntkeyContext context) { super(intkeyApp.getMainFrame(), false); setResizable(false);/*from w w w . j a v a 2 s. co m*/ ResourceMap resourceMap = Application.getInstance().getContext() .getResourceMap(FindInCharactersDialog.class); resourceMap.injectFields(this); ActionMap actionMap = Application.getInstance().getContext().getActionMap(this); _intkeyApp = intkeyApp; _numMatchedCharacters = 0; _currentMatchedCharacter = -1; _findAction = actionMap.get("findCharacters"); _nextAction = actionMap.get("nextCharacter"); this.setTitle(windowTitle); _pnlMain = new JPanel(); _pnlMain.setBorder(new EmptyBorder(20, 20, 20, 20)); getContentPane().add(_pnlMain, BorderLayout.CENTER); _pnlMain.setLayout(new BorderLayout(0, 0)); _pnlMainTop = new JPanel(); _pnlMain.add(_pnlMainTop, BorderLayout.NORTH); _pnlMainTop.setLayout(new BoxLayout(_pnlMainTop, BoxLayout.Y_AXIS)); _lblEnterSearchString = new JLabel(enterSearchStringCaption); _lblEnterSearchString.setBorder(new EmptyBorder(0, 0, 5, 0)); _pnlMainTop.add(_lblEnterSearchString); _textField = new JTextField(); _pnlMainTop.add(_textField); _textField.setColumns(10); _textField.getDocument().addDocumentListener(new DocumentListener() { @Override public void removeUpdate(DocumentEvent e) { reset(); } @Override public void insertUpdate(DocumentEvent e) { reset(); } @Override public void changedUpdate(DocumentEvent e) { reset(); } }); _pnlMainBottom = new JPanel(); _pnlMainBottom.setBorder(new EmptyBorder(20, 0, 0, 0)); _pnlMain.add(_pnlMainBottom, BorderLayout.CENTER); _pnlMainBottom.setLayout(new BoxLayout(_pnlMainBottom, BoxLayout.Y_AXIS)); _chckbxSearchStates = new JCheckBox(searchStatesCaption); _chckbxSearchStates.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainBottom.add(_chckbxSearchStates); _chckbxSearchUsedCharacters = new JCheckBox(searchUsedCharactersCaption); _chckbxSearchUsedCharacters.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { reset(); } }); _pnlMainBottom.add(_chckbxSearchUsedCharacters); _pnlButtons = new JPanel(); _pnlButtons.setBorder(new EmptyBorder(20, 0, 0, 10)); getContentPane().add(_pnlButtons, BorderLayout.EAST); _pnlButtons.setLayout(new BorderLayout(0, 0)); _pnlInnerButtons = new JPanel(); _pnlButtons.add(_pnlInnerButtons, BorderLayout.NORTH); GridBagLayout gbl__pnlInnerButtons = new GridBagLayout(); gbl__pnlInnerButtons.columnWidths = new int[] { 0, 0 }; gbl__pnlInnerButtons.rowHeights = new int[] { 0, 0, 0, 0 }; gbl__pnlInnerButtons.columnWeights = new double[] { 0.0, Double.MIN_VALUE }; gbl__pnlInnerButtons.rowWeights = new double[] { 0.0, 0.0, 0.0, Double.MIN_VALUE }; _pnlInnerButtons.setLayout(gbl__pnlInnerButtons); _btnFindNext = new JButton(); _btnFindNext.setAction(_findAction); GridBagConstraints gbc__btnFindNext = new GridBagConstraints(); gbc__btnFindNext.fill = GridBagConstraints.HORIZONTAL; gbc__btnFindNext.insets = new Insets(0, 0, 5, 0); gbc__btnFindNext.gridx = 0; gbc__btnFindNext.gridy = 0; _pnlInnerButtons.add(_btnFindNext, gbc__btnFindNext); _btnPrevious = new JButton(); _btnPrevious.setAction(actionMap.get("previousCharacter")); _btnPrevious.setEnabled(false); GridBagConstraints gbc__btnPrevious = new GridBagConstraints(); gbc__btnPrevious.insets = new Insets(0, 0, 5, 0); gbc__btnPrevious.gridx = 0; gbc__btnPrevious.gridy = 1; _pnlInnerButtons.add(_btnPrevious, gbc__btnPrevious); _btnDone = new JButton(); _btnDone.setAction(actionMap.get("findCharactersDone")); GridBagConstraints gbc__btnDone = new GridBagConstraints(); gbc__btnDone.fill = GridBagConstraints.HORIZONTAL; gbc__btnDone.gridx = 0; gbc__btnDone.gridy = 2; _pnlInnerButtons.add(_btnDone, gbc__btnDone); this.pack(); this.setLocationRelativeTo(_intkeyApp.getMainFrame()); }
From source file:com.digitalgeneralists.assurance.ui.components.ComparisonResultPanel.java
protected void initializeComponent(ComparisonResult result) { if (!this.initialized) { this.merging = false; this.numberOfLines = 0; this.setOpaque(true); GridBagLayout gridbag = new GridBagLayout(); this.setLayout(gridbag); this.basePanelConstraints.anchor = GridBagConstraints.WEST; this.basePanelConstraints.fill = GridBagConstraints.BOTH; this.basePanelConstraints.gridx = 0; this.basePanelConstraints.gridy = 0; this.basePanelConstraints.weightx = 1.0; this.basePanelConstraints.weighty = 1.0; this.basePanelConstraints.gridheight = 1; this.basePanelConstraints.gridwidth = 1; this.basePanelConstraints.insets = new Insets(0, 0, 0, 0); this.standardPanel.setOpaque(false); GridBagLayout basePanelGridbag = new GridBagLayout(); this.standardPanel.setLayout(basePanelGridbag); this.add(this.standardPanel, this.basePanelConstraints); GridBagConstraints sourcePanelConstraints = new GridBagConstraints(); sourcePanelConstraints.anchor = GridBagConstraints.WEST; sourcePanelConstraints.fill = GridBagConstraints.BOTH; sourcePanelConstraints.gridx = 0; sourcePanelConstraints.gridy = 0; sourcePanelConstraints.weightx = 0.4; sourcePanelConstraints.weighty = 1.0; sourcePanelConstraints.gridheight = 1; sourcePanelConstraints.gridwidth = 1; sourcePanelConstraints.insets = new Insets(0, 0, 0, 0); JPanel sourcePanel = new JPanel(); sourcePanel.setOpaque(false);/*from ww w. j av a 2 s . co m*/ GridBagLayout sourcePanelGridbag = new GridBagLayout(); sourcePanel.setLayout(sourcePanelGridbag); this.standardPanel.add(sourcePanel, sourcePanelConstraints); GridBagConstraints sourceFileLabelConstraints = new GridBagConstraints(); sourceFileLabelConstraints.anchor = GridBagConstraints.WEST; sourceFileLabelConstraints.gridx = 0; sourceFileLabelConstraints.gridy = 0; sourceFileLabelConstraints.weightx = 1.0; sourceFileLabelConstraints.weighty = 1.0; sourceFileLabelConstraints.gridheight = 1; sourceFileLabelConstraints.gridwidth = 1; sourceFileLabelConstraints.insets = new Insets(5, 5, 5, 5); String sourcePath = "No File Specified"; if ((result != null) && (result.getSource() != null)) { File sourceFile = result.getSource().getFile(); if ((sourceFile == null) || (!sourceFile.exists())) { sourcePath = "File does not exist in source location."; } else { sourcePath = sourceFile.getPath(); } sourceFile = null; } JLabel sourceFileLabel = new JLabel(sourcePath); sourcePath = null; sourcePanel.add(sourceFileLabel, sourceFileLabelConstraints); GridBagConstraints sourceAttributesPanelConstraints = new GridBagConstraints(); sourceAttributesPanelConstraints.anchor = GridBagConstraints.WEST; sourceAttributesPanelConstraints.fill = GridBagConstraints.BOTH; sourceAttributesPanelConstraints.gridx = 0; sourceAttributesPanelConstraints.gridy = 1; sourceAttributesPanelConstraints.weightx = 1.0; sourceAttributesPanelConstraints.weighty = 1.0; sourceAttributesPanelConstraints.gridheight = 1; sourceAttributesPanelConstraints.gridwidth = 1; sourceAttributesPanelConstraints.insets = new Insets(0, 0, 0, 0); FileReference sourceReference = null; if (result != null) { sourceReference = result.getSource(); } FileReference targetReference = null; if (result != null) { targetReference = result.getTarget(); } JPanel sourceAttributesPanel = this.createFileAttributesPanel(sourceReference, targetReference, GridBagConstraints.WEST); sourcePanel.add(sourceAttributesPanel, sourceAttributesPanelConstraints); this.moreSourceAttributesButton.setHorizontalAlignment(SwingConstants.LEFT); this.moreSourceAttributesButton.setBorderPainted(false); this.moreSourceAttributesButton.setOpaque(false); this.moreSourceAttributesButton.setForeground(Color.blue); if (this.editable) { this.moreSourceAttributesButton.setText("All attributes..."); this.moreSourceAttributesButton.addActionListener(this); this.moreSourceAttributesButton.setEnabled(true); } else { this.moreSourceAttributesButton.setText(" "); this.moreSourceAttributesButton.setEnabled(false); } this.moreSourceAttributesButton.setActionCommand(AssuranceActions.sourceAttributesAction); GridBagConstraints moreSourceAttributesButtonConstraints = new GridBagConstraints(); moreSourceAttributesButtonConstraints.anchor = GridBagConstraints.WEST; moreSourceAttributesButtonConstraints.fill = GridBagConstraints.BOTH; moreSourceAttributesButtonConstraints.gridx = 0; moreSourceAttributesButtonConstraints.gridy = 2; moreSourceAttributesButtonConstraints.weightx = 1.0; moreSourceAttributesButtonConstraints.weighty = 1.0; moreSourceAttributesButtonConstraints.gridheight = 1; moreSourceAttributesButtonConstraints.gridwidth = 1; moreSourceAttributesButtonConstraints.insets = new Insets(0, 0, 0, 0); sourcePanel.add(this.moreSourceAttributesButton, moreSourceAttributesButtonConstraints); this.buildMergePanel(result); GridBagConstraints targetPanelConstraints = new GridBagConstraints(); targetPanelConstraints.anchor = GridBagConstraints.EAST; targetPanelConstraints.fill = GridBagConstraints.BOTH; targetPanelConstraints.gridx = 2; targetPanelConstraints.gridy = 0; targetPanelConstraints.weightx = 0.4; targetPanelConstraints.weighty = 1.0; targetPanelConstraints.gridheight = 1; targetPanelConstraints.gridwidth = 1; targetPanelConstraints.insets = new Insets(0, 0, 0, 0); JPanel targetPanel = new JPanel(); GridBagLayout targetPanelGridbag = new GridBagLayout(); targetPanel.setOpaque(false); targetPanel.setLayout(targetPanelGridbag); this.standardPanel.add(targetPanel, targetPanelConstraints); GridBagConstraints targetFileLabelConstraints = new GridBagConstraints(); targetFileLabelConstraints.anchor = GridBagConstraints.EAST; targetFileLabelConstraints.fill = GridBagConstraints.BOTH; targetFileLabelConstraints.gridx = 0; targetFileLabelConstraints.gridy = 0; targetFileLabelConstraints.weightx = 1.0; targetFileLabelConstraints.weighty = 1.0; targetFileLabelConstraints.gridheight = 1; targetFileLabelConstraints.gridwidth = 1; targetFileLabelConstraints.insets = new Insets(5, 5, 5, 5); // Create a label to put messages during an action event. String targetPath = "No File Specified"; if ((result != null) && (result.getTarget() != null)) { File targetFile = result.getTarget().getFile(); if ((targetFile == null) || (!targetFile.exists())) { targetPath = "File does not exist in target location."; } else { targetPath = targetFile.getPath(); } targetFile = null; } JLabel targetFileLabel = new JLabel(targetPath); targetPath = null; targetPanel.add(targetFileLabel, targetFileLabelConstraints); GridBagConstraints targetAttributesPanelConstraints = new GridBagConstraints(); targetAttributesPanelConstraints.anchor = GridBagConstraints.EAST; targetAttributesPanelConstraints.fill = GridBagConstraints.BOTH; targetAttributesPanelConstraints.gridx = 0; targetAttributesPanelConstraints.gridy = 1; targetAttributesPanelConstraints.weightx = 1.0; targetAttributesPanelConstraints.weighty = 1.0; targetAttributesPanelConstraints.gridheight = 1; targetAttributesPanelConstraints.gridwidth = 1; targetAttributesPanelConstraints.insets = new Insets(0, 0, 0, 0); JPanel targetAttributesPanel = this.createFileAttributesPanel(targetReference, sourceReference, GridBagConstraints.EAST); targetPanel.add(targetAttributesPanel, targetAttributesPanelConstraints); sourceReference = null; targetReference = null; this.moreTargetAttributesButton.setHorizontalAlignment(SwingConstants.RIGHT); this.moreTargetAttributesButton.setBorderPainted(false); this.moreTargetAttributesButton.setOpaque(false); this.moreTargetAttributesButton.setForeground(Color.blue); if (this.editable) { this.moreTargetAttributesButton.setText("All attributes..."); this.moreTargetAttributesButton.addActionListener(this); this.moreTargetAttributesButton.setEnabled(true); } else { this.moreTargetAttributesButton.setText(" "); this.moreTargetAttributesButton.setEnabled(false); } this.moreTargetAttributesButton.setActionCommand(AssuranceActions.targetAttributesAction); GridBagConstraints moreTargetAttributesButtonConstraints = new GridBagConstraints(); moreTargetAttributesButtonConstraints.anchor = GridBagConstraints.EAST; moreTargetAttributesButtonConstraints.fill = GridBagConstraints.BOTH; moreTargetAttributesButtonConstraints.gridx = 0; moreTargetAttributesButtonConstraints.gridy = 2; moreTargetAttributesButtonConstraints.weightx = 1.0; moreTargetAttributesButtonConstraints.weighty = 1.0; moreTargetAttributesButtonConstraints.gridheight = 1; moreTargetAttributesButtonConstraints.gridwidth = 1; moreTargetAttributesButtonConstraints.insets = new Insets(0, 0, 0, 0); targetPanel.add(this.moreTargetAttributesButton, moreTargetAttributesButtonConstraints); GridBagLayout mergingPanelGridbag = new GridBagLayout(); this.mergingPanel.setLayout(mergingPanelGridbag); GridBagConstraints mergingLabelConstraints = new GridBagConstraints(); mergingLabelConstraints.anchor = GridBagConstraints.NORTH; mergingLabelConstraints.fill = GridBagConstraints.BOTH; mergingLabelConstraints.gridx = 0; mergingLabelConstraints.gridy = 0; mergingLabelConstraints.weightx = 1.0; mergingLabelConstraints.weighty = 1.0; mergingLabelConstraints.gridheight = 1; mergingLabelConstraints.gridwidth = 1; mergingLabelConstraints.insets = new Insets(10, 10, 10, 10); this.mergingLabel.setHorizontalAlignment(JLabel.CENTER); mergingPanel.add(this.mergingLabel, mergingLabelConstraints); GridBagConstraints mergingStatusIndicatorConstraints = new GridBagConstraints(); mergingStatusIndicatorConstraints.anchor = GridBagConstraints.SOUTH; mergingStatusIndicatorConstraints.fill = GridBagConstraints.BOTH; mergingStatusIndicatorConstraints.gridx = 0; mergingStatusIndicatorConstraints.gridy = 1; mergingStatusIndicatorConstraints.weightx = 1.0; mergingStatusIndicatorConstraints.weighty = 1.0; mergingStatusIndicatorConstraints.gridheight = 1; mergingStatusIndicatorConstraints.gridwidth = 1; mergingStatusIndicatorConstraints.insets = new Insets(10, 10, 10, 10); this.mergingProgressIndicator.setIndeterminate(true); mergingPanel.add(this.mergingProgressIndicator, mergingStatusIndicatorConstraints); this.addAncestorListener(new AncestorListener() { public void ancestorAdded(AncestorEvent event) { if (applicationDelegate != null) { applicationDelegate.addEventObserver(ResultMergeStartedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(ResultMergeProgressEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(ResultMergeCompletedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(DeletedItemRestoreStartedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(DeletedItemRestoreProgressEvent.class, (IEventObserver) event.getSource()); applicationDelegate.addEventObserver(DeletedItemRestoreCompletedEvent.class, (IEventObserver) event.getSource()); } } public void ancestorRemoved(AncestorEvent event) { if (applicationDelegate != null) { applicationDelegate.removeEventObserver(ResultMergeStartedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(ResultMergeProgressEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(ResultMergeCompletedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(DeletedItemRestoreStartedEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(DeletedItemRestoreProgressEvent.class, (IEventObserver) event.getSource()); applicationDelegate.removeEventObserver(DeletedItemRestoreCompletedEvent.class, (IEventObserver) event.getSource()); } } public void ancestorMoved(AncestorEvent event) { } }); this.initialized = true; } }