/** * This function is used to re-run the analyser, and re-create the rows corresponding the its * results. */ private void refreshReviewTable() { reviewPanel.removeAll(); rows.clear(); GridBagLayout gbl = new GridBagLayout(); reviewPanel.setLayout(gbl); GridBagConstraints gbc = new GridBagConstraints(); gbc.fill = GridBagConstraints.HORIZONTAL; gbc.gridy = 0; try { Map<String, Long> sums = analyser.processLogFile(config.getLogFilename(), fromDate.getDate(), toDate.getDate()); for (Entry<String, Long> entry : sums.entrySet()) { String project = entry.getKey(); double hours = 1.0 * entry.getValue() / (1000 * 3600); addRow(gbl, gbc, project, hours); } for (String project : main.getProjectsTree().getTopLevelProjects()) if (!rows.containsKey(project)) addRow(gbl, gbc, project, 0); gbc.insets = new Insets(10, 0, 0, 0); addLeftLabel(gbl, gbc, "TOTAL"); gbc.gridx = 1; gbc.weightx = 1; totalLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 3)); gbl.setConstraints(totalLabel, gbc); reviewPanel.add(totalLabel); gbc.weightx = 0; addRightLabel(gbl, gbc); } catch (IOException e) { e.printStackTrace(); } recomputeTotal(); pack(); }
/** Initializes contained components. */ private void initComponents() { final SimpleDateFormat format = new SimpleDateFormat("mm:ss"); final Calendar c = Calendar.getInstance(); final JLabel counter = new JLabel(); counter.setForeground(Color.red); counter.setFont(counter.getFont().deriveFont((float) (counter.getFont().getSize() + 5))); setLayout(new GridBagLayout()); setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); GridBagConstraints constraints = new GridBagConstraints(); JLabel messageLabel = new JLabel( GuiActivator.getResources().getI18NString("service.gui.security.SECURITY_ALERT")); messageLabel.setForeground(Color.WHITE); constraints.anchor = GridBagConstraints.CENTER; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.gridy = 0; add(messageLabel, constraints); constraints.anchor = GridBagConstraints.CENTER; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 0; constraints.gridy = 1; add(counter, constraints); ZrtpControl zrtpControl = null; if (securityControl instanceof ZrtpControl) zrtpControl = (ZrtpControl) securityControl; long initialSeconds = 0; if (zrtpControl != null) initialSeconds = zrtpControl.getTimeoutValue(); c.setTimeInMillis(initialSeconds); counter.setText(format.format(c.getTime())); if (initialSeconds > 0) timer.schedule( new TimerTask() { @Override public void run() { if (c.getTimeInMillis() - 1000 > 0) { c.add(Calendar.SECOND, -1); counter.setText(format.format(c.getTime())); } } }, 1000, 1000); }
/** * Adds a popup menu. * * @param label the label * @param items the menu items * @param defaultItem the menu item initially selected */ public void addChoice(String label, String[] items, String defaultItem) { String label2 = label; if (label2.indexOf('_') != -1) label2 = label2.replace('_', ' '); Label theLabel = makeLabel(label2); c.gridx = 0; c.gridy = y; c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; if (choice == null) { choice = new Vector(4); defaultChoiceIndexes = new Vector(4); c.insets = getInsets(5, 0, 5, 0); } else c.insets = getInsets(0, 0, 5, 0); grid.setConstraints(theLabel, c); add(theLabel); Choice thisChoice = new Choice(); thisChoice.addKeyListener(this); thisChoice.addItemListener(this); for (int i = 0; i < items.length; i++) thisChoice.addItem(items[i]); if (defaultItem != null) thisChoice.select(defaultItem); else thisChoice.select(0); c.gridx = 1; c.gridy = y; c.anchor = GridBagConstraints.WEST; grid.setConstraints(thisChoice, c); add(thisChoice); choice.addElement(thisChoice); int index = thisChoice.getSelectedIndex(); defaultChoiceIndexes.addElement(new Integer(index)); if (Recorder.record || macro) saveLabel(thisChoice, label); y++; }
/** * Adds contact entry labels. * * @param nameLabelGridWidth the grid width of the contact entry name label */ private void addLabels(int nameLabelGridWidth) { remove(nameLabel); remove(rightLabel); remove(displayDetailsLabel); if (treeNode != null && !(treeNode instanceof GroupNode)) constraints.insets = new Insets(0, 0, V_GAP, H_GAP); else constraints.insets = new Insets(0, 0, 0, H_GAP); constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 0; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridheight = 1; constraints.gridwidth = nameLabelGridWidth; this.add(nameLabel, constraints); constraints.anchor = GridBagConstraints.NORTHEAST; constraints.fill = GridBagConstraints.VERTICAL; constraints.gridx = nameLabelGridWidth + 1; constraints.gridy = 0; constraints.gridheight = 3; constraints.weightx = 0f; constraints.weighty = 1f; this.add(rightLabel, constraints); if (treeNode != null && treeNode instanceof ContactNode) { constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridwidth = nameLabelGridWidth; constraints.gridheight = 1; this.add(displayDetailsLabel, constraints); } else if (treeNode != null && treeNode instanceof GroupNode) { constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridwidth = nameLabelGridWidth; constraints.gridheight = 1; this.add(displayDetailsLabel, constraints); } }
/** * Adds a numeric field. The first word of the label must be unique or command recording will not * work. * * @param label the label * @param defaultValue value to be initially displayed * @param digits number of digits to right of decimal point * @param columns width of field in characters * @param units a string displayed to the right of the field */ public void addNumericField( String label, double defaultValue, int digits, int columns, String units) { String label2 = label; if (label2.indexOf('_') != -1) label2 = label2.replace('_', ' '); Label theLabel = makeLabel(label2); c.gridx = 0; c.gridy = y; c.anchor = GridBagConstraints.EAST; c.gridwidth = 1; if (firstNumericField) c.insets = getInsets(5, 0, 3, 0); else c.insets = getInsets(0, 0, 3, 0); grid.setConstraints(theLabel, c); add(theLabel); if (numberField == null) { numberField = new Vector(5); defaultValues = new Vector(5); defaultText = new Vector(5); } if (IJ.isWindows()) columns -= 2; if (columns < 1) columns = 1; String defaultString = IJ.d2s(defaultValue, digits); if (Double.isNaN(defaultValue)) defaultString = ""; TextField tf = new TextField(defaultString, columns); if (IJ.isLinux()) tf.setBackground(Color.white); tf.addActionListener(this); tf.addTextListener(this); tf.addFocusListener(this); tf.addKeyListener(this); numberField.addElement(tf); defaultValues.addElement(new Double(defaultValue)); defaultText.addElement(tf.getText()); c.gridx = 1; c.gridy = y; c.anchor = GridBagConstraints.WEST; tf.setEditable(true); // if (firstNumericField) tf.selectAll(); firstNumericField = false; if (units == null || units.equals("")) { grid.setConstraints(tf, c); add(tf); } else { Panel panel = new Panel(); panel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); panel.add(tf); panel.add(new Label(" " + units)); grid.setConstraints(panel, c); add(panel); } if (Recorder.record || macro) saveLabel(tf, label); y++; }
protected void layoutUIComponents(String strPath, boolean bDefaultFile) { JLabel label = null; // i18n // label = new JLabel( "File names can be constructed from a template. The LABEL field is " ); label = new JLabel( Util.getAdmLabel( "_admin_File_names_can_be_constructed_from_a_template._The_LABEL_field_is_")); label.setForeground(Color.black); // m_gbc.weightx = 0.5; showInstruction(m_gbl, m_gbc, 0, 0, 7, label); // i18n // label = new JLabel( "presented as the choice to the user in the \"Data save\" pop-up." ); label = new JLabel( Util.getAdmLabel( "_admin_presented_as_the_choice_to_the_user_in_the_Data_save_pop-up.")); showInstruction(m_gbl, m_gbc, 0, 1, 7, label); showInstruction(m_gbl, m_gbc, 0, 2, 1, new JLabel("")); label = new JLabel(Util.getAdmLabel("_adm_LABEL")); label.setForeground(Color.black); m_gbc.gridx = 1; m_gbc.gridy = 2; m_gbc.ipadx = 10; m_gbl.setConstraints(label, m_gbc); m_pnlDisplay.add(label); label = new JLabel(" "); m_gbc.gridx = 2; m_gbc.gridy = 2; m_gbc.ipadx = 0; // reset to default m_gbc.gridwidth = 5; m_gbl.setConstraints(label, m_gbc); // add( label ); showInstruction(m_gbl, m_gbc, 2, 2, 1, new JLabel(Util.getAdmLabel("_admin_TEMPLATE"))); m_nRow = 3; m_bDefaultFile = bDefaultFile; m_objTxfValue.clearArrays(); displayNewTxf(strPath); m_pnlDisplay.setBorder( new CompoundBorder( BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
// Initializing this component. private void jbInit() { callStackTable.addFocusListener( new FocusListener() { public void focusGained(FocusEvent e) { callStackTable_focusGained(e); } public void focusLost(FocusEvent e) { callStackTable_focusLost(e); } }); callStackTable.setTableHeader(null); callStackTable.setDefaultRenderer(callStackTable.getColumnClass(0), getCellRenderer()); scrollPane = new JScrollPane(callStackTable); setVisibleRows(DEFAULT_VISIBLE_ROWS); scrollPane.setLocation(0, 27); setBorder(BorderFactory.createEtchedBorder()); // this.setLayout(null); this.setLayout(new GridBagLayout()); nameLbl.setText("Call Stack"); nameLbl.setBounds(new Rectangle(3, 4, 70, 23)); nameLbl.setFont(Utilities.labelsFont); GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.ipadx = 0; c.ipady = 0; c.weightx = 1; c.weighty = 1; c.gridwidth = 7; c.gridheight = 1; c.anchor = GridBagConstraints.PAGE_END; c.gridx = 0; c.gridy = 2; this.add(scrollPane, c); c.fill = GridBagConstraints.HORIZONTAL; c.ipadx = 0; c.ipady = 0; c.weightx = 1; c.weighty = 0.0; c.gridwidth = 3; c.gridheight = 1; c.anchor = GridBagConstraints.FIRST_LINE_START; c.gridx = 0; c.gridy = 0; c.insets = new Insets(5, 0, 0, 0); this.add(nameLbl, c); }
private int addButton(SIPCommButton button, int gridX, int xBounds, boolean isLast) { lastAddedButton = button; constraints.insets = new Insets(0, 0, V_GAP, 0); constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = gridX; constraints.gridy = 2; constraints.gridwidth = 1; constraints.gridheight = 1; constraints.weightx = 0f; constraints.weighty = 0f; this.add(button, constraints); int yBounds = TOP_BORDER + BOTTOM_BORDER + 2 * V_GAP + ComponentUtils.getStringSize(nameLabel, nameLabel.getText()).height + ComponentUtils.getStringSize(displayDetailsLabel, displayDetailsLabel.getText()) .height; button.setBounds(xBounds, yBounds, BUTTON_WIDTH, BUTTON_HEIGHT); button.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); setButtonBg(button, gridX, isLast); return button.getWidth(); }
private void add(Component c, GridBagConstraints gbc, int x, int y, int w, int h) { gbc.gridx = x; gbc.gridy = y; gbc.gridwidth = w; gbc.gridheight = h; getContentPane().add(c, gbc); }
private void showSpaces(GridBagLayout gbl, GridBagConstraints gbc, int gridx, int gridy) { JLabel spaces = new JLabel(" "); gbc.gridx = gridx; gbc.gridy = gridy; gbl.setConstraints(spaces, gbc); m_pnlDisplay.add(spaces); }
/** Get the panel for a given form. * */ public JPanel getPanelFor(ArrayList elements) { JPanel p = new JPanel(new GridBagLayout()); int maxCols = 1; int elementSize = elements.size(); for (int i = 0; i < elementSize; i++) { // count max number of cols // ((XmlUIElement)elements.get(i)).setEditable(true);//by jai int cols = ((XmlUIElement) elements.get(i)).getNumberOfColumns(); if (cols > maxCols) { maxCols = cols; } } GridBagConstraints c = new GridBagConstraints(); c.fill = GridBagConstraints.BOTH; c.weightx = 1.0; c.gridx = 0; c.gridy = 0; if (elementSize < 5) c.insets = new Insets(8, 8, 8, 14); else if (elementSize < 20) c.insets = new Insets(4, 4, 4, 10); else if ((elementSize > 40 && maxCols == 2) || (elementSize > 80 && maxCols == 4)) c.insets = new Insets(1, 1, 1, 8); else c.insets = new Insets(2, 2, 2, 8); int rowsAdded = 0; for (int i = 0; i < elementSize; i++) { elementsAndPanels.put(elements.get(i), p); rowsAdded += ((XmlUIElement) elements.get(i)).addComponents(p, c, 0, rowsAdded, maxCols); } return p; }
private void addView() { GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = 1; gbc.gridx = 6; gbc.gridy = 0; add((JComponent) _secondaryView, gbc); }
public static void addToGridBag( GridBagLayout grid, Container cont, Component comp, int x, int y, int gw, int gh, double wx, double wy, int fill, int anchor) { // now the constraints GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = x; gbc.gridy = y; gbc.weightx = wx; gbc.weighty = wy; gbc.fill = fill; gbc.gridwidth = gw; gbc.gridheight = gh; gbc.anchor = anchor; cont.add(comp); grid.setConstraints(comp, gbc); }
protected void addComp(JPanel panel, Component comp, GridBagConstraints gbc, int x, int y) { gbc.gridx = x; gbc.gridy = y; gbc.fill = GridBagConstraints.HORIZONTAL; panel.add(comp, gbc); }
/** * Adds a label that shows the percentage of hours spent on a particular project. * * @param gbl The layout to add the label to. * @param gbc The layout constraints to use. * @param row The row to link against. * @see {@link #addRow(GridBagLayout, GridBagConstraints, String, double)} */ private void addPercentLabel(GridBagLayout gbl, GridBagConstraints gbc, Row row) { gbc.gridx = 3; gbc.ipadx = 5; gbl.setConstraints(row.percentL, gbc); gbc.ipadx = 0; reviewPanel.add(row.percentL); }
/** * Adds a radio button group. * * @param label group label (or null) * @param items radio button labels * @param rows number of rows * @param columns number of columns * @param defaultItem button initially selected */ public void addRadioButtonGroup( String label, String[] items, int rows, int columns, String defaultItem) { Panel panel = new Panel(); int n = items.length; panel.setLayout(new GridLayout(rows, columns, 0, 0)); CheckboxGroup cg = new CheckboxGroup(); for (int i = 0; i < n; i++) { Checkbox cb = new Checkbox(items[i], cg, items[i].equals(defaultItem)); cb.addItemListener(this); panel.add(cb); } if (radioButtonGroups == null) radioButtonGroups = new Vector(); radioButtonGroups.addElement(cg); Insets insets = getInsets(5, 10, 0, 0); if (label == null || label.equals("")) { label = "rbg" + radioButtonGroups.size(); insets.top += 5; } else { setInsets(10, insets.left, 0); addMessage(label); insets.top = 2; insets.left += 10; } c.gridx = 0; c.gridy = y; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; c.insets = new Insets(insets.top, insets.left, 0, 0); grid.setConstraints(panel, c); add(panel); if (Recorder.record || macro) saveLabel(cg, label); y++; }
/** * Creates the <tt>Component</tt> hierarchy of the area of status-related information such as * <tt>CallPeer</tt> display name, call duration, security status. * * @return the root of the <tt>Component</tt> hierarchy of the area of status-related information * such as <tt>CallPeer</tt> display name, call duration, security status */ private Component createStatusBar() { // stateLabel callStatusLabel.setForeground(Color.WHITE); dtmfLabel.setForeground(Color.WHITE); callStatusLabel.setText(callPeer.getState().getLocalizedStateString()); PeerStatusPanel statusPanel = new PeerStatusPanel(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.gridx = 0; constraints.gridy = 0; statusPanel.add(securityStatusLabel, constraints); initSecurityStatusLabel(); constraints.gridx++; statusPanel.add(holdStatusLabel, constraints); constraints.gridx++; statusPanel.add(muteStatusLabel, constraints); constraints.gridx++; callStatusLabel.setBorder(BorderFactory.createEmptyBorder(2, 3, 2, 12)); statusPanel.add(callStatusLabel, constraints); constraints.gridx++; constraints.weightx = 1f; statusPanel.add(dtmfLabel, constraints); return statusPanel; }
public void addForDisplay(CTalkativeTextPane pane, LabelPair<String, String> lp) { GridBagLayout gridbag = (GridBagLayout) getLayout(); labelPair = lp; label = new JLabel(labelPair.getSingular(), JLabel.LEFT); pane.getDocument().addDocumentListener(this); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.1; c.weighty = 0.1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 20, 0, 00); gridbag.setConstraints(pane, c); add(pane); c = new GridBagConstraints(); c.gridx = 1; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.1; c.weighty = 0.1; c.anchor = GridBagConstraints.LINE_START; c.insets = new Insets(0, 0, 0, 20); gridbag.setConstraints(label, c); add(label); JPanel filler = new JPanel(); filler.setBackground(white); c = new GridBagConstraints(); c.gridx = 2; c.gridy = 0; c.gridwidth = 1; c.gridheight = 1; c.weightx = 0.8; c.weighty = 0.8; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.LINE_END; gridbag.setConstraints(filler, c); add(filler); filler = null; c = null; }
/** * Adds an editable text field containing the hours spent on a project. * * @param gbl The layout to add the text field to. * @param gbc The layout constraints to use. * @param row The row to link against. * @param hours The number of hours spent on the project. * @see {@link #addRow(GridBagLayout, GridBagConstraints, String, double)} */ private void addMiddleField(GridBagLayout gbl, GridBagConstraints gbc, Row row, double hours) { row.hoursTF.setText(decimalFormat.format(hours)); gbc.gridx = 1; gbc.weightx = 1; gbl.setConstraints(row.hoursTF, gbc); gbc.weightx = 0; reviewPanel.add(row.hoursTF); }
private void addSpacer() { JPanel spacer = new JPanel(); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = 1; gbc.gridx = 5; gbc.gridy = 0; add(spacer, gbc); }
/** * Adds a simple 'h' to show that the time period is specified in hours. * * @param gbl The layout to add the label to. * @param gbc The layout constraints to use. * @see {@link #addRow(GridBagLayout, GridBagConstraints, String, double)} */ private void addRightLabel(GridBagLayout gbl, GridBagConstraints gbc) { JLabel hLabel = new JLabel("h", SwingConstants.CENTER); gbc.gridx = 2; gbc.ipadx = 5; gbl.setConstraints(hLabel, gbc); gbc.ipadx = 0; reviewPanel.add(hLabel); }
protected void layoutUIComponents(String strPath, boolean bDefaultFile) { // gbc.weightx = 0.5; showInstructions(m_gbl, m_gbc, 0, 0, 7, infoLabel1); showInstructions(m_gbl, m_gbc, 0, 1, 7, infoLabel2); showInstructions(m_gbl, m_gbc, 0, 2, 7, infoLabel3); /*showInstructions( gbl, gbc, 0, 3, 7, infoLabel4 ); showInstructions( gbl, gbc, 0, 4, 7, infoLabel5 );*/ showInstructions(m_gbl, m_gbc, 0, 5, 1, new JLabel("")); // i18n // label = new JLabel( "LABEL" ); label = new JLabel(Util.getAdmLabel("_adm_LABEL")); label.setForeground(Color.black); m_gbc.gridx = 1; m_gbc.gridy = 5; // gbc.ipadx = 10; m_gbl.setConstraints(label, m_gbc); m_pnlDisplay.add(label); label = new JLabel(" "); m_gbc.gridx = 2; m_gbc.gridy = 5; m_gbc.ipadx = 0; m_gbc.gridwidth = 5; m_gbc.weightx = 0; m_gbl.setConstraints(label, m_gbc); // add( label ); // i18n // showInstructions( m_gbl, m_gbc, 2, 5, 1, new JLabel( "DIRECTORY" )); showInstructions(m_gbl, m_gbc, 2, 5, 1, new JLabel(Util.getAdmLabel("_adm_DIRECTORY"))); m_nRow = 5; m_bDefaultFile = bDefaultFile; m_objTxfValue.clearArrays(); displayNewTxf(strPath); m_pnlDisplay.setBorder( new CompoundBorder( // i18n // BorderFactory.createTitledBorder( " Parent Directories "), BorderFactory.createTitledBorder(Util.getAdmLabel("_adm_Parent_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
/** * Hilfsmethode für das GridBagLayout zur Positionierung der Elemente. * * @param x die x-Position im Grid * @param y die y-Position im Grid * @param width gibt die Anzahl der Spalten an, die die Komponente nutzen soll * @param height gibt die Anzahl der Zeilen an, die die Komponente nutzen soll * @return die Rahmenbedingungen für eine Komponente */ private GridBagConstraints makegbc(int x, int y, int width, int height) { GridBagConstraints gbc = new GridBagConstraints(); gbc.gridx = x; gbc.gridy = y; gbc.gridwidth = width; gbc.gridheight = height; gbc.insets = new Insets(1, 5, 1, 1); return gbc; }
/** * Adds a group of checkboxs using a grid layout. * * @param rows the number of rows * @param columns the number of columns * @param labels the labels * @param defaultValues the initial states * @param headings the column headings Example: * http://imagej.nih.gov/ij/plugins/multi-column-dialog/index.html */ public void addCheckboxGroup( int rows, int columns, String[] labels, boolean[] defaultValues, String[] headings) { Panel panel = new Panel(); int nRows = headings != null ? rows + 1 : rows; panel.setLayout(new GridLayout(nRows, columns, 6, 0)); int startCBIndex = cbIndex; if (checkbox == null) checkbox = new Vector(12); if (headings != null) { Font font = new Font("SansSerif", Font.BOLD, 12); for (int i = 0; i < columns; i++) { if (i > headings.length - 1 || headings[i] == null) panel.add(new Label("")); else { Label label = new Label(headings[i]); label.setFont(font); panel.add(label); } } } int i1 = 0; int[] index = new int[labels.length]; for (int row = 0; row < rows; row++) { for (int col = 0; col < columns; col++) { int i2 = col * rows + row; if (i2 >= labels.length) break; index[i1] = i2; String label = labels[i1]; if (label == null || label.length() == 0) { Label lbl = new Label(""); panel.add(lbl); i1++; continue; } if (label.indexOf('_') != -1) label = label.replace('_', ' '); Checkbox cb = new Checkbox(label); checkbox.addElement(cb); cb.setState(defaultValues[i1]); cb.addItemListener(this); if (Recorder.record || macro) saveLabel(cb, labels[i1]); if (IJ.isLinux()) { Panel panel2 = new Panel(); panel2.setLayout(new BorderLayout()); panel2.add("West", cb); panel.add(panel2); } else panel.add(cb); i1++; } } c.gridx = 0; c.gridy = y; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; c.insets = getInsets(10, 0, 0, 0); grid.setConstraints(panel, c); add(panel); y++; }
private void addField(OptionField field) { // Add label JLabel l = new JLabel(field.getDisplayName() + ":"); GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = currentRow; c.insets = new Insets(5, 2, 2, 2); c.anchor = GridBagConstraints.NORTHWEST; content.add(l, c); // Add enable checkbox if (field.getEnableToggle() != null) { c = new GridBagConstraints(); c.gridx = 1; c.gridy = currentRow; c.fill = GridBagConstraints.BOTH; c.insets = new Insets(2, 2, 2, 2); c.anchor = GridBagConstraints.NORTHWEST; content.add(field.getEnableToggle(), c); } // Add field c = new GridBagConstraints(); c.gridx = 2; c.gridy = currentRow; c.fill = GridBagConstraints.BOTH; c.insets = new Insets(2, 2, 2, 2); c.anchor = GridBagConstraints.NORTHWEST; content.add(field.getComponent(), c); // Add change listener field.addChangeListener( new ChangeListener() { @Override public void stateChanged(ChangeEvent e) { fireChangeEvent(); } }); // Update state currentRow++; pack(); }
private void addSlider() { _slider = new JSlider(_minimum, _maximum, _minimum); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = 4; gbc.gridx = 0; gbc.gridy = 0; gbc.weightx = 1.0; gbc.fill = GridBagConstraints.HORIZONTAL; add(_slider, gbc); }
/** * Adds a Panel to the dialog with custom contraint and insets. The defaults are * GridBagConstraints.WEST (left justified) and "new Insets(5, 0, 0, 0)" (5 pixels of padding at * the top). */ public void addPanel(Panel panel, int constraints, Insets insets) { c.gridx = 0; c.gridy = y; c.gridwidth = 2; c.anchor = constraints; c.insets = insets; grid.setConstraints(panel, c); add(panel); y++; }
/** Initializes the GUI */ private void initGui() { this.setBackground(Color.white); headerPane = new HeaderPanel(this); contentPane = new ContentPanel(this); headerPane.getIntervalLabel().setText(contentPane.getStrategy().getDisplayInterval()); this.setLayout(new GridBagLayout()); final GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.weightx = 1; c.fill = GridBagConstraints.BOTH; add(headerPane, c); c.gridx = 0; c.gridy = 1; c.weighty = 0.9; c.insets = new Insets(10, 10, 10, 10); add(contentPane, c); }
GitCheckinOptions(@NotNull final Project project, @NotNull CheckinProjectPanel panel) { super(project, panel); myVcs = GitVcs.getInstance(project); final Insets insets = new Insets(2, 2, 2, 2); // add authors drop down GridBagConstraints c = new GridBagConstraints(); c.gridx = 0; c.gridy = 0; c.anchor = GridBagConstraints.WEST; c.insets = insets; final JLabel authorLabel = new JLabel(GitBundle.message("commit.author")); myPanel.add(authorLabel, c); c = new GridBagConstraints(); c.anchor = GridBagConstraints.CENTER; c.insets = insets; c.gridx = 1; c.gridy = 0; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; final List<String> usersList = getUsersList(project); final Set<String> authors = usersList == null ? new HashSet<String>() : new HashSet<String>(usersList); ContainerUtil.addAll(authors, mySettings.getCommitAuthors()); List<String> list = new ArrayList<String>(authors); Collections.sort(list); list = ObjectsConvertor.convert( list, new Convertor<String, String>() { @Override public String convert(String o) { return StringUtil.shortenTextWithEllipsis(o, 30, 0); } }); myAuthor = new ComboBox(ArrayUtil.toObjectArray(list)); myAuthor.insertItemAt("", 0); myAuthor.setSelectedItem(""); myAuthor.setEditable(true); authorLabel.setLabelFor(myAuthor); myAuthor.setToolTipText(GitBundle.getString("commit.author.tooltip")); myPanel.add(myAuthor, c); }
protected void buildPanel(String strPath) { strPath = FileUtil.openPath(strPath); ArrayList aListPath = new ArrayList(); BufferedReader reader = WFileUtil.openReadFile(strPath); if (reader == null) return; String strLine; try { while ((strLine = reader.readLine()) != null) { StringTokenizer strTok = new StringTokenizer(strLine, ":"); if (strTok.countTokens() < 4) continue; boolean bChecksum = false; boolean bShow = false; String strDir = strTok.nextToken(); String strChecksum = strTok.nextToken(); if (strChecksum.equalsIgnoreCase("checksum")) bChecksum = true; if (bChecksum && (strDir.equals("file") || strDir.equals("dir"))) { String strValue = strTok.nextToken(); String strShow = strTok.nextToken(); if (strShow.equalsIgnoreCase("yes")) bShow = true; if (bShow) aListPath.add(strValue); } } m_cmbPath = new JComboBox(aListPath.toArray()); JPanel pnlDisplay = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints( 0, 0, 1, 1, 0.2, 0.2, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(0, 0, 0, 0), 0, 0); pnlDisplay.add(m_cmbPath, gbc); gbc.gridx = 1; pnlDisplay.add(m_cmbChecksum, gbc); add(pnlDisplay, BorderLayout.NORTH); add(m_txaChecksum, BorderLayout.CENTER); } catch (Exception e) { e.printStackTrace(); } }