/** 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) { if (addToSameRow) { c.gridx = GridBagConstraints.RELATIVE; addToSameRow = false; } else { c.gridx = 0; c.gridy++; } c.gridwidth = 2; c.anchor = constraints; c.insets = insets; add(panel, c); }
public static void addMessageAsJLabel(String msg, GenericDialog gd, Font font, Color color) { gd.addMessage( msg ); if (!PluginHelper.isHeadless()) { final Component msgC = gd.getComponent(gd.getComponentCount() - 1 ); final JLabel msgLabel = new JLabel(msg); if (font!=null) msgLabel.setFont(font); if (color!=null) msgLabel.setForeground(color); gd.add(msgLabel); GridBagConstraints constraints = ((GridBagLayout)gd.getLayout()).getConstraints(msgC); ((GridBagLayout)gd.getLayout()).setConstraints(msgLabel, constraints); gd.remove(msgC); } }
c.anchor = GridBagConstraints.WEST; c.insets = new Insets(insets.top, insets.left, 0, 0); add(panel, c); if (Recorder.record || macro) saveLabel(cg, label);
/** 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) { if (addToSameRow) { c.gridx = GridBagConstraints.RELATIVE; addToSameRow = false; } else { c.gridx = 0; c.gridy++; } c.gridwidth = 2; c.anchor = constraints; c.insets = insets; add(panel, c); }
c.anchor = GridBagConstraints.WEST; c.insets = new Insets(insets.top, insets.left, 0, 0); add(panel, c); if (Recorder.record || macro) saveLabel(cg, label);
/** 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); if (addToSameRow) { c.gridx = GridBagConstraints.RELATIVE; addToSameRow = false; } else { c.gridx = 0; c.gridy++; c.insets = getInsets("".equals(text)?0:10, 20, 0, 0); // top, left, bottom, right } c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; if (font!=null) { if (Prefs.getGuiScale()>1.0) font = font.deriveFont((float)(font.getSize()*Prefs.getGuiScale())); theLabel.setFont(font); } if (color!=null) theLabel.setForeground(color); add(theLabel, c); c.fill = GridBagConstraints.NONE; }
/** 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); if (addToSameRow) { c.gridx = GridBagConstraints.RELATIVE; addToSameRow = false; } else { c.gridx = 0; c.gridy++; c.insets = getInsets("".equals(text)?0:10, 20, 0, 0); // top, left, bottom, right } c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.fill = GridBagConstraints.HORIZONTAL; if (font!=null) { if (Prefs.getGuiScale()>1.0) font = font.deriveFont((float)(font.getSize()*Prefs.getGuiScale())); theLabel.setFont(font); } if (color!=null) theLabel.setForeground(color); add(theLabel, c); c.fill = GridBagConstraints.NONE; }
cb.addItemListener(this); cb.addKeyListener(this); add(cb, c); c.insets.left = 0; checkbox.addElement(cb);
cb.addItemListener(this); cb.addKeyListener(this); add(cb, c); c.insets.left = 0; checkbox.addElement(cb);
gdl.setConstraints(masterPanel, gbc); gd.add(masterPanel);
gdl.setConstraints(masterPanel, gbc); gd.add(masterPanel);
/** 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(); Font font = new Font("SansSerif", Font.PLAIN, 14); textArea1 = new TextArea(text1,rows,columns,TextArea.SCROLLBARS_NONE); if (IJ.isLinux()) textArea1.setBackground(Color.white); textArea1.setFont(font); 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); textArea2.setFont(font); panel.add(textArea2); } c.gridx = 0; c.gridy++; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.insets = getInsets(15, 20, 0, 0); addToSameRow = false; add(panel, c); }
/** 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(); Font font = new Font("SansSerif", Font.PLAIN, 14); textArea1 = new TextArea(text1,rows,columns,TextArea.SCROLLBARS_NONE); if (IJ.isLinux()) textArea1.setBackground(Color.white); textArea1.setFont(font); 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); textArea2.setFont(font); panel.add(textArea2); } c.gridx = 0; c.gridy++; c.gridwidth = GridBagConstraints.REMAINDER; c.anchor = GridBagConstraints.WEST; c.insets = getInsets(15, 20, 0, 0); addToSameRow = false; add(panel, c); }