MCPcopy Create free account
hub / github.com/AstroImageJ/astroimagej / addChoice

Method addChoice

ij/src/main/java/ij/gui/GenericDialog.java:818–858  ·  view source on GitHub ↗

Adds a popup menu. @param label the label @param items the menu items @param defaultItem the menu item initially selected

(String label, String[] items, String defaultItem)

Source from the content-addressed store, hash-verified

816 * @param defaultItem the menu item initially selected
817 */
818 public void addChoice(String label, String[] items, String defaultItem) {
819 String label2 = label;
820 if (label2.indexOf('_')!=-1)
821 label2 = label2.replace('_', ' ');
822 Label fieldLabel = makeLabel(label2);
823 this.lastLabelAdded = fieldLabel;
824 if (addToSameRow) {
825 c.gridx = GridBagConstraints.RELATIVE;
826 addToSameRow = false;
827 } else {
828 c.gridx = 0; c.gridy++;
829 if (choice==null)
830 c.insets = getInsets(5, 0, 5, 0);
831 else
832 c.insets = getInsets(0, 0, 5, 0);
833 }
834 c.anchor = GridBagConstraints.EAST;
835 c.gridwidth = 1;
836 if (choice==null) {
837 choice = new Vector(4);
838 defaultChoiceIndexes = new Vector(4);
839 }
840 add(fieldLabel, c);
841 Choice thisChoice = new Choice();
842 thisChoice.addKeyListener(this);
843 thisChoice.addItemListener(this);
844 for (int i=0; i<items.length; i++)
845 thisChoice.addItem(items[i]);
846 if (defaultItem!=null)
847 thisChoice.select(defaultItem);
848 else
849 thisChoice.select(0);
850 c.gridx = GridBagConstraints.RELATIVE;
851 c.anchor = GridBagConstraints.WEST;
852 add(thisChoice, c);
853 choice.addElement(thisChoice);
854 int index = thisChoice.getSelectedIndex();
855 defaultChoiceIndexes.addElement(Integer.valueOf(index));
856 if (IJ.recording() || macro)
857 saveLabel(thisChoice, label);
858 }
859
860 /** Adds a message consisting of one or more lines of text. */
861 public void addMessage(String text) {

Callers 15

convertImagesToStackMethod · 0.95
mergeStacksMethod · 0.95
runMethod · 0.95
showDialogMethod · 0.95
runMethod · 0.95
runMethod · 0.95
getHyperstackProfileMethod · 0.95
resizeMethod · 0.95
showDialogMethod · 0.95
runMethod · 0.95
showDialogMethod · 0.95

Calls 13

makeLabelMethod · 0.95
getInsetsMethod · 0.95
recordingMethod · 0.95
saveLabelMethod · 0.95
getSelectedIndexMethod · 0.80
valueOfMethod · 0.80
addMethod · 0.65
indexOfMethod · 0.45
replaceMethod · 0.45
addKeyListenerMethod · 0.45
addItemMethod · 0.45
selectMethod · 0.45

Tested by

no test coverage detected