Java Code Examples for java.awt.event.ItemListener

The following examples show how to use java.awt.event.ItemListener. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
private void readObject(ObjectInputStream s)
  throws ClassNotFoundException, IOException
{
  s.defaultReadObject();

  Object keyOrNull;
  while(null != (keyOrNull = s.readObject())) {
    String key = ((String)keyOrNull).intern();

    if (itemListenerK == key)
      addItemListener((ItemListener)(s.readObject()));

    else // skip value for unrecognized key
      s.readObject();
  }
}
 
Example 2
Source Project: PacketProxy   Source File: GUIOptionListenPortDialog.java    License: Apache License 2.0 6 votes vote down vote up
private JComponent createTypeSetting() {
	type_combo.addItem("HTTP_PROXY");
	type_combo.addItem("FORWARDER");
	type_combo.addItem("SSL_FORWARDER");
	type_combo.addItem("SSL_TRANSPARENT_PROXY");
	type_combo.addItem("HTTP_TRANSPARENT_PROXY");
	type_combo.addItem("UDP_FORWARDER");
	type_combo.setEnabled(true);
	type_combo.setMaximumRowCount(6);
	type_combo.addItemListener(new ItemListener(){
		@Override
		public void itemStateChanged(ItemEvent event) {
			try {
				if (event.getStateChange() != ItemEvent.SELECTED)
					return;
				updateNextHopList((String)event.getItem());
			} catch (Exception e) {
				e.printStackTrace();
			}
		}
	});
	return label_and_object("Type:", type_combo);
}
 
Example 3
Source Project: zap-extensions   Source File: AddPayloadDialog.java    License: Apache License 2.0 6 votes vote down vote up
protected JComboBox<String> getPayloadUIHandlersComboBox() {
    if (payloadUIHandlersComboBox == null) {
        payloadUIHandlersComboBox = new JComboBox<>(new SortedComboBoxModel<String>());
        for (String name : payloadGeneratorsUIHandlers.getPayloadUIHandlersNames()) {
            payloadUIHandlersComboBox.addItem(name);
        }

        payloadUIHandlersComboBox.addItemListener(
                new ItemListener() {

                    @Override
                    public void itemStateChanged(ItemEvent e) {
                        if (ItemEvent.SELECTED == e.getStateChange()) {
                            String panelName = (String) e.getItem();

                            currentPanel = payloadGeneratorsUIHandlers.getPanel(panelName);
                            contentsPanelCardLayout.show(contentsPanel, panelName);

                            setHelpTarget(currentPanel.getHelpTarget());
                        }
                    }
                });
    }
    return payloadUIHandlersComboBox;
}
 
Example 4
private ItemListener changeTitleListener() {
	final ItemListener listener = new ItemListener() {
		
		@Override
		public void itemStateChanged(ItemEvent e) {
			final String title = titleComboBox.getSelectedItem().toString();
			
			if(title.equalsIgnoreCase("Mr")) {
				genderComboBox.setSelectedIndex(0);
				genderComboBox.revalidate();
				genderComboBox.repaint();
			}
			
			else {
				genderComboBox.setSelectedIndex(1);
				genderComboBox.revalidate();
				genderComboBox.repaint();
			}
		}
	};
	return listener;
}
 
Example 5
Source Project: netbeans   Source File: RefreshServiceDialog.java    License: Apache License 2.0 6 votes vote down vote up
private RefreshServiceDialog(boolean downloadWsdl, String implClass, String url) {
    this.downloadWsdl=downloadWsdl;
    this.implClass = implClass;
    this.url=url;
    initComponents();
    // display the delete_wsdl checkbox only if wsdl exists
    if (!downloadWsdl) {
        downloadWsdlCheckBox.setVisible(false);
        jLabel1.setVisible(false);
        jTextField1.setVisible(false);
    } else {
        jTextField1.setText(url);
        downloadWsdlCheckBox.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                if (((javax.swing.JCheckBox)e.getSource()).isSelected())
                    jTextField1.setEditable(true);
                else 
                    jTextField1.setEditable(false);
            }

        });            
    }
}
 
Example 6
Source Project: ghidra   Source File: MemSearchDialog.java    License: Apache License 2.0 6 votes vote down vote up
private Container buildCodeUnitTypesPanel() {
	final JCheckBox instructionsCheckBox = new GCheckBox("Instructions", true);
	final JCheckBox definedCheckBox = new GCheckBox("Defined Data", true);
	final JCheckBox undefinedCheckBox = new GCheckBox("Undefined Data", true);

	ItemListener stateListener = e -> validate();

	codeUnitTypesList = new ArrayList<>();
	codeUnitTypesList.add(instructionsCheckBox);
	codeUnitTypesList.add(definedCheckBox);
	codeUnitTypesList.add(undefinedCheckBox);

	instructionsCheckBox.addItemListener(stateListener);
	definedCheckBox.addItemListener(stateListener);
	undefinedCheckBox.addItemListener(stateListener);

	JPanel codeUnitTypePanel = new JPanel();
	codeUnitTypePanel.setLayout(new BoxLayout(codeUnitTypePanel, BoxLayout.Y_AXIS));
	codeUnitTypePanel.add(instructionsCheckBox);
	codeUnitTypePanel.add(definedCheckBox);
	codeUnitTypePanel.add(undefinedCheckBox);
	codeUnitTypePanel.setBorder(BorderFactory.createTitledBorder(CODE_UNIT_SCOPE_NAME));

	return codeUnitTypePanel;
}
 
Example 7
Source Project: netbeans   Source File: NbEditorKit.java    License: Apache License 2.0 6 votes vote down vote up
public @Override JMenuItem getPopupMenuItem(JTextComponent target) {
    Preferences prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    boolean toolbarVisible = prefs.getBoolean(SimpleValueNames.TOOLBAR_VISIBLE_PROP, EditorPreferencesDefaults.defaultToolbarVisible);
    
    JCheckBoxMenuItem item = new JCheckBoxMenuItem(
        NbBundle.getBundle(ToggleToolbarAction.class).getString("PROP_base_toolbarVisible"), //NOI18N
        toolbarVisible);
    
    item.addItemListener( new ItemListener() {
        public @Override void itemStateChanged(ItemEvent e) {
            actionPerformed(null,null);
        }
    });
    
    return item;
}
 
Example 8
Source Project: ghidra   Source File: SymbolTypeFilter.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected void createCheckBoxInfos() {
	ItemListener listener = new ItemListener() {
		@Override
		public void itemStateChanged(ItemEvent e) {
			fireStatusChanged(getFilterStatus());
		}
	};

	SourceType[] values = SourceType.values();
	for (SourceType type : values) {
		GCheckBox checkBox = new GCheckBox(type.getDisplayString(), true);
		checkBox.addItemListener(listener);
		CheckBoxInfo<VTMatch> info = new SymbolTypeCheckBoxInfo(checkBox, type);
		checkBoxInfos.add(info);
	}

	GCheckBox nullSymbolCheckbox = new GCheckBox("<No Symbol>", true);
	nullSymbolCheckbox.addItemListener(listener);
	checkBoxInfos.add(new NullSymbolCheckBoxInfo(nullSymbolCheckbox));
}
 
Example 9
Source Project: arcusplatform   Source File: ComboBoxBuilder.java    License: Apache License 2.0 6 votes vote down vote up
public JComboBox<T> create() {
   JComboBox<T> combo = new JComboBox<T>(model);
   combo.setEditable(editable);
   if(listRenderer != null) {
      combo.setRenderer(listRenderer);
   }
   if(editable && editor != null) {
      combo.setEditor(editor);
   }
   if(listeners != null) {
      final List<Listener<? super T>> l = ImmutableList.copyOf(listeners);
      combo.addItemListener(new ItemListener() {

         @Override
         public void itemStateChanged(ItemEvent e) {
            if(e.getStateChange() == ItemEvent.SELECTED) {
               for(Listener<? super T> listener: l) {
                  listener.onEvent((T) e.getItem());
               }
            }
         }
      });
   }
   return combo;
}
 
Example 10
Source Project: netbeans   Source File: RefreshWsDialog.java    License: Apache License 2.0 6 votes vote down vote up
private RefreshWsDialog(boolean downloadWsdl, String implClass, String url) {
    this.downloadWsdl=downloadWsdl;
    this.implClass = implClass;
    this.url=url;
    initComponents();
    // display the delete_wsdl checkbox only if wsdl exists
    if (!downloadWsdl) {
        downloadWsdlCheckBox.setVisible(false);
        jLabel1.setVisible(false);
        jTextField1.setVisible(false);
    } else {
        jTextField1.setText(url);
        downloadWsdlCheckBox.addItemListener(new ItemListener() {

            public void itemStateChanged(ItemEvent e) {
                if (((javax.swing.JCheckBox)e.getSource()).isSelected())
                    jTextField1.setEditable(true);
                else 
                    jTextField1.setEditable(false);
            }

        });            
    }
}
 
Example 11
Source Project: netbeans   Source File: StatisticsPanel.java    License: Apache License 2.0 6 votes vote down vote up
private JToggleButton newOptionButton(Icon icon, String tooltip, String accessibleName, final String property) {
JToggleButton newButton = new JToggleButton(icon);
newButton.setToolTipText(tooltip);
newButton.getAccessibleContext().setAccessibleName(accessibleName);
boolean isSelected = NbPreferences.forModule(StatisticsPanel.class).getBoolean(property, false);
newButton.setSelected(isSelected);
newButton.addItemListener(new ItemListener() {
    @Override
    public void itemStateChanged(ItemEvent e) {
	boolean selected;
	switch (e.getStateChange()) {
	    case ItemEvent.SELECTED:
		selected = true;
		break;
	    case ItemEvent.DESELECTED:
		selected = false;
		break;
	    default:
		return;
	}
	ResultWindow.getInstance().updateOptionStatus(property, selected);
    }
});
return newButton;
   }
 
Example 12
Source Project: Ardulink-2   Source File: ConnectionPanel.java    License: Apache License 2.0 6 votes vote down vote up
private JComboBox createURICombo() {
	JComboBox uris = new JComboBox();
	uris.setRenderer(new DefaultListCellRenderer() {

		private static final long serialVersionUID = 2756587449741341859L;

		@Override
		public Component getListCellRendererComponent(JList list,
				Object value, int index, boolean isSelected,
				boolean cellHasFocus) {
			return value == null ? null : super.getListCellRendererComponent(list,
					extractNameFromURI(URIs.newURI((String) value)), index,
					isSelected, cellHasFocus);
		}
	});
	uris.addItemListener(new ItemListener() {
		@Override
		public void itemStateChanged(ItemEvent event) {
			if (event.getStateChange() == SELECTED) {
				replaceSubpanel();
			}
		}
	});
	return uris;
}
 
Example 13
Source Project: netbeans   Source File: CodeSnifferOptionsPanel.java    License: Apache License 2.0 6 votes vote down vote up
@NbBundle.Messages({
    "# {0} - short script name",
    "# {1} - long script name",
    "CodeSnifferOptionsPanel.hint=Full path of Code Sniffer script (typically {0} or {1}).",
})
private void initCodeSniffer(DocumentListener defaultDocumentListener) {
    codeSnifferHintLabel.setText(Bundle.CodeSnifferOptionsPanel_hint(CodeSniffer.NAME, CodeSniffer.LONG_NAME));
    codeSnifferStandardComboBox.setModel(codeSnifferStandardsModel);

    // listeners
    codeSnifferTextField.getDocument().addDocumentListener(defaultDocumentListener);
    codeSnifferTextField.getDocument().addDocumentListener(new CodeSnifferPathDocumentListener());
    final ItemListener defaultItemListener = new DefaultItemListener();
    codeSnifferStandardsModel.fetchStandards(codeSnifferStandardComboBox, new Runnable() {
        @Override
        public void run() {
            // #232279
            codeSnifferStandardComboBox.addItemListener(defaultItemListener);
        }
    });
}
 
Example 14
public FlutterLogFilterPanel(@NotNull OnFilterListener onFilterListener) {
  this.onFilterListener = onFilterListener;
  final ItemListener listener = e -> doFilter();
  matchCaseCheckBox.addItemListener(listener);
  regexCheckBox.addItemListener(listener);
  final List<FlutterLog.Level> logLevels = Arrays.stream(FlutterLog.Level.values())
    .collect(Collectors.toList());
  logLevelComboBox.setModel(new CollectionComboBoxModel<>(logLevels));
  logLevelComboBox.setSelectedItem(FlutterLog.Level.NONE);
  logLevelComboBox.addActionListener(event -> doFilter());
  logLevelComboBox.setRenderer(new ColoredListCellRenderer<FlutterLog.Level>() {
    @Override
    protected void customizeCellRenderer(@NotNull JList<? extends FlutterLog.Level> list,
                                         FlutterLog.Level value,
                                         int index,
                                         boolean selected,
                                         boolean hasFocus) {
      // When NONE is selected, show an empty string in the combo selector.
      final String label = index == -1 && value == FlutterLog.Level.NONE ? "" : value.toDisplayString();
      append(label);
    }
  });
}
 
Example 15
private ItemListener createItemListener(final JTextField filePathTextField, final JComboBox<String> fileFormatCBox) {
    return new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            final String fp = filePathTextField.getText();
            if(!fp.isEmpty()) {
                if(fp.endsWith("\\") || fp.endsWith("/")) {
                    filePathTextField.setText(fp + "results." + moduleExtensions[fileFormatCBox.getSelectedIndex()]);
                } else {
                    SwingUtilities.invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            int dotpos = fp.lastIndexOf('.');
                            if(dotpos > 0) {
                                filePathTextField.setText(fp.substring(0, dotpos + 1) + moduleExtensions[fileFormatCBox.getSelectedIndex()]);
                            }
                        }
                    });
                }
            }
        }
    };
}
 
Example 16
Source Project: logviewer   Source File: ConfigureLogcatFormatDialog.java    License: Apache License 2.0 6 votes vote down vote up
public ConfigureLogcatFormatDialog(Project project) {
    super(project, false, IdeModalityType.PROJECT);
    init();
    setTitle(AndroidBundle.message("android.configure.logcat.header.title"));
    myPreferences = AndroidLogcatPreferences.getInstance(project);

    myFormatString = myPreferences.LOGCAT_FORMAT_STRING;
    myShowTimeCheckBox.setSelected(myFormatString.isEmpty() || myFormatString.contains("%1$s"));
    myShowPidTidCheckBox.setSelected(myFormatString.isEmpty() || myFormatString.contains("%2$s"));
    myShowPackageNameCheckBox.setSelected(myFormatString.isEmpty() || myFormatString.contains("%3$s"));
    myShowTag.setSelected(myFormatString.isEmpty() || myFormatString.contains("%5$s"));

    ItemListener checkboxListener = new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            rebuildFormatString();
        }
    };
    myShowTimeCheckBox.addItemListener(checkboxListener);
    myShowPidTidCheckBox.addItemListener(checkboxListener);
    myShowPackageNameCheckBox.addItemListener(checkboxListener);
    myShowTag.addItemListener(checkboxListener);

    updateDemoLabel();
}
 
Example 17
Source Project: darklaf   Source File: UIManagerDefaults.java    License: MIT License 5 votes vote down vote up
private JComponent createSelectionPanel() {
    comboBox = new JComboBox<>();

    final JLabel label = new JLabel("Select Item:");
    label.setDisplayedMnemonic('S');
    label.setLabelFor(comboBox);

    ItemListener itemListener = e -> {
        selectedItem = null;
        if (table.isEditing()) {
            table.getCellEditor().stopCellEditing();
        }
        table.clearSelection();
        resetComponents();
    };

    byComponent = new JRadioButton("By Component", true);
    byComponent.setMnemonic('C');
    byComponent.addItemListener(itemListener);

    final JRadioButton byValueType = new JRadioButton("By Value Type");
    byValueType.setMnemonic('V');
    byValueType.addItemListener(itemListener);

    final ButtonGroup group = new ButtonGroup();
    group.add(byComponent);
    group.add(byValueType);

    final JPanel panel = new JPanel();
    panel.setBorder(new EmptyBorder(15, 0, 15, 0));
    panel.add(label);
    panel.add(comboBox);
    panel.add(byComponent);
    panel.add(byValueType);
    return panel;
}
 
Example 18
Source Project: consulo   Source File: ArrangementComboBoxUiComponent.java    License: Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
public ArrangementComboBoxUiComponent(@Nonnull List<ArrangementSettingsToken> tokens) {
  super(tokens);
  ArrangementSettingsToken[] tokensArray = tokens.toArray(new ArrangementSettingsToken[tokens.size()]);
  Arrays.sort(tokensArray, new Comparator<ArrangementSettingsToken>() {
    @Override
    public int compare(ArrangementSettingsToken t1, ArrangementSettingsToken t2) {
      return t1.getRepresentationValue().compareTo(t2.getRepresentationValue());
    }
  });
  myComboBox = new JComboBox(tokensArray);
  myComboBox.setRenderer(new ListCellRendererWrapper() {
    @Override
    public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
      setText(((ArrangementSettingsToken)value).getRepresentationValue());
    }
  });
  myComboBox.addItemListener(new ItemListener() {
    @Override
    public void itemStateChanged(ItemEvent e) {
      if (e.getStateChange() == ItemEvent.SELECTED) {
        fireStateChanged();
      }
    }
  });
  int minWidth = 0;
  ListCellRenderer renderer = myComboBox.getRenderer();
  JBList dummyList = new JBList();
  for (int i = 0, max = myComboBox.getItemCount(); i < max; i++) {
    Component rendererComponent = renderer.getListCellRendererComponent(dummyList, myComboBox.getItemAt(i), i, false, true);
    minWidth = Math.max(minWidth, rendererComponent.getPreferredSize().width);
  }
  myComboBox.setPreferredSize(new Dimension(minWidth * 5 / 3, myComboBox.getPreferredSize().height));
}
 
Example 19
Source Project: netbeans   Source File: DefaultSuiteProjectDeletePanel.java    License: Apache License 2.0 5 votes vote down vote up
private void attachListeners() {
    this.deleteModulesCheckBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if(deleteModulesCheckBox.isSelected() && hasSourcesToDelete) {
                deleteSourcesCheckBox.setEnabled(true);
            }
            else {
                deleteSourcesCheckBox.setEnabled(false);
            }
        }

    });
}
 
Example 20
Source Project: gcs   Source File: PreferencePanel.java    License: Mozilla Public License 2.0 5 votes vote down vote up
/**
 * Creates a {@link JCheckBox} suitable for use within the preference panel.
 *
 * @param title   The title to use.
 * @param tooltip The tooltip to use.
 * @param checked Whether the initial state should be checked.
 * @return The newly created {@link JCheckBox}.
 */
protected JCheckBox createCheckBox(String title, String tooltip, boolean checked) {
    JCheckBox checkbox = new JCheckBox(title, checked);
    checkbox.setOpaque(false);
    checkbox.setToolTipText(Text.wrapPlainTextForToolTip(tooltip));
    if (this instanceof ItemListener) {
        checkbox.addItemListener((ItemListener) this);
    }
    add(checkbox);
    return checkbox;
}
 
Example 21
Source Project: ghidra   Source File: MultiFunctionComparisonPanel.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Creates the panel displaying the source combo box
 * <p>
 * Note: The custom renderer is used so the name of the program associated
 * with each function can be displayed in the combo box; this is necessary
 * since a combo box may show functions from any number of programs, and
 * the default is to simply show the function name<br>
 * eg: "init (notepad)"<br>
 * 
 * @return the source panel
 */
private JPanel createSourcePanel() {
	JPanel panel = new JPanel(new BorderLayout());
	sourceFunctionsCB = new JComboBox<>();
	sourceFunctionsCBModel = new DefaultComboBoxModel<>();
	sourceFunctionsCB.setModel(sourceFunctionsCBModel);
	sourceFunctionsCB.setRenderer(new FunctionListCellRenderer());
	sourceFunctionsCB.addItemListener(new ItemListener() {
		@Override
		public void itemStateChanged(ItemEvent e) {
			if (e.getStateChange() != ItemEvent.SELECTED) {
				return;
			}

			Function selected = (Function) sourceFunctionsCBModel.getSelectedItem();
			loadFunctions(selected, null);

			// Each time a source function is selected we need
			// to load the targets associated with it
			reloadTargetList((Function) sourceFunctionsCBModel.getSelectedItem());

			updateTabText();

			// Fire a notification to update the UI state; without this the 
			// actions would not be properly enabled/disabled
			tool.contextChanged(provider);
		}
	});

	panel.add(sourceFunctionsCB, BorderLayout.CENTER);
	return panel;
}
 
Example 22
Source Project: nextreports-designer   Source File: SQLViewPanel.java    License: Apache License 2.0 5 votes vote down vote up
private JPanel createMaxRowsPanel() {

            JPanel maxRowsPanel = new JPanel();
            double[] columns = {
                    TableLayoutConstants.PREFERRED,
                    3,
                    TableLayoutConstants.PREFERRED
            };

            double[] rows = {
                    TableLayoutConstants.PREFERRED,
            };

            TableLayout layout = new TableLayout(columns, rows);
            maxRowsPanel.setLayout(layout);

            maxRowsCheckBox = new JCheckBox(I18NSupport.getString("max.rows"));
            maxRowsCheckBox.addItemListener(new ItemListener() {

                public void itemStateChanged(ItemEvent e) {
                    if (e.getStateChange() == ItemEvent.SELECTED) {
                        maxRowsTextField.setEditable(true);
                    } else {
                        maxRowsTextField.setEditable(false);
                    }
                }

            });
            maxRowsPanel.add(maxRowsCheckBox, "0, 0");

            maxRowsTextField = new IntegerTextField();
            maxRowsTextField.setText("500");
            maxRowsTextField.setColumns(7);
            maxRowsPanel.add(maxRowsTextField, "2, 0");

            // enable max rows feature
            enableMaxCheck();
            return maxRowsPanel;
        }
 
Example 23
/**
 * Maps {@code Checkbox.removeItemListener(ItemListener)} through queue
 */
public void removeItemListener(final ItemListener itemListener) {
    runMapping(new MapVoidAction("removeItemListener") {
        @Override
        public void map() {
            ((Checkbox) getSource()).removeItemListener(itemListener);
        }
    });
}
 
Example 24
Source Project: openjdk-jdk9   Source File: ChoiceOperator.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * Maps {@code Choice.removeItemListener(ItemListener)} through queue
 */
public void removeItemListener(final ItemListener itemListener) {
    runMapping(new MapVoidAction("removeItemListener") {
        @Override
        public void map() {
            ((Choice) getSource()).removeItemListener(itemListener);
        }
    });
}
 
Example 25
Source Project: netbeans   Source File: SmartyCustomizerPanel.java    License: Apache License 2.0 5 votes vote down vote up
private void init() {
    enabledCheckBox.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            setFieldsEnabled(e.getStateChange() == ItemEvent.SELECTED);
        }
    });
    setFieldsEnabled(enabledCheckBox.isSelected());
}
 
Example 26
public CreateTraitDialog(final BeautiFrame frame) {
        this.frame = frame;

        nameField = new JTextField("untitled_trait");
        nameField.setColumns(20);

//        nameCombo = new JComboBox(TraitData.Traits.values());
        typeCombo = new JComboBox(TraitData.TraitType.values());

        optionPanel = new OptionsPanel(12, 12);

        ButtonGroup group = new ButtonGroup();
        group.add(createRadio);
        group.add(importRadio);
        ItemListener listener = new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                nameField.setEnabled(createRadio.isSelected());
                typeCombo.setEnabled(createRadio.isSelected());
                exampleButton.setEnabled(importRadio.isSelected());
            }
        };
        createRadio.addItemListener(listener);
        importRadio.addItemListener(listener);

        exampleButton.setEnabled(false);
        exampleButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent ae) {
                JScrollPane scrollPane = TextUtil.createHTMLScrollPane(EXAMPLE_FORMAT, new Dimension(400,300));

                JOptionPane.showMessageDialog(frame, scrollPane,
                        "Example of mapping file format",
                        JOptionPane.PLAIN_MESSAGE);
            }
        });
    }
 
Example 27
Source Project: consulo   Source File: MultipleChangeListBrowser.java    License: Apache License 2.0 5 votes vote down vote up
public ChangeListChooser() {
  super(new BorderLayout(4, 2));
  myChooser = new ComboBox();
  //noinspection unchecked
  myChooser.setRenderer(new ColoredListCellRendererWrapper<LocalChangeList>() {
    @Override
    protected void doCustomize(JList list, LocalChangeList value, int index, boolean selected, boolean hasFocus) {
      if (value != null) {
        String name = StringUtil.shortenTextWithEllipsis(value.getName().trim(), MAX_LEN, 0);

        append(name, value.isDefault() ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES);
      }
    }
  });

  myChooser.addItemListener(new ItemListener() {
    public void itemStateChanged(ItemEvent e) {
      if (e.getStateChange() == ItemEvent.SELECTED) {
        final LocalChangeList changeList = (LocalChangeList)myChooser.getSelectedItem();
        setSelectedList(changeList);
        myChooser.setToolTipText(changeList == null ? "" : (changeList.getName()));
      }
    }
  });

  myChooser.setEditable(false);
  add(myChooser, BorderLayout.CENTER);

  JLabel label = new JLabel(VcsBundle.message("commit.dialog.changelist.label"));
  label.setLabelFor(myChooser);
  add(label, BorderLayout.WEST);
}
 
Example 28
Source Project: ghidra   Source File: ArrayElementPropertyEditor.java    License: Apache License 2.0 5 votes vote down vote up
private Component buildEditor() {
	// we want to have a panel with our options so that we may group them together
	JPanel panel = new JPanel(new VerticalLayout(3));

	// the namespace checkbox will disable the text field options when it is not used
	groupElementsCheckBox = new GCheckBox(SHOW_MULTI_ELEMENTS_LABEL);
	groupElementsCheckBox.setSelected(true);
	groupElementsCheckBox.setToolTipText(SHOW_MULTI_ELEMENTS_TOOLTIP);

	panel.add(groupElementsCheckBox);

	elementsPerLineField =
		createLocalPrefixTextField(GROUP_SIZE_LABEL, GROUP_SIZE_LABEL_TOOLTIP, panel);
	elementsLabel.setToolTipText(GROUP_SIZE_LABEL_TOOLTIP);

	groupElementsCheckBox.addItemListener(new ItemListener() {
		@Override
		public void itemStateChanged(ItemEvent e) {
			boolean enabled = groupElementsCheckBox.isSelected();
			// only enable the text field if we are showing namespaces AND we are 
			// overriding the display value
			elementsPerLineField.setEnabled(enabled);
			elementsLabel.setEnabled(enabled);
			firePropertyChange();
		}
	});
	panel.setBorder(BorderFactory.createCompoundBorder(
		BorderFactory.createEmptyBorder(10, 0, 10, 0), new TitledBorder("Grouping")));

	return panel;
}
 
Example 29
private void addComboBoxListener(JComboBox<Integer> comboBox, int numberOfOwnedBuildings, JLabel buildingIncome) {
	comboBox.addItemListener(new ItemListener() {
		
		@Override
		public void itemStateChanged(ItemEvent e) {
			buildingIncome.setText(Integer.toString(numberOfOwnedBuildings * (Integer)comboBox.getSelectedItem()));				
		}
	});
	buildingIncome.setText(Integer.toString(numberOfOwnedBuildings * (Integer)comboBox.getSelectedItem()));
}
 
Example 30
Source Project: astor   Source File: AgeCalculator.java    License: GNU General Public License v2.0 5 votes vote down vote up
FieldGroup(ItemListener listener, String checkboxText, int fieldType) {
    iCheckbox = new JCheckBox(checkboxText, true);
    iCheckbox.addItemListener(listener);
    iResult = new JTextField();
    iResult.setEditable(false);
    iFieldType = fieldType;
}