public DisplayUserDirectory() { GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); setLayout(gbl); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; hmlabel.setForeground(Color.black); add(hmlabel, gbc); add(Box.createHorizontalStrut(10), gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; add(hmdir, gbc); add(Box.createVerticalStrut(15), gbc); gbc.gridwidth = 1; vjlabel.setForeground(Color.black); add(vjlabel, gbc); add(Box.createHorizontalStrut(10), gbc); gbc.gridwidth = GridBagConstraints.REMAINDER; add(vjdir, gbc); add(Box.createVerticalStrut(0), gbc); gbc.gridwidth = 1; vjlabel2.setForeground(Color.black); add(vjlabel2, gbc); setBorder( new CompoundBorder( // i18n // BorderFactory.createTitledBorder(" User_Directories "), BorderFactory.createTitledBorder(Util.getAdmLabel("_admin_User_Directories")), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
private void setRow(GridBagConstraints c, GridBagLayout gridbag, Component obj1, Component obj2) { c.gridwidth = GridBagConstraints.RELATIVE; gridbag.setConstraints(obj1, c); add(obj1); c.gridwidth = GridBagConstraints.REMAINDER; // end row gridbag.setConstraints(obj2, c); add(obj2); c.fill = GridBagConstraints.BOTH; }
/** * 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); } }
// 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 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); }
public DisplayResults() { GridBagLayout gbl = new GridBagLayout(); GridBagConstraints gbc = new GridBagConstraints(); setLayout(gbl); gbc.anchor = GridBagConstraints.NORTHWEST; gbc.fill = GridBagConstraints.HORIZONTAL; text.setForeground(Color.black); add(text, gbc); gbc.gridy = 0; gbc.gridwidth = GridBagConstraints.REMAINDER; add(emptyLabel, gbc); add(Box.createVerticalStrut(0), gbc); add(emptyLabel, gbc); /* gbc.gridy = 1; VTextMsg result = new VTextMsg(sshare, vnmrif, null); result.setPreferredSize(new Dimension(300, 30)); result.setForeground(Color.black); add( result, gbc ); */ setBorder( new CompoundBorder( BorderFactory.createTitledBorder(" Results "), BorderFactory.createEmptyBorder(10, 10, 10, 10))); }
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(); }
/** * 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++; }
/** * 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++; }
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); }
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; }
private void addSpacer() { JPanel spacer = new JPanel(); GridBagConstraints gbc = new GridBagConstraints(); gbc.gridwidth = 1; gbc.gridx = 5; gbc.gridy = 0; add(spacer, gbc); }
/** * 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 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++; }
protected GridBagConstraints createConstraints(int x, int y) { GridBagConstraints c = new GridBagConstraints(); c.gridx = x; c.gridy = y; c.gridwidth = 2; c.gridheight = 1; c.ipadx = 1; c.weightx = 0.5; c.weighty = 0.5; c.fill = GridBagConstraints.BOTH; c.anchor = GridBagConstraints.CENTER; return c; }
/** * 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))); }
private void showInstruction( GridBagLayout gbl, GridBagConstraints gbc, int gridx, int gridy, int gridwidth, JLabel instruction) { gbc.gridwidth = gridwidth; gbc.gridx = gridx; gbc.gridy = gridy; gbl.setConstraints(instruction, gbc); instruction.setForeground(Color.black); m_pnlDisplay.add(instruction); }
private Connector() { setLayout(new GridBagLayout()); // setBorder (new EmptyBorder (8, 8, 8, 8)); GridBagConstraints c = new GridBagConstraints(); c.insets = new Insets(0, 0, 3, 3); c.anchor = GridBagConstraints.WEST; add(new JLabel(bundle.getString("CTL_HostName")), c); tfHost = new JTextField(host, 25); c = new GridBagConstraints(); c.gridwidth = 0; c.insets = new Insets(0, 3, 3, 0); c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.weightx = 1.0; add(tfHost, c); c = new GridBagConstraints(); c.insets = new Insets(3, 0, 0, 3); c.anchor = GridBagConstraints.WEST; add(new JLabel(bundle.getString("CTL_Password")), c); tfPassword = new JTextField(25); c = new GridBagConstraints(); c.gridwidth = 0; c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.weightx = 1.0; c.insets = new Insets(3, 3, 0, 0); add(tfPassword, c); c = new GridBagConstraints(); c.fill = java.awt.GridBagConstraints.BOTH; c.weighty = 1.0; JPanel p = new JPanel(); p.setPreferredSize(new Dimension(1, 1)); add(p, c); }
public DvcsCommitAdditionalComponent( @NotNull final Project project, @NotNull CheckinProjectPanel panel) { myCheckinPanel = panel; myPanel = new JPanel(new GridBagLayout()); final Insets insets = new Insets(2, 2, 2, 2); // add amend checkbox GridBagConstraints c = new GridBagConstraints(); // todo change to MigLayout c.gridx = 0; c.gridy = 1; c.gridwidth = 2; c.anchor = GridBagConstraints.CENTER; c.insets = insets; c.weightx = 1; c.fill = GridBagConstraints.HORIZONTAL; myAmend = new NonFocusableCheckBox(DvcsBundle.message("commit.amend")); myAmend.setMnemonic('m'); myAmend.setToolTipText(DvcsBundle.message("commit.amend.tooltip")); myPreviousMessage = myCheckinPanel.getCommitMessage(); myAmend.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { if (myAmend.isSelected()) { if (myPreviousMessage.equals( myCheckinPanel .getCommitMessage())) { // if user has already typed something, don't revert // it if (myMessagesForRoots == null) { loadMessagesInModalTask(project); // load all commit messages for all repositories } String message = constructAmendedMessage(); if (!StringUtil.isEmptyOrSpaces(message)) { myAmendedMessage = message; substituteCommitMessage(myAmendedMessage); } } } else { // there was the amended message, but user has changed it => not reverting if (myCheckinPanel.getCommitMessage().equals(myAmendedMessage)) { myCheckinPanel.setCommitMessage(myPreviousMessage); } } } }); myPanel.add(myAmend, c); }
/* * helper class to initialize empty spaces * @param int x - column of button * @param int y - row of button * @param Dimension btnSize - sets the size of the button */ public void createBlankButtons(int x, int y, Dimension btnSize) { String output = ""; Font clueFont = new Font("Arial", Font.PLAIN, 8); // initialize next myButton btn[activeMyButtons] = new myButton(); String toolTip = ("" + activeMyButtons); btn[activeMyButtons].setDefaultToolTipText(toolTip); btn[activeMyButtons].setToolTipText(toolTip); // get next available myButton and assign current position btn[activeMyButtons].positionX = x; btn[activeMyButtons].positionY = y; btn[activeMyButtons].button = activeMyButtons; btn[activeMyButtons].setPreferredSize(btnSize); btn[activeMyButtons].setFont(clueFont); // assign GridBagConstraints for //position cons.gridx = x; cons.gridy = y; cons.gridwidth = 1; cons.gridheight = 1; cons.ipadx = 0; cons.ipady = 0; // determine position and set alternating color if (((x % 2 == 0) && (y % 2 == 0)) || ((x % 2 != 0) && (y % 2 != 0))) { btn[activeMyButtons].setBackground(new Color(152, 86, 112)); btn[activeMyButtons].setDefaultColor(new Color(152, 86, 112)); } else { btn[activeMyButtons].setBackground(new Color(128, 48, 82)); btn[activeMyButtons].setDefaultColor(new Color(128, 48, 82)); } btn[activeMyButtons].setOpaque(true); btn[activeMyButtons].setBorderPainted(false); // add button to boardPanel this.add(btn[activeMyButtons], cons); btn[activeMyButtons].addActionListener(new myActionListener()); validate(); // pass output to setOutput() output = "activeMyButtons: " + activeMyButtons + " " + btn[activeMyButtons].getDefaultColor(); // setOutput(output); activeMyButtons++; }
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))); }
/** * Adds a message consisting of one or more lines of text, which will be displayed using the * specified font and color. */ public void addMessage(String text, Font font, Color color) { theLabel = null; if (text.indexOf('\n') >= 0) theLabel = new MultiLineLabel(text); else theLabel = new Label(text); // theLabel.addKeyListener(this); c.gridx = 0; c.gridy = y; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; c.insets = getInsets(text.equals("") ? 0 : 10, 20, 0, 0); c.fill = GridBagConstraints.HORIZONTAL; grid.setConstraints(theLabel, c); if (font != null) theLabel.setFont(font); if (color != null) theLabel.setForeground(color); add(theLabel); c.fill = GridBagConstraints.NONE; y++; }
/** * Adds one or two (side by side) text areas. * * @param text1 initial contents of the first text area * @param text2 initial contents of the second text area or null * @param rows the number of rows * @param columns the number of columns */ public void addTextAreas(String text1, String text2, int rows, int columns) { if (textArea1 != null) return; Panel panel = new Panel(); textArea1 = new TextArea(text1, rows, columns, TextArea.SCROLLBARS_NONE); if (IJ.isLinux()) textArea1.setBackground(Color.white); textArea1.addTextListener(this); panel.add(textArea1); if (text2 != null) { textArea2 = new TextArea(text2, rows, columns, TextArea.SCROLLBARS_NONE); if (IJ.isLinux()) textArea2.setBackground(Color.white); panel.add(textArea2); } c.gridx = 0; c.gridy = y; c.gridwidth = 2; c.anchor = GridBagConstraints.WEST; c.insets = getInsets(15, 20, 0, 0); grid.setConstraints(panel, c); add(panel); y++; }
private void addSeparator(String label) { JPanel p = new JPanel(new GridBagLayout()); GridBagConstraints c; if (label != null) { // left border c = new GridBagConstraints(); c.gridy = 0; c.ipadx = 15; // half the desired width p.add(new JSeparator(), c); // label c = new GridBagConstraints(); c.gridy = 0; c.insets = new Insets(0, 4, 0, 4); p.add(new JLabel(label), c); } // right border c = new GridBagConstraints(); c.gridy = 0; c.fill = GridBagConstraints.HORIZONTAL; c.weightx = 1; p.add(new JSeparator(), c); // add to window c = new GridBagConstraints(); c.gridx = 0; c.gridy = currentRow++; c.gridwidth = 3; c.fill = GridBagConstraints.HORIZONTAL; if (label == null) { // simple separator between predicate name and options; don't use // pronounced section break c.insets = new Insets(3, 0, 3, 0); } else { c.insets = new Insets(10, 0, 0, 0); } content.add(p, c); }
/** * Adds a text field. * * @param label the label * @param defaultText text initially displayed * @param columns width of the text field */ public void addStringField(String label, String defaultText, int columns) { 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; boolean custom = customInsets; if (stringField == null) { stringField = new Vector(4); defaultStrings = new Vector(4); c.insets = getInsets(5, 0, 5, 0); } else c.insets = getInsets(0, 0, 5, 0); grid.setConstraints(theLabel, c); add(theLabel); if (custom) { if (stringField.size() == 0) c.insets = getInsets(5, 0, 5, 0); else c.insets = getInsets(0, 0, 5, 0); } TextField tf = new TextField(defaultText, columns); if (IJ.isLinux()) tf.setBackground(Color.white); tf.setEchoChar(echoChar); echoChar = 0; tf.addActionListener(this); tf.addTextListener(this); tf.addFocusListener(this); tf.addKeyListener(this); c.gridx = 1; c.gridy = y; c.anchor = GridBagConstraints.WEST; grid.setConstraints(tf, c); tf.setEditable(true); add(tf); stringField.addElement(tf); defaultStrings.addElement(defaultText); if (Recorder.record || macro) saveLabel(tf, label); y++; }
/** * Initializes the display details component for the given <tt>UIContact</tt>. * * @param displayDetails the display details to show */ private void initDisplayDetails(String displayDetails) { remove(displayDetailsLabel); displayDetailsLabel.setText(""); if (displayDetails != null && displayDetails.length() > 0) { // Replace all occurrences of new line with slash. displayDetails = Html2Text.extractText(displayDetails); displayDetails = displayDetails.replaceAll("\n|<br>|<br/>", " / "); displayDetailsLabel.setText(displayDetails); } constraints.anchor = GridBagConstraints.WEST; constraints.fill = GridBagConstraints.NONE; constraints.gridx = 1; constraints.gridy = 1; constraints.weightx = 1f; constraints.weighty = 0f; constraints.gridwidth = 1; constraints.gridheight = 1; this.add(displayDetailsLabel, constraints); }