private static void test(final Point tmp) throws Exception { Choice choice = new Choice(); for (int i = 1; i < 7; i++) { choice.add("Long-long-long-long-long text in the item-" + i); } Frame frame = new Frame(); try { frame.setAlwaysOnTop(true); frame.setLayout(new FlowLayout()); frame.add(choice); frame.pack(); frameWidth = frame.getWidth(); frame.setSize(frameWidth, SIZE); frame.setVisible(true); frame.setLocation(tmp.x, tmp.y); openPopup(choice); } finally { frame.dispose(); } }
private static void UI() { Frame frame = new Frame("Test frame"); Choice choice = new Choice(); Stream.of(new String[]{"item 1", "item 2", "item 3"}).forEach(choice::add); frame.add(choice); frame.setBounds(100, 100, 400, 200); frame.setVisible(true); Font font = choice.getFont(); int size = font.getSize(); int height = choice.getBounds().height; try { if (height < size) { throw new RuntimeException("Test failed"); } } finally { frame.dispose(); } }
/** * Show dialog. * * @return the image plus */ public ImagePlus showDialog(){ gd = new GenericDialog("Add Image"); gd.setResizable(true); gd.pack(); String[] source = {"From Image","From File"}; gd.addChoice("Image Source:", source, null); addImageChoice(); // automatically update name if a different image is selected final Choice im = (Choice) gd.getChoices().get(0); im.addItemListener(this); gd.showDialog(); if(gd.wasCanceled()) return null; if(!fromFile) { img = fromImage(); } return img; }
public void drawForm() { removeAll(); cRightAxis = new Choice(); Panel mainPanel = new Panel(); mainPanel.setLayout( new GridLayout(recorder.plotSize + 2, 0) ); mainPanel.add(L1); cRightAxis.addItem("Parameters (0 to 1)"); cRightAxis.addItem("Currents"); mainPanel.add(cRightAxis); for (int x = 0; x < recorder.plotSize; x++) { c[x] = new Checkbox(recorder.names[x] ); c[x].setForeground( recorder.colorArray[x] ); c[x].setState( recorder.plot[x] ); mainPanel.add(c[x]); } setLayout( new BorderLayout()); add("Center", mainPanel); validate(); }
public GtkChoicePeer (Choice c) { super (c); int count = c.getItemCount (); if (count > 0) { for (int i = 0; i < count; i++) add(c.getItem(i), i); selected = c.getSelectedIndex(); if (selected >= 0) select( selected ); } else selected = -1; }
protected void addListeners( final GenericDialog gd, final Choice choice, final MyMultiLineLabel label, final ArrayList< MultiViewDatasetDefinition > datasetDefinitions ) { gd.addDialogListener( new DialogListener() { @Override public boolean dialogItemChanged( final GenericDialog dialog, final AWTEvent e ) { if ( e instanceof ItemEvent && e.getID() == ItemEvent.ITEM_STATE_CHANGED && e.getSource() == choice ) { label.setText( formatEntry( datasetDefinitions.get( choice.getSelectedIndex() ).getExtendedDescription(), numCharacters, numLinesDocumentation ) ); } return true; } } ); }
protected void addListeners( final GenericDialog gd, final Choice choice, final Label label1, final Label label2 ) { choice.addItemListener( new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { update( spimData, choice, label1, label2 ); } }); update( spimData, choice, label1, label2 ); }
@Override public void queryAdditionalParameters( final GenericDialog gd ) { gd.addChoice( "ImgLib2_container_FFTs", BoundingBoxGUI.imgTypes, BoundingBoxGUI.imgTypes[ defaultFFTImgType ] ); gd.addCheckbox( "Save_memory (not keep FFT's on CPU, 2x time & 0.5x memory)", defaultSaveMemory ); saveMem = (Checkbox)gd.getCheckboxes().lastElement(); gd.addChoice( "Type_of_iteration", iterationTypeString, iterationTypeString[ defaultIterationType ] ); it = (Choice)gd.getChoices().lastElement(); gd.addChoice( "Image_weights", weightsString, weightsString[ defaultWeightType ] ); weight = (Choice)gd.getChoices().lastElement(); gd.addChoice( "OSEM_acceleration", osemspeedupChoice, osemspeedupChoice[ defaultOSEMspeedupIndex ] ); gd.addNumericField( "Number_of_iterations", defaultNumIterations, 0 ); gd.addCheckbox( "Debug_mode", defaultDebugMode ); gd.addCheckbox( "Adjust_blending_parameters (if stripes are visible)", defaultAdjustBlending ); gd.addCheckbox( "Use_Tikhonov_regularization", defaultUseTikhonovRegularization ); gd.addNumericField( "Tikhonov_parameter", defaultLambda, 4 ); gd.addChoice( "Compute", blocksChoice, blocksChoice[ defaultBlockSizeIndex ] ); block = (Choice)gd.getChoices().lastElement(); gd.addChoice( "Compute_on", computationOnChoice, computationOnChoice[ defaultComputationTypeIndex ] ); gpu = (Choice)gd.getChoices().lastElement(); gd.addChoice( "PSF_estimation", extractPSFChoice, extractPSFChoice[ defaultExtractPSF ] ); gd.addChoice( "PSF_display", displayPSFChoice, displayPSFChoice[ defaultDisplayPSF ] ); }
private ImagePlus getRoiSource(ImagePlus imp, Choice imageList, Choice optionList) { // Get the ROI option if (optionList.getSelectedItem().equals(OPTION_NONE)) { // No ROI image return null; } // Find the image in the image list if (imageList.getSelectedItem().equals(CHANNEL_IMAGE)) { // Channel image is the source for the ROI return imp; } return WindowManager.getImage(imageList.getSelectedItem()); }
private Panel createRoiChoicePanel(Choice imageList, Choice optionList, String label, int selectedOptionIndex) { Panel panel = new Panel(); panel.setLayout(new BorderLayout()); Label listLabel = new Label(label, 0); listLabel.setFont(monoFont); // imageList.setSize(fontWidth * 3, fontWidth); panel.add(listLabel, BorderLayout.WEST); panel.add(optionList, BorderLayout.CENTER); panel.add(imageList, BorderLayout.EAST); optionList.add(OPTION_NONE); optionList.add(OPTION_MIN_VALUE); optionList.add(OPTION_USE_ROI); optionList.add(OPTION_MASK); imageList.add(CHANNEL_IMAGE); if (selectedOptionIndex < 4 && selectedOptionIndex >= 0) { optionList.select(selectedOptionIndex); } return panel; }
private Panel createChoicePanel(Choice list, String[] options, String selected, String label) { Panel panel = new Panel(); panel.setLayout(new BorderLayout()); Label listLabel = new Label(label, 0); if (options != null) { for (String option : options) list.add(option); try { list.select(Integer.parseInt(selected)); } catch (Exception ex) { list.select((String) selected); } } panel.add(listLabel, BorderLayout.WEST); panel.add(list, BorderLayout.CENTER); return panel; }
public void itemStateChanged(ItemEvent e) { Object actioner = e.getSource(); if (actioner instanceof Choice) { if (updateChildren) { fillChildList(); } } parentImage = (synchroniseButton.isSelected()) ? WindowManager.getImage(extractId(this.imageChoice.getSelectedItem())) : null; updateSynchronisation(); }
public dialogASSAR(final Frame parentWindow, final ImagePlus[] imageList) { super("ASSAR", parentWindow); // We create a list of image titles to be used as source or target images String[] titles = new String[imageList.length]; for ( int i = 0; i < titles.length; ++i ) { titles[i] = imageList[i].getTitle(); } // Source and target choices addChoice( "Source_Image", titles, titles[0]); this.sourceChoice = (Choice) super.getChoices().lastElement(); addChoice( "Target_Image", titles, titles[1]); this.targetChoice = (Choice) super.getChoices().lastElement(); }
public Panel construirPanelSolicitud() { Panel p = new Panel(); codigosOperacion = new Choice(); codop1 = "Crear"; codop2 = "Eliminar"; codop3 = "Leer"; codop4 = "Escribir"; codigosOperacion.add(codop1); codigosOperacion.add(codop2); codigosOperacion.add(codop3); codigosOperacion.add(codop4); campoMensaje = new TextField(10); botonSolicitud = new Button("Solicitar"); botonSolicitud.addActionListener(new ManejadorSolicitud()); p.add(new Label("Operacion:")); p.add(codigosOperacion); p.add(new Label("Datos:")); p.add(campoMensaje); p.add(botonSolicitud); return p; }
public boolean queryOptions(MesquiteModule ownerModule) { MesquiteInteger buttonPressed = new MesquiteInteger(1); ExtensibleDialog dialog = new ExtensibleDialog(ownerModule.containerOfModule(), "Name category to use for sequence names",buttonPressed); //MesquiteTrunk.mesquiteTrunk.containerOfModule() int tagNumber = getTagNumber(chosenNameCategoryTag); Choice categoryChoice = dialog.addPopUpMenu("", nameCategoryDescriptions, tagNumber); dialog.completeAndShowDialog(true); boolean success=(buttonPressed.getValue()== dialog.defaultOK); if (success) { int chosen = categoryChoice.getSelectedIndex(); chosenNameCategoryTag = getCategoryTag(chosen); } dialog.dispose(); return success; }
/** @return Propertydescriptors */ @Override protected PropertyDescriptor[] createPDs() throws IntrospectionException { return new PropertyDescriptor[] { new PropertyDescriptor("selectedObjects", Choice.class, "getSelectedObjects", null), // NOI18N new PropertyDescriptor("selectedIndex", Choice.class, "getSelectedIndex", null), // NOI18N new PropertyDescriptor("itemCount", Choice.class, "getItemCount", null), // NOI18N new PropertyDescriptor("item", Choice.class, "getItem", null), // NOI18N new PropertyDescriptor("selectedItem", Choice.class, "getSelectedItem", null), // NOI18N }; }
private void updateComboBox(Choice certificateComboBox){ certificateComboBox.removeAll(); certificateComboBox.addItem("Loading Certificates..."); certificateComboBox.select(0); ArrayList<CertificateData> certList = new ArrayList<CertificateData>(); try { certList = signEngine.loadSmartCardCertificateList(readAllCertificates).certificateList; } catch (Exception e) { e.printStackTrace(); SignUtils.playBeeps(1); JOptionPane.showMessageDialog(null, "ERROR LOADING CERTIFICATES:\n"+e.getMessage(), "ERROR", JOptionPane.ERROR_MESSAGE); } certificateComboBox.removeAll(); certificateComboBox.addItem("--Select Certificate--"); for(int i=0;i<certList.size();i++) certificateComboBox.addItem(certList.get(i).id); if(certificateComboBox.getItemCount()==1){ certificateComboBox.removeAll(); certificateComboBox.addItem("--No Certificates Available!--"); SignUtils.playBeeps(2); } else{ if(certificateComboBox.getItemCount()==2){ certificateComboBox.remove(0); } SignUtils.playBeeps(1); } }
public DitherControls(DitherTest app, int s, int e, DitherMethod type, boolean vertical) { applet = app; setLayout(dcLayout); add(new Label(vertical ? "Vertical" : "Horizontal")); add(choice = new Choice()); for (DitherMethod m : DitherMethod.values()) { choice.addItem(m.toString().substring(0, 1) + m.toString().substring(1).toLowerCase()); } choice.select(type.ordinal()); add(start = new CardinalTextField(Integer.toString(s), 4)); add(end = new CardinalTextField(Integer.toString(e), 4)); }
@SuppressWarnings("LeakingThisInConstructor") public DrawControls(DrawPanel target) { this.target = target; setLayout(new FlowLayout()); setBackground(Color.lightGray); target.setForeground(Color.red); CheckboxGroup group = new CheckboxGroup(); Checkbox b; add(b = new Checkbox(null, group, false)); b.addItemListener(this); b.setForeground(Color.red); add(b = new Checkbox(null, group, false)); b.addItemListener(this); b.setForeground(Color.green); add(b = new Checkbox(null, group, false)); b.addItemListener(this); b.setForeground(Color.blue); add(b = new Checkbox(null, group, false)); b.addItemListener(this); b.setForeground(Color.pink); add(b = new Checkbox(null, group, false)); b.addItemListener(this); b.setForeground(Color.orange); add(b = new Checkbox(null, group, true)); b.addItemListener(this); b.setForeground(Color.black); target.setForeground(b.getForeground()); Choice shapes = new Choice(); shapes.addItemListener(this); shapes.addItem("Lines"); shapes.addItem("Points"); shapes.setBackground(Color.lightGray); add(shapes); }
@Override public void itemStateChanged(ItemEvent e) { if (e.getSource() instanceof Checkbox) { target.setForeground(((Component) e.getSource()).getForeground()); } else if (e.getSource() instanceof Choice) { String choice = (String) e.getItem(); if (choice.equals("Lines")) { target.setDrawMode(DrawPanel.LINES); } else if (choice.equals("Points")) { target.setDrawMode(DrawPanel.POINTS); } } }
/** * Returns information about component. */ @Override public Hashtable<String, Object> getDump() { Hashtable<String, Object> result = super.getDump(); if (((Choice) getSource()).getSelectedItem() != null) { result.put(SELECTED_ITEM_DPROP, ((Choice) getSource()).getSelectedItem()); } String[] items = new String[((Choice) getSource()).getItemCount()]; for (int i = 0; i < ((Choice) getSource()).getItemCount(); i++) { items[i] = ((Choice) getSource()).getItem(i); } addToDump(result, ITEM_PREFIX_DPROP, items); return result; }
/** * Maps {@code Choice.add(String)} through queue */ public void add(final String item) { runMapping(new MapVoidAction("add") { @Override public void map() { ((Choice) getSource()).add(item); } }); }
/** * Maps {@code Choice.addItemListener(ItemListener)} through queue */ public void addItemListener(final ItemListener itemListener) { runMapping(new MapVoidAction("addItemListener") { @Override public void map() { ((Choice) getSource()).addItemListener(itemListener); } }); }
/** * Maps {@code Choice.getItem(int)} through queue */ public String getItem(final int index) { return (runMapping(new MapAction<String>("getItem") { @Override public String map() { return ((Choice) getSource()).getItem(index); } })); }
/** * Maps {@code Choice.getItemCount()} through queue */ public int getItemCount() { return (runMapping(new MapIntegerAction("getItemCount") { @Override public int map() { return ((Choice) getSource()).getItemCount(); } })); }
/** * Maps {@code Choice.getSelectedIndex()} through queue */ public int getSelectedIndex() { return (runMapping(new MapIntegerAction("getSelectedIndex") { @Override public int map() { return ((Choice) getSource()).getSelectedIndex(); } })); }
/** * Maps {@code Choice.getSelectedItem()} through queue */ public String getSelectedItem() { return (runMapping(new MapAction<String>("getSelectedItem") { @Override public String map() { return ((Choice) getSource()).getSelectedItem(); } })); }
/** * Maps {@code Choice.insert(String)} through queue */ public void insert(final String item, final int index) { runMapping(new MapVoidAction("insert") { @Override public void map() { ((Choice) getSource()).insert(item, index); } }); }
/** * Maps {@code Choice.remove(int)} through queue */ public void remove(final int position) { runMapping(new MapVoidAction("remove") { @Override public void map() { ((Choice) getSource()).remove(position); } }); }
/** * Maps {@code Choice.remove(String)} through queue */ public void remove(final String item) { runMapping(new MapVoidAction("remove") { @Override public void map() { ((Choice) getSource()).remove(item); } }); }
/** * Maps {@code Choice.removeAll()} through queue */ public void removeAll() { runMapping(new MapVoidAction("removeAll") { @Override public void map() { ((Choice) getSource()).removeAll(); } }); }