Java Examples for javax.swing.ComboBoxModel
The following java examples will help you to understand the usage of javax.swing.ComboBoxModel. These source code samples are taken from different open source projects.
Example 1
| Project: codjo-standalone-common-master File: LinkTableDetailWindow.java View source code |
/**
* Overview.
*
* <p>
* Description
* </p>
*
* @param table Description of Parameter
* @param comboBox Description of Parameter
*/
private void fillComboFields(Table table, JComboBox comboBox) {
try {
FieldNameRenderer fieldNameRenderer = new FieldNameRenderer(cm, table.getDBTableName());
Map m = table.getAllColumns();
Object[] o = m.keySet().toArray();
Arrays.sort(o, new net.codjo.gui.renderer.FieldLabelComparator(cm, table.getDBTableName()));
ComboBoxModel c = new DefaultComboBoxModel(o);
comboBox.setModel(c);
comboBox.setRenderer(fieldNameRenderer);
} catch (Exception ex) {
ex.printStackTrace();
}
}Example 2
| Project: eXist-1.4.x-master File: AbstractPolicyEditor.java View source code |
protected ComboBoxModel getComboModel() {
boolean isPolicy = node instanceof PolicyNode;
DefaultComboBoxModel model = new DefaultComboBoxModel();
Set algorithms = StandardCombiningAlgFactory.getFactory().getStandardAlgorithms();
for (Iterator it = algorithms.iterator(); it.hasNext(); ) {
CombiningAlgorithm algorithm = (CombiningAlgorithm) it.next();
if (isPolicy) {
if (algorithm instanceof RuleCombiningAlgorithm) {
String abbreviatedID = abbrev.getAbbreviatedCombiningID(algorithm.getIdentifier());
model.addElement(abbreviatedID);
}
} else if (algorithm instanceof PolicyCombiningAlgorithm) {
String abbreviatedID = abbrev.getAbbreviatedCombiningID(algorithm.getIdentifier());
model.addElement(abbreviatedID);
}
}
return model;
}Example 3
| Project: jtheque-core-master File: AtLeastOneConstraint.java View source code |
@Override
public void validate(Object field, Collection<org.jtheque.errors.Error> errors) {
int count = 0;
if (field instanceof ItemSelectable) {
count = ((ItemSelectable) field).getSelectedObjects().length;
} else if (field instanceof ComboBoxModel) {
count = ((ComboBoxModel) field).getSelectedItem() == null ? 0 : 1;
} else if (field instanceof JList) {
count = ((JList) field).getSelectedValues().length;
}
if (count <= 0) {
errors.add(Errors.newI18nError("error.validation.field.empty", new Object[] { getFieldName() }));
}
}Example 4
| Project: megameklab-master File: EquipmentListCellKeySelectionManager.java View source code |
public int selectionForKey(char aKey, @SuppressWarnings("rawtypes") ComboBoxModel aModel) {
int i, c;
int currentSelection = -1;
Object selectedItem = aModel.getSelectedItem();
if (selectedItem != null) {
String selectedText = ((EquipmentType) selectedItem).getName();
String v;
String pattern;
for (i = 0, c = aModel.getSize(); i < c; i++) {
if (selectedText.equals(((EquipmentType) aModel.getElementAt(i)).getName())) {
currentSelection = i;
break;
}
}
pattern = ("" + aKey).toLowerCase();
aKey = pattern.charAt(0);
for (i = ++currentSelection, c = aModel.getSize(); i < c; i++) {
Object elem = aModel.getElementAt(i);
if ((elem != null) && (elem.toString() != null)) {
v = ((EquipmentType) elem).getName().toLowerCase();
if ((v.length() > 0) && (v.charAt(0) == aKey)) {
return i;
}
}
}
for (i = 0; i < currentSelection; i++) {
Object elem = aModel.getElementAt(i);
if ((elem != null) && (elem.toString() != null)) {
v = ((EquipmentType) elem).getName().toLowerCase();
if ((v.length() > 0) && (v.charAt(0) == aKey)) {
return i;
}
}
}
}
return -1;
}Example 5
| Project: SwingLibrary-master File: TestApplication.java View source code |
@Override
public void actionPerformed(ActionEvent event) {
if (event.getActionCommand().equals("comboBoxChanged")) {
String selected = (String) getSelectedItem();
List<String> items = new ArrayList<String>();
if (!selected.equals(REMOVABLE_ITEM))
items.add(selected);
ComboBoxModel model = getModel();
for (int i = 0, size = model.getSize(); i < size; i++) {
String item = (String) model.getElementAt(i);
if (!item.equals(selected))
items.add(item);
}
setModel(new DefaultComboBoxModel(items.toArray()));
setSelectedIndex(0);
}
}Example 6
| Project: Desktop-master File: AssignAttributeDialog.java View source code |
private void attributesChanged() {
final MapModel map = Controller.getCurrentController().getMap();
final AttributeRegistry attributes = AttributeRegistry.getRegistry(map);
final ComboBoxModel names = attributes.getComboBoxModel();
attributeNames.setModel(new ClonedComboBoxModel(names));
attributeNames.setEditable(!attributes.isRestricted());
replacingAttributeNames.setModel(new ClonedComboBoxModel(names));
replacingAttributeNames.setEditable(!attributes.isRestricted());
if (attributes.size() > 0) {
final Object first = names.getElementAt(0);
attributeNames.setSelectedItem(first);
replacingAttributeNames.setSelectedItem(first);
selectedAttributeChanged(attributeNames.getSelectedItem(), attributeValues);
selectedAttributeChanged(replacingAttributeNames.getSelectedItem(), replacingAttributeValues);
} else {
attributeValues.setModel(new DefaultComboBoxModel());
attributeValues.setEditable(false);
replacingAttributeValues.setModel(new DefaultComboBoxModel());
replacingAttributeValues.setEditable(false);
}
}Example 7
| Project: Docear-master File: AssignAttributeDialog.java View source code |
private void attributesChanged() {
final MapModel map = Controller.getCurrentController().getMap();
final AttributeRegistry attributes = AttributeRegistry.getRegistry(map);
final ComboBoxModel names = attributes.getComboBoxModel();
attributeNames.setModel(new ClonedComboBoxModel(names));
attributeNames.setEditable(!attributes.isRestricted());
replacingAttributeNames.setModel(new ClonedComboBoxModel(names));
replacingAttributeNames.setEditable(!attributes.isRestricted());
if (attributes.size() > 0) {
final Object first = names.getElementAt(0);
attributeNames.setSelectedItem(first);
replacingAttributeNames.setSelectedItem(first);
selectedAttributeChanged(attributeNames.getSelectedItem(), attributeValues);
selectedAttributeChanged(replacingAttributeNames.getSelectedItem(), replacingAttributeValues);
} else {
attributeValues.setModel(new DefaultComboBoxModel());
attributeValues.setEditable(false);
replacingAttributeValues.setModel(new DefaultComboBoxModel());
replacingAttributeValues.setEditable(false);
}
}Example 8
| Project: geotools-tike-master File: AuthorityCodesComboBox.java View source code |
/**
* Display only the CRS name that contains the specified keywords. The {@code keywords}
* argument is a space-separated list, usually provided by the user after he pressed the
* "Search" button.
*
* @param keywords space-separated list of keywords to look for.
*/
public void filter(String keywords) {
ComboBoxModel model = codeList;
if (keywords != null) {
final Locale locale = SwingUtilities.getLocale(this);
keywords = keywords.toLowerCase(locale).trim();
final String[] tokens = keywords.split("\\s+");
if (tokens.length != 0) {
final DefaultComboBoxModel filtered;
model = filtered = new DefaultComboBoxModel();
final int size = codeList.getSize();
scan: for (int i = 0; i < size; i++) {
final Code code = (Code) codeList.getElementAt(i);
final String name = code.toString().toLowerCase(locale);
for (int j = 0; j < tokens.length; j++) {
if (name.indexOf(tokens[j]) < 0) {
continue scan;
}
}
filtered.addElement(code);
}
}
}
list.setModel(model);
}Example 9
| Project: languagetool-master File: LanguageComboBox.java View source code |
void selectLanguage(Language language) {
ComboBoxModel<LanguageAdapter> model = getModel();
for (int i = 0; i < model.getSize(); i++) {
LanguageAdapter adapter = model.getElementAt(i);
if (adapter.getLanguage() == null) {
continue;
}
if (adapter.getLanguage().toString().equals(language.toString())) {
setSelectedItem(adapter);
break;
}
}
}Example 10
| Project: nextreports-designer-master File: HistoryComboBox.java View source code |
public void load(String fileName) {
// for now I deserialize the combo model from a file
try {
if (getItemCount() > 0) {
removeAllItems();
}
File file = new File(fileName);
if (!file.exists()) {
return;
}
FileInputStream fileStream = new FileInputStream(file);
ObjectInputStream objectStream = new ObjectInputStream(fileStream);
Object object = objectStream.readObject();
if (object instanceof ComboBoxModel) {
setModel((ComboBoxModel) object);
}
objectStream.close();
fileStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}Example 11
| Project: robocode-master File: ComboBoxUtil.java View source code |
public static void setSelected(JComboBox comboBox, FontStyle fontStyle) {
ComboBoxModel model = comboBox.getModel();
for (int i = 0; i < model.getSize(); i++) {
String name = (String) model.getElementAt(i);
FontStyle style = FontStyle.fromName(name);
if (style != null && style == fontStyle) {
model.setSelectedItem(name);
break;
}
}
}Example 12
| Project: swingx-master File: XListDemo.java View source code |
private ComboBoxModel createRolloverHighlighters() {
DefaultComboBoxModel model = new DefaultComboBoxModel();
// <snip> JXList rollover support
// simple decorations of rollover row
model.addElement(new DisplayInfo<Highlighter>("Background Color", new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, Color.MAGENTA, null)));
model.addElement(new DisplayInfo<Highlighter>("Foreground Color", new ColorHighlighter(HighlightPredicate.ROLLOVER_ROW, null, Color.MAGENTA)));
// </snip>
model.addElement(new DisplayInfo<Highlighter>("Related Merit", createExtendedRolloverDecoration()));
return model;
}Example 13
| Project: zaproxy-master File: ContextSelectComboBox.java View source code |
/**
* Reloads/refreshes the list of {@link Context Contexts} from the {@link Session}.
*
* @param keepSelected whether the previously selected context is tried to be restored. If
* {@code false}, defaults to no selection.
*/
public void reloadContexts(boolean keepSelected) {
Context selected = null;
if (keepSelected)
selected = (Context) getSelectedItem();
List<Context> contexts = Model.getSingleton().getSession().getContexts();
Context[] contextsArray = contexts.toArray(new Context[contexts.size()]);
ComboBoxModel<Context> model = new DefaultComboBoxModel<>(contextsArray);
// No matter what, set selected item, so it either defaults to 'nothing selected' or
// restores the previously selected item
model.setSelectedItem(selected);
this.setModel(model);
}Example 14
| Project: cids-custom-switchon-master File: CreateNewTagAction.java View source code |
/**
* DOCUMENT ME!
*
* @return DOCUMENT ME!
*
* @throws Exception DOCUMENT ME!
*/
private CidsBean getTaggroupOfCombobox() throws Exception {
final ComboBoxModel model = combo.getModel();
CidsBean tag = null;
for (int i = 0; i < model.getSize(); i++) {
final Object element = model.getElementAt(i);
if (element instanceof CidsBean) {
tag = (CidsBean) element;
break;
} else if (element instanceof MetaObject) {
tag = ((MetaObject) element).getBean();
break;
}
}
if (tag != null) {
return (CidsBean) tag.getProperty("taggroup");
} else {
throw new Exception("Taggroup could not be determined.");
}
}Example 15
| Project: eclipselink.runtime-master File: AbstractRdbmsLoginPane.java View source code |
private ComboBoxModel buildLookupTypeComboModel() {
LookupType string = new LookupType(resourceRepository().getString("CONNECTION_RDBMS_LOOKUP_TYPE_STRING_CHOICE"), new Integer(JNDIConnector.STRING_LOOKUP));
LookupType compound = new LookupType(resourceRepository().getString("CONNECTION_RDBMS_LOOKUP_TYPE_COMPOUND_NAME_CHOICE"), new Integer(JNDIConnector.COMPOUND_NAME_LOOKUP));
LookupType composite = new LookupType(resourceRepository().getString("CONNECTION_RDBMS_LOOKUP_TYPE_COMPOSITE_NAME_CHOICE"), new Integer(JNDIConnector.COMPOSITE_NAME_LOOKUP));
List lookupTypes = new Vector(3);
lookupTypes.add(string);
lookupTypes.add(compound);
lookupTypes.add(composite);
CollectionTools.sort(lookupTypes, buildLookupTypeComparator());
return new ComboBoxModelAdapter(buildLookupTypeCollectionHolder(lookupTypes), buildLookupTypeHolder(lookupTypes));
}Example 16
| Project: japura-gui-master File: PriorityComboBox.java View source code |
@Override
public int selectionForKey(char aKey, ComboBoxModel aModel) {
PriorityComboBoxModel model = (PriorityComboBoxModel) aModel;
int i, c;
int currentSelection = -1;
Object selectedItem = aModel.getSelectedItem();
String v;
String pattern;
if (selectedItem != null) {
for (i = 0, c = aModel.getSize(); i < c; i++) {
if (selectedItem == aModel.getElementAt(i) && i > model.getPriorityItemsSize()) {
currentSelection = i;
break;
}
}
}
pattern = ("" + aKey).toLowerCase();
aKey = pattern.charAt(0);
for (i = ++currentSelection, c = aModel.getSize(); i < c; i++) {
Object elem = aModel.getElementAt(i);
if (elem != null && elem.toString() != null) {
v = elem.toString().toLowerCase();
if (v.length() > 0 && v.charAt(0) == aKey && i > model.getPriorityItemsSize())
return i;
}
}
for (i = 0; i < currentSelection; i++) {
Object elem = aModel.getElementAt(i);
if (elem != null && elem.toString() != null) {
v = elem.toString().toLowerCase();
if (v.length() > 0 && v.charAt(0) == aKey && i > model.getPriorityItemsSize())
return i;
}
}
return -1;
}Example 17
| Project: joda-beans-ui-master File: JValidatedFields.java View source code |
//-------------------------------------------------------------------------
/**
* Applies mandatory validation to a {@code JComboBox}.
*
* @param <T> the data type
* @param comboData the combobox data, not null
* @param mandatory whether the combobox is mandatory
* @param limitedValues whether the combobox has limited values
* @return the combobox, not null
*/
public static <T> JComboBox<T> createCombobox(final Map<String, T> comboData, boolean mandatory, boolean limitedValues) {
// allow drop down pick of a blank row
comboData.put("", null);
@SuppressWarnings("unchecked") ComboBoxModel<T> model = new MapComboBoxModel<String, T>(comboData);
final JComboBox<T> component = new JComboBox<T>(model);
component.setEditable(limitedValues == false);
component.setSelectedIndex(-1);
AutoCompleteDecorator.decorate(component, new ObjectToStringConverter() {
@Override
public String getPreferredStringForItem(Object item) {
if (item == null) {
return null;
}
for (Entry<String, T> entry : comboData.entrySet()) {
if (item.equals(entry.getValue())) {
return entry.getKey();
}
}
return item.toString();
}
});
if (mandatory) {
JValidatedFields.validateMandatory(component);
}
return component;
}Example 18
| Project: Weasis-master File: SendDicomView.java View source code |
protected void initialize(boolean afirst) {
if (afirst) {
AbstractDicomNode.loadDicomNodes(comboNode, AbstractDicomNode.Type.DICOM, UsageType.STORAGE);
AbstractDicomNode.loadDicomNodes(comboNode, AbstractDicomNode.Type.WEB, UsageType.STORAGE);
String desc = SendDicomFactory.EXPORT_PERSISTENCE.getProperty(LAST_SEL_NODE);
if (StringUtil.hasText(desc)) {
ComboBoxModel<AbstractDicomNode> model = comboNode.getModel();
for (int i = 0; i < model.getSize(); i++) {
if (desc.equals(model.getElementAt(i).getDescription())) {
model.setSelectedItem(model.getElementAt(i));
break;
}
}
}
}
}Example 19
| Project: argouml-master File: UMLSearchableComboBox.java View source code |
/**
* Does the actual searching. Returns the item found or null if there is no
* item found.
* @param item the string entered by the user
* @return Object the found object from the list, or null if none found
*/
protected Object search(Object item) {
String text = (String) item;
ComboBoxModel model = getModel();
for (int i = 0; i < model.getSize(); i++) {
Object element = model.getElementAt(i);
if (Model.getFacade().isAModelElement(element)) {
if (getRenderer() instanceof UMLListCellRenderer2) {
String labelText = ((UMLListCellRenderer2) getRenderer()).makeText(element);
if (labelText != null && labelText.startsWith(text)) {
return element;
}
}
if (Model.getFacade().isAModelElement(element)) {
Object /*MModelElement*/
elem = element;
String name = Model.getFacade().getName(elem);
if (name != null && name.startsWith(text)) {
return element;
}
}
}
}
return null;
}Example 20
| Project: argouml-spl-master File: UMLSearchableComboBox.java View source code |
/**
* Does the actual searching. Returns the item found or null if there is no
* item found.
* @param item the string entered by the user
* @return Object the found object from the list, or null if none found
*/
protected Object search(Object item) {
String text = (String) item;
ComboBoxModel model = getModel();
for (int i = 0; i < model.getSize(); i++) {
Object element = model.getElementAt(i);
if (Model.getFacade().isAModelElement(element)) {
if (getRenderer() instanceof UMLListCellRenderer2) {
String labelText = ((UMLListCellRenderer2) getRenderer()).makeText(element);
if (labelText != null && labelText.startsWith(text)) {
return element;
}
}
if (Model.getFacade().isAModelElement(element)) {
Object /*MModelElement*/
elem = element;
String name = Model.getFacade().getName(elem);
if (name != null && name.startsWith(text)) {
return element;
}
}
}
}
return null;
}Example 21
| Project: atlasframework-master File: FeatureClassification.java View source code |
/**
* Return a {@link ComboBoxModel} that present all available attributes.
* That excludes the attribute selected in
* {@link #getValueFieldsComboBoxModel()}.
*/
public ComboBoxModel createNormalizationFieldsComboBoxModel() {
normlizationAttribsComboBoxModel = new DefaultComboBoxModel();
normlizationAttribsComboBoxModel.addElement(NORMALIZE_NULL_VALUE_IN_COMBOBOX);
normlizationAttribsComboBoxModel.setSelectedItem(NORMALIZE_NULL_VALUE_IN_COMBOBOX);
for (final String fn : FeatureUtil.getNumericalFieldNames(getStyledFeatures().getSchema(), false)) {
if (fn != valueAttribsComboBoxModel.getSelectedItem())
if (FeatureUtil.checkAttributeNameRestrictions(fn))
normlizationAttribsComboBoxModel.addElement(fn);
else {
LOGGER.info("Hidden attribut " + fn + " in createNormalizationFieldsComboBoxModel");
}
else {
// System.out.println("Omittet field" + fn);
}
}
return normlizationAttribsComboBoxModel;
}Example 22
| Project: cayenne-master File: SuggestionList.java View source code |
/**
* 'Filters' the list, leaving only matching items
* @param prefix user-typed string, used to filter
*/
public void filter(String prefix) {
ComboBoxModel model = comboBox.getModel();
DefaultListModel lm = new DefaultListModel();
for (int i = 0; i < model.getSize(); i++) {
String item = CellRenderers.asString(model.getElementAt(i));
if (matches(item, prefix)) {
lm.addElement(model.getElementAt(i));
}
}
list.setModel(lm);
}Example 23
| Project: CoArgoUML-master File: UMLSearchableComboBox.java View source code |
/**
* Does the actual searching. Returns the item found or null if there is no
* item found.
* @param item the string entered by the user
* @return Object the found object from the list, or null if none found
*/
protected Object search(Object item) {
String text = (String) item;
ComboBoxModel model = getModel();
for (int i = 0; i < model.getSize(); i++) {
Object element = model.getElementAt(i);
if (Model.getFacade().isAModelElement(element)) {
if (getRenderer() instanceof UMLListCellRenderer2) {
String labelText = ((UMLListCellRenderer2) getRenderer()).makeText(element);
if (labelText != null && labelText.startsWith(text)) {
return element;
}
}
if (Model.getFacade().isAModelElement(element)) {
Object /*MModelElement*/
elem = element;
String name = Model.getFacade().getName(elem);
if (name != null && name.startsWith(text)) {
return element;
}
}
}
}
return null;
}Example 24
| Project: com.revolsys.open-master File: SelectMapUnitsPerPixel.java View source code |
public String format(final Object value) {
if (value instanceof Number) {
final Number number = (Number) value;
double doubleValue = number.doubleValue();
final ComboBoxModel<?> model = getModel();
if (model == PROJECTED_MODEL) {
doubleValue = Doubles.makePrecise(1000, doubleValue);
} else {
doubleValue = Doubles.makePrecise(10000000, doubleValue);
}
return Doubles.toString(doubleValue) + this.unitString;
} else {
return "Unknown";
}
}Example 25
| Project: deegree2-desktop-master File: SnappingOptionsPanel.java View source code |
private void initGUI() {
try {
final Settings settings = appCont.getSettings();
this.setPreferredSize(new java.awt.Dimension(360, 311));
GridBagLayout thisLayout = new GridBagLayout();
this.setSize(360, 311);
thisLayout.rowWeights = new double[] { 0.0, 0.1 };
thisLayout.rowHeights = new int[] { 234, 7 };
thisLayout.columnWeights = new double[] { 0.1 };
thisLayout.columnWidths = new int[] { 7 };
this.setLayout(thisLayout);
{
snapOptionsPanel = new JPanel();
GridBagLayout snapOptionsPanelLayout = new GridBagLayout();
this.add(snapOptionsPanel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
snapOptionsPanelLayout.rowWeights = new double[] { 0.1, 0.0, 0.1 };
snapOptionsPanelLayout.rowHeights = new int[] { 7, 12, 7 };
snapOptionsPanelLayout.columnWeights = new double[] { 0.0, 0.0, 0.1, 0.1 };
snapOptionsPanelLayout.columnWidths = new int[] { 110, 110, 7, 7 };
snapOptionsPanel.setLayout(snapOptionsPanelLayout);
{
btHelp = new JButton();
snapOptionsPanel.add(btHelp, new GridBagConstraints(2, 2, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
btHelp.setText(Messages.getMessage(getLocale(), "$MD10463"));
btHelp.setIcon(IconRegistry.getIcon("help.png"));
btHelp.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
HelpFrame hf = HelpFrame.getInstance(new HelpManager(appCont));
hf.setVisible(true);
hf.gotoModule("Digitizer");
}
});
}
{
jLabel1 = new JLabel();
snapOptionsPanel.add(jLabel1, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
jLabel1.setText(Messages.getMessage(getLocale(), "$MD10464"));
}
{
double value = settings.getSnappingToleranceOptions().getValue();
SpinnerNumberModel model = new SpinnerNumberModel(value, 1d, 10000d, 1);
spSnapDistance = new JSpinner();
snapOptionsPanel.add(spSnapDistance, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
spSnapDistance.setModel(model);
spSnapDistance.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
SnappingToleranceOpt smo = settings.getSnappingToleranceOptions();
String value = ((JSpinner) e.getSource()).getValue().toString();
smo.setValue(Float.valueOf(value));
}
});
}
{
String[] values = new String[] { Messages.getMessage(getLocale(), "$MD10465"), Messages.getMessage(getLocale(), "$MD10466") };
ComboBoxModel cbUOMModel = new DefaultComboBoxModel(values);
cbUOMModel.setSelectedItem(settings.getSnappingToleranceOptions().getUOM());
cbUOM = new JComboBox(cbUOMModel);
snapOptionsPanel.add(cbUOM, new GridBagConstraints(2, 0, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
cbUOM.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == 1) {
SnappingToleranceOpt smo = settings.getSnappingToleranceOptions();
smo.setUOM(e.getItem().toString());
}
}
});
}
}
{
layerPanel = new JPanel();
GridBagLayout layerPanelLayout = new GridBagLayout();
this.add(layerPanel, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
layerPanelLayout.rowWeights = new double[] { 0.1 };
layerPanelLayout.rowHeights = new int[] { 7 };
layerPanelLayout.columnWeights = new double[] { 0.0, 0.1 };
layerPanelLayout.columnWidths = new int[] { 182, 7 };
layerPanel.setLayout(layerPanelLayout);
{
scLayers = new JScrollPane();
layerPanel.add(scLayers, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(5, 5, 5, 5), 0, 0));
{
List<String> layers = getFeatureLayers();
ListModel layerListModel = new DefaultComboBoxModel(layers.toArray(new String[layers.size()]));
layerList = new JList();
layerList.addListSelectionListener(new LayerSelectListener());
scLayers.setViewportView(layerList);
layerList.setModel(layerListModel);
layerList.addListSelectionListener(new ListSelectionListener() {
public void valueChanged(ListSelectionEvent e) {
cbEdge.setEnabled(true);
cbEdgeCenter.setEnabled(true);
cbEndNode.setEnabled(true);
cbStartNode.setEnabled(true);
cbVertex.setEnabled(true);
}
});
}
}
{
snapTargetPanel = new JPanel();
GridBagLayout snapTargetPanelLayout = new GridBagLayout();
layerPanel.add(snapTargetPanel, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
snapTargetPanelLayout.rowWeights = new double[] { 0.1, 0.0, 0.0, 0.0, 0.0, 0.0, 0.1 };
snapTargetPanelLayout.rowHeights = new int[] { 7, 30, 30, 30, 30, 30, 7 };
snapTargetPanelLayout.columnWeights = new double[] { 0.1 };
snapTargetPanelLayout.columnWidths = new int[] { 7 };
snapTargetPanel.setLayout(snapTargetPanelLayout);
{
jLabel2 = new JLabel();
snapTargetPanel.add(jLabel2, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 5, 0, 5), 0, 0));
jLabel2.setText(Messages.getMessage(getLocale(), "$MD10467"));
}
addCheckboxes();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}Example 26
| Project: Ganymede-master File: TimedKeySelectionManager.java View source code |
/* -- */
public int selectionForKey(char key, ComboBoxModel model) {
updateSearchString(model, key);
if (debug) {
System.err.println("TimedKeySelectionManager: searchString = " + searchString);
System.err.println("TimedKeySelectionManager: start = " + start);
}
int selection = search(model, start);
if (selection == -1 && start != 0) {
selection = search(model, 0);
}
start = selection + 1;
if (debug) {
System.err.println("TimedKeySelectionManager: selection index = " + selection);
}
return selection;
}Example 27
| Project: gluu-opendj-master File: ComboKeySelectionManager.java View source code |
/**
* {@inheritDoc}
*/
public int selectionForKey(char key, ComboBoxModel model) {
int selectedIndex = -1;
long currentTime = System.currentTimeMillis();
if (key == KeyEvent.VK_BACK_SPACE) {
if (lastSearchedString == null) {
lastSearchedString = "";
} else if (lastSearchedString.length() > 0) {
lastSearchedString = lastSearchedString.substring(0, lastSearchedString.length() - 1);
} else {
// Nothing to do.
}
} else {
if (lastSearchedTime + RESET_BETWEEN_TYPES < currentTime) {
// Reset the search.
lastSearchedString = String.valueOf(key);
} else {
if (lastSearchedString == null) {
lastSearchedString = String.valueOf(key);
} else {
lastSearchedString += key;
}
}
}
lastSearchedTime = currentTime;
if (lastSearchedString.length() > 0) {
for (int i = 0; i < model.getSize() && selectedIndex == -1; i++) {
Object value = model.getElementAt(i);
Component comp = combo.getRenderer().getListCellRendererComponent(list, value, i, true, true);
String sValue;
if (comp instanceof Container) {
sValue = getDisplayedStringValue((Container) comp);
if (sValue == null) {
sValue = "";
} else {
sValue = sValue.trim();
}
} else {
sValue = String.valueOf(value);
}
if (sValue.toLowerCase().startsWith(lastSearchedString.toLowerCase())) {
selectedIndex = i;
}
}
}
return selectedIndex;
}Example 28
| Project: jeboorker-master File: JREditableHistoryComboBox.java View source code |
/**
* Get all history values as comma separated string.
*
* @return The comma separated history values.
*/
public String getHistoryValues() {
ComboBoxModel<String> model = getModel();
StringBuilder modelEntries = new StringBuilder();
for (int i = 0; i < model.getSize(); i++) {
String elementAt = StringUtil.replace(StringUtil.toString(model.getElementAt(i)), ",", EMPTY);
if (modelEntries.length() > 0) {
modelEntries.append(",");
}
modelEntries.append(elementAt);
}
return modelEntries.toString();
}Example 29
| Project: josm-plugins-master File: ConflictResolver.java View source code |
private void reassignButtonActionPerformed(java.awt.event.ActionEvent evt) {
//GEN-FIRST:event_reassignButtonActionPerformed
Reasoner r = Reasoner.getInstance();
synchronized (r) {
r.openTransaction();
if (conflictModel.getSelectedItem() instanceof OsmPrimitive) {
OsmPrimitive prim = (OsmPrimitive) conflictModel.getSelectedItem();
if (r.translate(prim) != null)
r.unOverwrite(prim, r.translate(prim));
ComboBoxModel<Object> model = candField.getModel();
for (int i = 0; i < model.getSize(); i++) {
AddressElement elem = (AddressElement) model.getElementAt(i);
r.unOverwrite(prim, elem);
if (r.translate(elem) != null)
r.unOverwrite(r.translate(elem), elem);
}
r.doOverwrite(prim, (AddressElement) model.getSelectedItem());
}
if (conflictModel.getSelectedItem() instanceof AddressElement) {
AddressElement elem = (AddressElement) conflictModel.getSelectedItem();
if (r.translate(elem) != null)
r.unOverwrite(r.translate(elem), elem);
ComboBoxModel<Object> model = candField.getModel();
for (int i = 0; i < model.getSize(); i++) {
OsmPrimitive prim = (OsmPrimitive) model.getElementAt(i);
r.unOverwrite(prim, elem);
if (r.translate(prim) != null)
r.unOverwrite(prim, r.translate(prim));
}
r.doOverwrite((OsmPrimitive) model.getSelectedItem(), elem);
}
r.closeTransaction();
}
}Example 30
| Project: kolmafia-master File: SkillBuffFrame.java View source code |
public void actionPerformed(final ActionEvent e) {
ComboBoxModel oldModel = SkillBuffFrame.this.skillSelect.getModel();
ComboBoxModel newModel = oldModel;
switch(SkillTypeComboBox.this.getSelectedIndex()) {
case 0:
// All skills
newModel = (LockableListModel<UseSkillRequest>) KoLConstants.usableSkills;
break;
case 1:
// Summoning skills
newModel = (LockableListModel<UseSkillRequest>) KoLConstants.summoningSkills;
break;
case 2:
// Remedy skills
newModel = (LockableListModel<UseSkillRequest>) KoLConstants.remedySkills;
break;
case 3:
// Self-only skills
newModel = (LockableListModel<UseSkillRequest>) KoLConstants.selfOnlySkills;
break;
case 4:
// Buff skills
newModel = (LockableListModel<UseSkillRequest>) KoLConstants.buffSkills;
break;
case 5:
// Song skills
newModel = (LockableListModel<UseSkillRequest>) KoLConstants.songSkills;
break;
case 6:
// Expression skills
newModel = (LockableListModel<UseSkillRequest>) KoLConstants.expressionSkills;
break;
case 7:
// Walk skills
newModel = (LockableListModel<UseSkillRequest>) KoLConstants.walkSkills;
break;
}
if (newModel != oldModel) {
int index = SkillTypeComboBox.this.getSelectedIndex();
SkillBuffFrame.this.skillSelect.setModel(newModel);
}
}Example 31
| Project: korsakow-editor-master File: AbstractTableWidgetPropertiesEditor.java View source code |
protected void prepareEditor(int row, int column) {
isEditing = true;
editingName = (String) table.getValueAt(row, 0);
cellEditor.removeCellEditorListener(this);
cellEditor.addCellEditorListener(this);
ComboBoxModel model = new KComboboxModel();
// propertyEditor.setEditable(true);
// it is perfectly acceptable for a property handler to set a custom renderer, so we reset it
propertyEditor.setRenderer(defaultRenderer);
propertyEditor.setModel(model);
}Example 32
| Project: LEADT-master File: UMLSearchableComboBox.java View source code |
/**
* Does the actual searching. Returns the item found or null if there is no
* item found.
* @param item the string entered by the user
* @return Object the found object from the list, or null if none found
*/
protected Object search(Object item) {
String text = (String) item;
ComboBoxModel model = getModel();
for (int i = 0; i < model.getSize(); i++) {
Object element = model.getElementAt(i);
if (Model.getFacade().isAModelElement(element)) {
if (getRenderer() instanceof UMLListCellRenderer2) {
String labelText = ((UMLListCellRenderer2) getRenderer()).makeText(element);
if (labelText != null && labelText.startsWith(text)) {
return element;
}
}
if (Model.getFacade().isAModelElement(element)) {
Object /*MModelElement*/
elem = element;
String name = Model.getFacade().getName(elem);
if (name != null && name.startsWith(text)) {
return element;
}
}
}
}
return null;
}Example 33
| Project: liquiface-master File: DatabaseChooserPanel.java View source code |
private ComboBoxModel getDatabases() {
if (databases == null) {
DatabaseConnection[] netbeansConnections = DatabaseConnectionFactory.getInstance().getNetbeansConnections();
DatabaseConnectionItem[] items = new DatabaseConnectionItem[netbeansConnections.length];
int i = 0;
for (DatabaseConnection conn : netbeansConnections) {
items[i++] = new DatabaseConnectionItem(conn);
}
databases = new DefaultComboBoxModel(items);
}
return databases;
}Example 34
| Project: Meshia-master File: RenderGlobalsPanel.java View source code |
private void initGUI() {
try {
setPreferredSize(new Dimension(400, 300));
{
generalPanel = new JPanel();
FlowLayout generalPanelLayout = new FlowLayout();
generalPanelLayout.setAlignment(FlowLayout.LEFT);
generalPanel.setLayout(generalPanelLayout);
this.addTab("General", null, generalPanel, null);
{
resolutionPanel = new JPanel();
generalPanel.add(resolutionPanel);
FlowLayout resolutionPanelLayout = new FlowLayout();
resolutionPanel.setLayout(resolutionPanelLayout);
resolutionPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED), "Resolution", TitledBorder.LEADING, TitledBorder.TOP));
{
resolutionCheckBox = new JCheckBox();
resolutionPanel.add(resolutionCheckBox);
resolutionCheckBox.setText("Override");
}
{
jLabel1 = new JLabel();
resolutionPanel.add(jLabel1);
jLabel1.setText("Image Width:");
}
{
resolutionXTextField = new JTextField();
resolutionPanel.add(resolutionXTextField);
resolutionXTextField.setText("640");
resolutionXTextField.setPreferredSize(new java.awt.Dimension(50, 20));
}
{
jLabel2 = new JLabel();
resolutionPanel.add(jLabel2);
jLabel2.setText("Image Height:");
}
{
resolutionYTextField = new JTextField();
resolutionPanel.add(resolutionYTextField);
resolutionYTextField.setText("480");
resolutionYTextField.setPreferredSize(new java.awt.Dimension(50, 20));
}
}
{
threadsPanel = new JPanel();
generalPanel.add(threadsPanel);
threadsPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED), "Threads", TitledBorder.LEADING, TitledBorder.TOP));
{
threadCheckBox = new JCheckBox();
threadsPanel.add(threadCheckBox);
threadCheckBox.setText("Use All Processors");
}
{
jLabel3 = new JLabel();
threadsPanel.add(jLabel3);
jLabel3.setText("Threads:");
}
{
threadTextField = new JTextField();
threadsPanel.add(threadTextField);
threadTextField.setText("1");
threadTextField.setPreferredSize(new java.awt.Dimension(50, 20));
}
}
}
{
rendererPanel = new JPanel();
FlowLayout rendererPanelLayout = new FlowLayout();
rendererPanelLayout.setAlignment(FlowLayout.LEFT);
rendererPanel.setLayout(rendererPanelLayout);
this.addTab("Renderer", null, rendererPanel, null);
{
defaultRendererRadioButton = new JRadioButton();
rendererPanel.add(defaultRendererRadioButton);
defaultRendererRadioButton.setText("Default Renderer");
}
{
bucketRendererPanel = new JPanel();
BoxLayout bucketRendererPanelLayout = new BoxLayout(bucketRendererPanel, javax.swing.BoxLayout.Y_AXIS);
bucketRendererPanel.setLayout(bucketRendererPanelLayout);
rendererPanel.add(bucketRendererPanel);
bucketRendererPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(BevelBorder.LOWERED), "Bucket Renderer", TitledBorder.LEADING, TitledBorder.TOP));
{
bucketRendererRadioButton = new JRadioButton();
bucketRendererPanel.add(bucketRendererRadioButton);
bucketRendererRadioButton.setText("Enable");
}
{
samplingPanel = new JPanel();
GridLayout samplingPanelLayout = new GridLayout(2, 2);
samplingPanelLayout.setColumns(2);
samplingPanelLayout.setHgap(5);
samplingPanelLayout.setVgap(5);
samplingPanelLayout.setRows(2);
samplingPanel.setLayout(samplingPanelLayout);
bucketRendererPanel.add(samplingPanel);
{
jLabel5 = new JLabel();
samplingPanel.add(jLabel5);
jLabel5.setText("Min:");
}
{
ComboBoxModel minSamplingComboBoxModel = new DefaultComboBoxModel(new String[] { "Item One", "Item Two" });
minSamplingComboBox = new JComboBox();
samplingPanel.add(minSamplingComboBox);
minSamplingComboBox.setModel(minSamplingComboBoxModel);
}
{
jLabel6 = new JLabel();
samplingPanel.add(jLabel6);
jLabel6.setText("Max:");
}
{
ComboBoxModel maxSamplingComboxBoxModel = new DefaultComboBoxModel(new String[] { "Item One", "Item Two" });
maxSamplingComboxBox = new JComboBox();
samplingPanel.add(maxSamplingComboxBox);
maxSamplingComboxBox.setModel(maxSamplingComboxBoxModel);
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
}Example 35
| Project: monsiaj-master File: PandaCombo.java View source code |
private boolean selectWithKey(KeyEvent e) {
if (e.getID() == KeyEvent.KEY_TYPED) {
ComboBoxModel model = combo.getModel();
int pos = getSelectionStart();
if (pos == 0) {
pos = getCaretPosition();
}
String prefix = getText().substring(0, pos) + e.getKeyChar();
for (int i = 0, n = model.getSize(); i < n; i++) {
Object o = model.getElementAt(i);
String s = o.toString();
if (s.startsWith(prefix)) {
combo.setSelectedIndex(i);
setText(s);
setSelectionStart(pos + 1);
setSelectionEnd(getText().length());
return true;
}
}
} else if (e.getID() == KeyEvent.KEY_PRESSED && e.getKeyCode() == KeyEvent.VK_UNDEFINED) {
ComboBoxModel model = combo.getModel();
int pos = getText().length();
String prefix = getText().substring(0, pos);
for (int i = 0, n = model.getSize(); i < n; i++) {
Object o = model.getElementAt(i);
String s = o.toString();
if (s.startsWith(prefix)) {
combo.setSelectedIndex(i);
setText(s);
setCaretPosition(pos);
return true;
}
}
}
return false;
}Example 36
| Project: MPS-master File: TwoOptionsStep.java View source code |
private ComboBoxModel updateComboBoxModel() {
M[] newVariants = this.getVariants();
if (!((this.mySelectComboBox == null)) && Arrays.deepEquals(newVariants, this.myVariantsArray)) {
return this.mySelectComboBox.getModel();
}
this.myVariantsArray = newVariants;
List<String> items = ListSequence.fromList(new ArrayList<String>());
for (M variant : this.myVariantsArray) {
ListSequence.fromList(items).addElement(TwoOptionsStep.this.getVariantName(variant));
}
return new DefaultComboBoxModel(ListSequence.fromList(items).toGenericArray(String.class));
}Example 37
| Project: OpenDJ-master File: ComboKeySelectionManager.java View source code |
/** {@inheritDoc} */
public int selectionForKey(char key, ComboBoxModel model) {
int selectedIndex = -1;
long currentTime = System.currentTimeMillis();
if (key == KeyEvent.VK_BACK_SPACE) {
if (lastSearchedString == null) {
lastSearchedString = "";
} else if (lastSearchedString.length() > 0) {
lastSearchedString = lastSearchedString.substring(0, lastSearchedString.length() - 1);
} else {
// Nothing to do.
}
} else {
if (lastSearchedTime + RESET_BETWEEN_TYPES < currentTime) {
// Reset the search.
lastSearchedString = String.valueOf(key);
} else {
if (lastSearchedString == null) {
lastSearchedString = String.valueOf(key);
} else {
lastSearchedString += key;
}
}
}
lastSearchedTime = currentTime;
if (lastSearchedString.length() > 0) {
for (int i = 0; i < model.getSize() && selectedIndex == -1; i++) {
Object value = model.getElementAt(i);
Component comp = combo.getRenderer().getListCellRendererComponent(list, value, i, true, true);
String sValue;
if (comp instanceof Container) {
sValue = getDisplayedStringValue((Container) comp);
if (sValue == null) {
sValue = "";
} else {
sValue = sValue.trim();
}
} else {
sValue = String.valueOf(value);
}
if (sValue.toLowerCase().startsWith(lastSearchedString.toLowerCase())) {
selectedIndex = i;
}
}
}
return selectedIndex;
}Example 38
| Project: pikater-master File: MainWindowOld.java View source code |
private void initGUI() {
resultsTableModel = new DefaultTableModel(0, 3);
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
{
jPanel1 = new JPanel();
getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.setLayout(null);
jPanel1.setPreferredSize(new java.awt.Dimension(617, 397));
{
mainPane = new JTabbedPane();
jPanel1.add(mainPane);
mainPane.setBounds(10, 14, 591, 308);
{
agentsPanel = new JPanel();
mainPane.addTab("Agents", null, agentsPanel, null);
agentsPanel.setLayout(null);
{
agentParams1 = new JTextField();
agentsPanel.add(agentParams1);
agentParams1.setBounds(187, 12, 135, 19);
}
{
ComboBoxModel agentClass1Model = new DefaultComboBoxModel();
agentClass1 = new JComboBox();
agentsPanel.add(agentClass1);
agentClass1.setModel(agentClass1Model);
agentClass1.setBounds(12, 10, 169, 23);
}
{
ComboBoxModel agentClass2Model = new DefaultComboBoxModel();
agentClass2 = new JComboBox();
agentsPanel.add(agentClass2);
agentClass2.setModel(agentClass2Model);
agentClass2.setBounds(12, 45, 169, 22);
}
{
agentParams2 = new JTextField();
agentsPanel.add(agentParams2);
agentParams2.setBounds(187, 47, 135, 19);
}
}
{
filesPanel = new JPanel();
mainPane.addTab("Files", null, filesPanel, null);
filesPanel.setLayout(null);
filesPanel.setPreferredSize(new java.awt.Dimension(385, 243));
{
file1 = new JTextField();
filesPanel.add(file1);
file1.setBounds(12, 12, 122, 33);
}
{
file2 = new JTextField();
filesPanel.add(file2);
file2.setBounds(12, 53, 122, 33);
}
}
{
resultsPanel = new JPanel();
mainPane.addTab("Results", null, resultsPanel, null);
{
jScrollPane1 = new JScrollPane();
resultsPanel.add(jScrollPane1);
jScrollPane1.setPreferredSize(new java.awt.Dimension(577, 272));
{
resultsTable = new JTable(resultsTableModel);
jScrollPane1.setViewportView(resultsTable);
resultsTable.setPreferredSize(new java.awt.Dimension(577, 272));
}
}
}
}
{
startButton = new JButton();
jPanel1.add(startButton);
startButton.setText("Start");
startButton.setBounds(257, 352, 63, 25);
startButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent evt) {
startButtonMouseClicked(evt);
}
});
}
}
pack();
GuiEvent ge = new GuiEvent(agentClass1, ONLOAD);
myAgent.postGuiEvent(ge);
} catch (Exception e) {
e.printStackTrace();
}
}Example 39
| Project: PokemonWalking-master File: KeySelectionRenderer.java View source code |
/**
* Implements the KeySelectionManager.
* */
@Override
@SuppressWarnings("rawtypes")
public int selectionForKey(char aKey, ComboBoxModel model) {
this.currentTime = System.currentTimeMillis();
// Get the index of the currently selected item
int size = model.getSize();
int startIndex = -1;
Object selectedItem = model.getSelectedItem();
if (selectedItem != null) {
for (int i = 0; i < size; i++) {
if (selectedItem == model.getElementAt(i)) {
startIndex = i;
break;
}
}
}
// fast the user has been typing and on which letter has been typed.
if (currentTime - lastTime < timeFactor) {
if ((prefix.length() == 1) && (aKey == prefix.charAt(0)))
// Subsequent same key presses move the keyboard focus to the next
// object that starts with the same letter.
startIndex++;
else
prefix += aKey;
} else {
startIndex++;
prefix = "" + aKey;
}
lastTime = currentTime;
// Search from the current selection and wrap when no match is found
if (startIndex < 0 || startIndex >= size)
startIndex = 0;
int index = getNextMatch(prefix, startIndex, size, model);
if (index < 0)
// Wrap
index = getNextMatch(prefix, 0, startIndex, model);
return index;
}Example 40
| Project: Scute-master File: JXSearchPanel.java View source code |
//--------------------- binding support
/**
* bind the components to the patternModel/actions.
*/
@Override
protected void bind() {
super.bind();
List<?> matchRules = getPatternModel().getMatchRules();
// PENDING: map rules to localized strings
ComboBoxModel model = new DefaultComboBoxModel(matchRules.toArray());
model.setSelectedItem(getPatternModel().getMatchRule());
searchCriteria.setModel(model);
searchCriteria.setAction(getAction(MATCH_RULE_ACTION_COMMAND));
}Example 41
| Project: snap-desktop-master File: ColorPaletteChooser.java View source code |
public ColorPaletteDef getSelectedColorPaletteDefinition() {
final int selectedIndex = getSelectedIndex();
final ComboBoxModel<ColorPaletteWrapper> model = getModel();
final ColorPaletteWrapper colorPaletteWrapper = model.getElementAt(selectedIndex);
final ColorPaletteDef cpd = colorPaletteWrapper.cpd;
cpd.getFirstPoint().setLabel(colorPaletteWrapper.name);
return cpd;
}Example 42
| Project: SOAP-master File: OAuth2GetAccessTokenForm.java View source code |
private JComboBox appendOAuth2ComboBox(SimpleBindingForm accessTokenForm) {
AbstractValueModel valueModel = getOAuth2FlowValueModel(accessTokenForm);
ComboBoxModel oauth2FlowsModel = new DefaultComboBoxModel(OAuth2Profile.OAuth2Flow.values());
JComboBox oauth2FlowComboBox = accessTokenForm.appendComboBox("OAuth 2 Flow", oauth2FlowsModel, "OAuth 2 Authorization Flow", valueModel);
oauth2FlowComboBox.setName(OAUTH_2_FLOW_COMBO_BOX_NAME);
return oauth2FlowComboBox;
}Example 43
| Project: soapui-master File: OAuth2GetAccessTokenForm.java View source code |
private JComboBox appendOAuth2ComboBox(SimpleBindingForm accessTokenForm) {
AbstractValueModel valueModel = getOAuth2FlowValueModel(accessTokenForm);
ComboBoxModel oauth2FlowsModel = new DefaultComboBoxModel(OAuth2Profile.OAuth2Flow.values());
JComboBox oauth2FlowComboBox = accessTokenForm.appendComboBox("OAuth 2 Flow", oauth2FlowsModel, "OAuth 2 Authorization Flow", valueModel);
oauth2FlowComboBox.setName(OAUTH_2_FLOW_COMBO_BOX_NAME);
return oauth2FlowComboBox;
}Example 44
| Project: WordCloudPlugin-master File: WidestStringComboBoxPopupMenuListener.java View source code |
/**
* Resize the popup list based on the longest display string for objects in
* the model of the JComboBox being listened to.
* The model must implement WidestStringProvider for the popup to be sized.
*
* @param e
*/
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
ComboBoxModel cbm;
WidestStringProvider wsp;
int w, h;
Dimension d;
JComboBox box = (JComboBox) e.getSource();
cbm = box.getModel();
if (!(cbm instanceof WidestStringProvider)) {
// Silently ignore if not listening to a JComboBox with a suitable model object
return;
}
wsp = (WidestStringProvider) cbm;
Object comp = box.getUI().getAccessibleChild(box, 0);
if (!(comp instanceof JPopupMenu)) {
return;
}
Object scrollObject = ((JComponent) comp).getComponent(0);
if (!(scrollObject instanceof JScrollPane)) {
return;
}
JScrollPane scrollPane = (JScrollPane) scrollObject;
FontMetrics fm = box.getFontMetrics(scrollPane.getFont());
w = (int) fm.stringWidth(wsp.getWidest());
h = (int) scrollPane.getMinimumSize().getHeight();
d = new Dimension(Math.max((int) ((double) w + scrollPane.getVerticalScrollBar().getMinimumSize().getWidth()), box.getWidth()), h);
scrollPane.setPreferredSize(d);
scrollPane.setMaximumSize(d);
}Example 45
| Project: assertj-swing-master File: ListComboBoxDriver.java View source code |
public String[] getContents(ListComboBox target) {
ComboBoxModel model = target.getModel();
ConverterContext context = target.getConverterContext();
ObjectConverter converter = target.getConverter();
java.util.List<String> contents = new ArrayList<String>(model.getSize());
for (int i = 0; i < model.getSize(); i++) {
if (converter == null) {
contents.add(String.valueOf(model.getElementAt(i)));
} else {
contents.add(converter.toString(model.getElementAt(i), context));
}
}
return contents.toArray(new String[contents.size()]);
}Example 46
| Project: DataCleaner-master File: SourceColumnComboBox.java View source code |
public void setModel(final Datastore datastore, final Table table) {
final String previousColumnName;
final Column previousItem = getSelectedItem();
if (previousItem == null) {
previousColumnName = null;
} else {
previousColumnName = previousItem.getName();
}
if (getTable() == table) {
return;
}
setTable(table);
if (datastore == null) {
setDatastoreConnection(null);
} else {
setDatastoreConnection(datastore.openConnection());
}
if (table == null) {
setModel(new DefaultComboBoxModel<>(new String[1]));
} else {
int selectedIndex = 0;
final List<Column> comboBoxList = new ArrayList<>();
comboBoxList.add(null);
final Column[] columns = table.getColumns();
for (final Column column : columns) {
comboBoxList.add(column);
if (column.getName().equals(previousColumnName)) {
selectedIndex = comboBoxList.size() - 1;
}
}
final ComboBoxModel<Object> model = new DefaultComboBoxModel<>(comboBoxList.toArray());
setModel(model);
setSelectedIndex(selectedIndex);
}
}Example 47
| Project: DDS-Utils-master File: SettingsPanel.java View source code |
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
@Override
public void actionPerformed(final ActionEvent e) {
final JComboBox combo = (JComboBox) e.getSource();
final ComboBoxModel model = combo.getModel();
final Preset preset = (Preset) model.getSelectedItem();
fldNewWidth.setValue(preset.getWidth());
fldNewHeight.setValue(preset.getHeight());
chkMipMaps.setSelected(preset.isMipmaps());
//TODO clean up ... no hardcode
if (preset.getPixelformat() == DDSImage.D3DFMT_DXT1) {
comboPixelformat.setSelectedIndex(3);
} else if (preset.getPixelformat() == DDSImage.D3DFMT_DXT5) {
comboPixelformat.setSelectedIndex(1);
} else {
comboPixelformat.setSelectedIndex(1);
}
}Example 48
| Project: geotoolkit-master File: AuthorityCodesComboBox.java View source code |
/**
* Sets the selected object to the one having the given code. If the given object is
* {@code null}, then this method clears the selection.
*
* @param code The authority code of the object to set as the selected index, or {@code null}.
*
* @since 3.12
*/
public void setSelectedCode(final String code) {
if (code == null) {
codeComboBox.setSelectedItem(null);
} else {
final ComboBoxModel<AuthorityCode> model = codeComboBox.getModel();
if (model instanceof AuthorityCodeList) {
((AuthorityCodeList) model).setSelectedCode(code);
} else {
final int size = model.getSize();
for (int i = 0; i < size; i++) {
final AuthorityCode c = model.getElementAt(i);
if (code.equals(c.code)) {
model.setSelectedItem(c);
break;
}
}
}
}
}Example 49
| Project: HermesJMS-master File: EditNamingConfigDialog.java View source code |
private ComboBoxModel createComboBoxModel() {
DefaultComboBoxModel model = new DefaultComboBoxModel();
if (newConfig != null) {
model.addElement(newConfig.getId());
}
for (Iterator iter = namingConfigs.iterator(); iter.hasNext(); ) {
NamingConfig config = (NamingConfig) iter.next();
namingConfigsByName.put(config.getId(), config);
model.addElement(config.getId());
if (selectedConfig == null) {
selectedConfig = config.getId();
}
}
return model;
}Example 50
| Project: jDip-master File: AssocJComboBox.java View source code |
// getDefaultAO()
/**
* Returns the AssociatedObj for a given value/display
* If none, returns null. If an AssociatedObj is passed in,
* that same AssociatedObj is returned.
*/
private AssociatedObj getAOForValue(Object value) {
// short circuit
if (value instanceof AssociatedObj) {
return (AssociatedObj) value;
} else if (value != null) {
ComboBoxModel model = getModel();
final int len = model.getSize();
for (int i = 0; i < len; i++) {
AssociatedObj ao = (AssociatedObj) model.getElementAt(i);
if (value.equals(ao.getValue()) || value.equals(ao.getDisplay())) {
return ao;
}
}
}
return null;
}Example 51
| Project: lazybones-master File: GeneralPanel.java View source code |
private void initGUI() {
try {
{
FlowLayout thisLayout = new FlowLayout();
thisLayout.setAlignment(FlowLayout.LEFT);
this.setLayout(thisLayout);
this.setPreferredSize(new java.awt.Dimension(517, 343));
{
mainPanel = new JPanel();
GridBagLayout mainPanelLayout = new GridBagLayout();
mainPanelLayout.columnWidths = new int[] { 7, 7 };
mainPanelLayout.rowHeights = new int[] { 7, 7, 7, 7 };
mainPanelLayout.columnWeights = new double[] { 0.1, 0.1 };
mainPanelLayout.rowWeights = new double[] { 0.1, 0.1, 0.1, 0.1 };
this.add(mainPanel);
mainPanel.setLayout(mainPanelLayout);
}
{
lHost = new JLabel();
lHost.setText(LazyBones.getTranslation("host", "Host"));
mainPanel.add(lHost, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
}
{
expertsPanel = new JPanel();
GridBagLayout expertsPanelLayout = new GridBagLayout();
expertsPanel.setLayout(expertsPanelLayout);
expertsPanel.setBorder(BorderFactory.createTitledBorder(LazyBones.getTranslation("experts", "Experts")));
{
lFuzzyness = new JLabel();
lFuzzyness.setText(LazyBones.getTranslation("percentageOfEquality", "Fuzzylevel program titles"));
}
{
logConnectionErr = new JCheckBox();
expertsPanel.add(logConnectionErr, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
logConnectionErr.setSelected(Boolean.TRUE.toString().equals(LazyBones.getProperties().getProperty("logConnectionErrors")));
}
{
lLogConnectionErr = new JLabel(LazyBones.getTranslation("logConnectionErrors", "Show error dialogs on connection problems"));
lLogConnectionErr.setText(LazyBones.getTranslation("logConnectionErrors", "Show error dialogs on connection problems"));
}
{
int percentageThreshold = Integer.parseInt(LazyBones.getProperties().getProperty("percentageThreshold"));
SpinnerModel percentageModel = new SpinnerNumberModel(percentageThreshold, 0, 100, 1);
percentage = new JSpinner();
percentage.setModel(percentageModel);
percentage.setToolTipText(LazyBones.getTranslation("percentageOfEquality.tooltip", "Percentage of equality of program titles"));
}
{
supressMatchDialog = new JCheckBox();
expertsPanel.add(supressMatchDialog, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
expertsPanel.add(percentage, new GridBagConstraints(1, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
expertsPanel.add(lFuzzyness, new GridBagConstraints(0, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
supressMatchDialog.setToolTipText(LazyBones.getTranslation("supressMatchDialog.tooltip", "Do not show EPG selection dialog for non matching VDR timer"));
supressMatchDialog.setSelected(Boolean.TRUE.toString().equals(LazyBones.getProperties().getProperty("supressMatchDialog")));
}
{
lSupressMatchDialog = new JLabel();
expertsPanel.add(lSupressMatchDialog, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
expertsPanel.add(lLogConnectionErr, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
{
lLogEpgErr = new JLabel();
expertsPanel.add(lLogEpgErr, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
lLogEpgErr.setText(LazyBones.getTranslation("logEPGErrors", "Show error dialogs, if EPG data are missing"));
}
{
logEpgErr = new JCheckBox();
logEpgErr.setSelected(Boolean.TRUE.toString().equals(LazyBones.getProperties().getProperty("logEPGErrors")));
expertsPanel.add(logEpgErr, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
}
{
lShowTimerOptions = new JLabel();
expertsPanel.add(lShowTimerOptions, new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
lShowTimerOptions.setText(LazyBones.getTranslation("showTimerOptionsDialog", "Show timer options dialog on timer creation"));
}
{
showTimerOptions = new JCheckBox();
showTimerOptions.setSelected(Boolean.TRUE.toString().equals(LazyBones.getProperties().getProperty("showTimerOptionsDialog")));
expertsPanel.add(showTimerOptions, new GridBagConstraints(1, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
}
{
bShowLog = new JButton();
expertsPanel.add(bShowLog, new GridBagConstraints(1, 6, 1, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
bShowLog.setText(LazyBones.getTranslation("show_log", "Show log"));
bShowLog.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent evt) {
DebugConsole dc = new DebugConsole();
dc.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
dc.setVisible(true);
}
});
}
{
lLoadRecordInfo = new JLabel();
expertsPanel.add(lLoadRecordInfo, new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
lLoadRecordInfo.setText(LazyBones.getTranslation("load_recording_information", "Load recording information"));
}
{
cbLoadRecordInfo = new JCheckBox();
cbLoadRecordInfo.setSelected(Boolean.TRUE.toString().equals(LazyBones.getProperties().getProperty("loadRecordInfos")));
expertsPanel.add(cbLoadRecordInfo, new GridBagConstraints(1, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
}
lSupressMatchDialog.setText(LazyBones.getTranslation("supressMatchDialog", "Supress match dialog"));
}
expertsPanelLayout.rowWeights = new double[] { 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1 };
expertsPanelLayout.rowHeights = new int[] { 7, 7, 7, 7, 7, 7, 7 };
expertsPanelLayout.columnWeights = new double[] { 0.1, 0.1 };
expertsPanelLayout.columnWidths = new int[] { 7, 7 };
}
{
ComboBoxModel<String> charsetModel = new DefaultComboBoxModel<String>(new String[] { "ISO-8859-1", "ISO-8859-15", "UTF-8" });
charset = new JComboBox<String>();
mainPanel.add(charset, new GridBagConstraints(1, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
charset.setModel(charsetModel);
String c = LazyBones.getProperties().getProperty("charset");
charset.setSelectedItem(c);
}
{
lCharset = new JLabel();
mainPanel.add(lCharset, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
lCharset.setText(LazyBones.getTranslation("charset", "Charset"));
}
{
int value = Integer.parseInt(LazyBones.getProperties().getProperty("timeout"));
SpinnerNumberModel timeoutModel = new SpinnerNumberModel(value, 1, 30000, 1);
timeout = new JSpinner();
mainPanel.add(timeout, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
timeout.setModel(timeoutModel);
timeout.setEditor(new JSpinner.NumberEditor(timeout, "#"));
}
{
lTimeout = new JLabel();
mainPanel.add(lTimeout, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
lTimeout.setText("Timeout");
}
{
host = new JTextField();
host.setText(LazyBones.getProperties().getProperty("host"));
}
{
int value = Integer.parseInt(LazyBones.getProperties().getProperty("port"));
SpinnerNumberModel portModel = new SpinnerNumberModel(value, 1, 65535, 1);
port = new JSpinner();
mainPanel.add(port, new GridBagConstraints(1, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
port.setModel(portModel);
port.setEditor(new JSpinner.NumberEditor(port, "#"));
}
{
lPort = new JLabel();
mainPanel.add(lPort, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
mainPanel.add(host, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
mainPanel.add(expertsPanel, new GridBagConstraints(0, 4, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
expertsPanel.setSize(10, 10);
lPort.setText(LazyBones.getTranslation("port", "Port"));
}
}
} catch (Exception e) {
e.printStackTrace();
}
}Example 52
| Project: maptool-master File: HTMLPaneFormView.java View source code |
private Map<String, String> getDataFrom(Element ele, String selectedImageMap) {
Map<String, String> vals = new HashMap<String, String>();
for (int i = 0; i < ele.getElementCount(); i++) {
Element e = ele.getElement(i);
AttributeSet as = e.getAttributes();
if (as.getAttribute(StyleConstants.ModelAttribute) != null || as.getAttribute(HTML.Attribute.TYPE) != null) {
String type = (String) as.getAttribute(HTML.Attribute.TYPE);
String name = (String) as.getAttribute(HTML.Attribute.NAME);
Object model = as.getAttribute(StyleConstants.ModelAttribute);
if (// Text area has no HTML.Attribute.TYPE
type == null && model instanceof PlainDocument) {
PlainDocument pd = (PlainDocument) model;
try {
vals.put(name, encode(pd.getText(0, pd.getLength())));
} catch (BadLocationException e1) {
LOGGER.error(e1.getStackTrace());
}
} else if (type == null && model instanceof ComboBoxModel) {
vals.put(name, ((ComboBoxModel) model).getSelectedItem().toString());
} else if ("text".equals(type)) {
PlainDocument pd = (PlainDocument) model;
try {
vals.put(name, encode(pd.getText(0, pd.getLength())));
} catch (BadLocationException e1) {
LOGGER.error(e1.getStackTrace());
}
} else if ("submit".equals(type)) {
// Ignore
} else if ("image".equals(type)) {
if (name != null && name.equals(selectedImageMap)) {
String val = (String) as.getAttribute(HTML.Attribute.VALUE);
vals.put(name + ".value", encode(val == null ? "" : val));
}
} else if ("radio".equals(type)) {
if (as.getAttribute(HTML.Attribute.CHECKED) != null) {
vals.put(name, encode(encode((String) as.getAttribute(HTML.Attribute.VALUE))));
}
} else if ("checkbox".equals(type)) {
if (as.getAttribute(HTML.Attribute.CHECKED) != null) {
vals.put(name, encode(encode((String) as.getAttribute(HTML.Attribute.VALUE))));
}
} else if ("password".equals(type)) {
PlainDocument pd = (PlainDocument) model;
try {
vals.put(name, encode(pd.getText(0, pd.getLength())));
} catch (BadLocationException e1) {
LOGGER.error(e1.getStackTrace());
}
} else if ("hidden".equals(type)) {
vals.put(name, encode(encode((String) as.getAttribute(HTML.Attribute.VALUE))));
}
}
vals.putAll(getDataFrom(e, selectedImageMap));
}
return vals;
}Example 53
| Project: nbruby-master File: FmtOptions.java View source code |
/** Very smart method which tries to set the values in the components correctly
*/
private void loadData(JComponent jc, String optionID, Preferences node) {
if (jc instanceof JTextField) {
JTextField field = (JTextField) jc;
field.setText(node.get(optionID, getDefaultAsString(optionID)));
} else if (jc instanceof JCheckBox) {
JCheckBox checkBox = (JCheckBox) jc;
boolean df = getDefaultAsBoolean(optionID);
checkBox.setSelected(node.getBoolean(optionID, df));
} else if (jc instanceof JComboBox) {
JComboBox cb = (JComboBox) jc;
String value = node.get(optionID, getDefaultAsString(optionID));
ComboBoxModel model = createModel(value);
cb.setModel(model);
ComboItem item = whichItem(value, model);
cb.setSelectedItem(item);
}
}Example 54
| Project: OSMembrane-master File: AutoCompletingComboBox.java View source code |
private Object lookupItem(String pattern) {
ComboBoxModel model = comboBox.getModel();
AutoCompletionListItem bestItem = null;
for (int i = 0, n = model.getSize(); i < n; i++) {
AutoCompletionListItem currentItem = (AutoCompletionListItem) model.getElementAt(i);
if (currentItem.getValue().equals(pattern)) {
return currentItem;
}
if (currentItem.getValue().startsWith(pattern)) {
if (bestItem == null || currentItem.getPriority().compareTo(bestItem.getPriority()) > 0) {
bestItem = currentItem;
}
}
}
// may be null
return bestItem;
}Example 55
| Project: panstamp-tools-master File: SetValueDialog.java View source code |
/**
* return the units available for this endpoint
*/
private void initUnitsCombo() {
ComboBoxModel cbm = new DefaultComboBoxModel(ep.getUnits().toArray(new String[] {}));
switch(cbm.getSize()) {
case 0:
unitComboBox.setEnabled(false);
break;
case 1:
cbm.setSelectedItem(ep.getUnit());
unitComboBox.setEnabled(false);
break;
default:
cbm.setSelectedItem(ep.getUnit());
}
unitComboBox.setModel(cbm);
}Example 56
| Project: ProjectLibre-master File: FindDialog.java View source code |
public void init(Searchable searchable, Field field) {
this.searchable = searchable;
context = searchable.createSearchContext();
if (field != null)
context.setField(field);
ArrayList l = new ArrayList();
l.addAll(searchable.getAvailableFields());
Collections.sort(l);
ComboBoxModel m = new DefaultComboBoxModel(l.toArray());
if (combo == null)
combo = new JComboBox(m);
else
combo.setModel(m);
bind(true);
updateFindButtonState();
search.requestFocus();
//combo.invalidate();
}Example 57
| Project: qi4j-sdk-master File: EntityViewer.java View source code |
/**
* Event Handler for TreePanel
*
* @param evt the Event
*/
public void treePanelValueChanged(TreeSelectionEvent evt) {
TreePath path = evt.getPath();
Object source = path.getLastPathComponent();
if (source == null) {
return;
}
DefaultMutableTreeNode node = (DefaultMutableTreeNode) source;
Object obj = node.getUserObject();
if (obj == null) {
return;
}
Class<?> clazz = obj.getClass();
if (EntityDetailDescriptor.class.isAssignableFrom(clazz)) {
EntityDetailDescriptor entityDesc = (EntityDetailDescriptor) obj;
Class entityType = first(entityDesc.descriptor().types());
// Update the selected item on the combo box, which in turn update the properties table
ComboBoxModel comboModel = entitiesCombo.getModel();
int index = -1;
for (int i = 0; i < comboModel.getSize(); i++) {
EntityDetailDescriptor entityDesc1 = (EntityDetailDescriptor) comboModel.getElementAt(i);
Class entityType1 = first(entityDesc1.descriptor().types());
if (entityType1.equals(entityType)) {
index = i;
break;
}
}
if (index >= 0) {
entitiesCombo.setSelectedIndex(index);
}
}
}Example 58
| Project: SikuliX-2014-master File: JXSearchPanel.java View source code |
//--------------------- binding support
/**
* bind the components to the patternModel/actions.
*/
@Override
protected void bind() {
super.bind();
List<?> matchRules = getPatternModel().getMatchRules();
// PENDING: map rules to localized strings
ComboBoxModel model = new DefaultComboBoxModel(matchRules.toArray());
model.setSelectedItem(getPatternModel().getMatchRule());
searchCriteria.setModel(model);
searchCriteria.setAction(getAction(MATCH_RULE_ACTION_COMMAND));
searchCriteria.setRenderer(new DefaultListRenderer(createStringValue(getLocale())));
}Example 59
| Project: som-master File: SOMNewLearningDialog.java View source code |
/**
* Assessor for GUI creation (Sorry about the method size. But this method
* will just create the Dialog components).
*
* @param samples - Sample names.
*
* @author Leonardo Bispo de Oliveira and Daniele Sunaga de Oliveira.
*
*/
private final void startGui(String samples[]) {
int xl, yl, xs, ys;
Dimension size;
JRadioButton radio;
JPanel controlPanel, mainPanel;
JButton cancelButton, saveButton;
JLabel label;
SpinnerModel spinnerModel;
ComboBoxModel sampleModel;
learningVO = null;
sampleModel = new DefaultComboBoxModel(samples);
controlPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
saveButton = new JButton(resourceBundle.getString(SAVE_BUTTON));
cancelButton = new JButton(resourceBundle.getString(CANCEL_BUTTON));
cancelButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
dispose();
}
});
saveButton.addActionListener(new ActionListener() {
SelfOrganizingMap som;
public void actionPerformed(ActionEvent arg0) {
if (txtName.getText().equals("")) {
JOptionPane.showMessageDialog(SOMNewLearningDialog.this, SOMNewLearningDialog.this.resourceBundle.getString(NAME_ERROR), SOMNewLearningDialog.this.resourceBundle.getString(SOMMainWindow.ERROR_ALERT), JOptionPane.ERROR_MESSAGE);
return;
}
if (!uniqueSample) {
if (cmbSample.getSelectedIndex() == 0) {
JOptionPane.showMessageDialog(SOMNewLearningDialog.this, SOMNewLearningDialog.this.resourceBundle.getString(SAMPLE_ERROR), SOMNewLearningDialog.this.resourceBundle.getString(SOMMainWindow.ERROR_ALERT), JOptionPane.ERROR_MESSAGE);
return;
} else {
try {
som = new SelfOrganizingMap(SOMMainWindow.DEFAULT_ITERATION, sampleList.get(cmbSample.getSelectedIndex() - 1));
} catch (SOMException e) {
System.err.println("[ERROR] Problems when I try to create a SOM!");
e.printStackTrace();
System.exit(1);
}
}
} else {
try {
som = new SelfOrganizingMap(SOMMainWindow.DEFAULT_ITERATION, sampleList.get(0));
} catch (SOMException e) {
System.err.println("[ERROR] Problems when I try to create a SOM!");
e.printStackTrace();
System.exit(1);
}
}
learningVO = new SOMLearningVO(((SpinnerNumberModel) spnWidth.getModel()).getNumber().intValue(), ((SpinnerNumberModel) spnHeight.getModel()).getNumber().intValue(), txtName.getText(), (String) cmbSample.getSelectedItem(), som);
dispose();
}
});
controlPanel.add(saveButton);
controlPanel.add(cancelButton);
getContentPane().add(controlPanel, BorderLayout.SOUTH);
mainPanel = new JPanel(new AbsoluteLayout());
label = new JLabel(new ImageIcon("/images/learning_process.gif"));
label.setBounds(7, 7, 154, 243);
label.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED));
mainPanel.add(label);
label = new JLabel(resourceBundle.getString(NAME_LABEL));
label.setBounds(175, 20, 35, 21);
mainPanel.add(label);
label = new JLabel(resourceBundle.getString(SAMPLE_LABEL));
label.setBounds(175, 60, 35, 21);
mainPanel.add(label);
label = new JLabel(resourceBundle.getString(WIDTH_LABEL));
label.setBounds(175, 100, 35, 21);
mainPanel.add(label);
label = new JLabel(resourceBundle.getString(HEIGHT_LABEL));
label.setBounds(378, 100, 35, 21);
mainPanel.add(label);
label = new JLabel();
label.setBounds(175, 140, 370, 100);
label.setBorder(BorderFactory.createTitledBorder(resourceBundle.getString(DISTANCE_LABEL)));
label.setPreferredSize(new Dimension(370, 100));
radio = new JRadioButton();
radio.setText(resourceBundle.getString(EUCLIDEAN_LABEL));
radio.setBounds(14, 29, 300, 21);
radio.setSelected(true);
label.add(radio);
mainPanel.add(label);
label = new JLabel();
label.setBounds(175, 270, 370, 100);
label.setBorder(BorderFactory.createTitledBorder(resourceBundle.getString(NEIGHBORS_LABEL)));
label.setPreferredSize(new Dimension(370, 100));
radio = new JRadioButton();
radio.setText(resourceBundle.getString(GAUSSIAN_LABEL));
radio.setBounds(14, 29, 300, 21);
radio.setSelected(true);
label.add(radio);
mainPanel.add(label);
txtName = new JTextField();
txtName.setBounds(245, 20, 300, 21);
txtName.setPreferredSize(new Dimension(300, 21));
mainPanel.add(txtName);
cmbSample = new JComboBox();
cmbSample.setModel(sampleModel);
cmbSample.setBounds(245, 60, 300, 21);
cmbSample.setPreferredSize(new Dimension(300, 21));
if (uniqueSample)
cmbSample.setEnabled(false);
mainPanel.add(cmbSample);
spinnerModel = new SpinnerNumberModel(5, 1, 50, 1);
spnWidth = new JSpinner(spinnerModel);
spnWidth.setBounds(245, 100, 80, 21);
spnWidth.setPreferredSize(new Dimension(80, 21));
mainPanel.add(spnWidth);
spinnerModel = new SpinnerNumberModel(5, 1, 50, 1);
spnHeight = new JSpinner(spinnerModel);
spnHeight.setBounds(465, 100, 80, 21);
spnHeight.setPreferredSize(new Dimension(80, 21));
mainPanel.add(spnHeight);
getContentPane().add(mainPanel, BorderLayout.CENTER);
setSize(577, 443);
setResizable(false);
setAlwaysOnTop(true);
setModal(true);
xs = getWidth();
ys = getHeight();
size = getToolkit().getScreenSize();
xl = (size.width / 2) - (xs / 2);
yl = (size.height / 2) - (ys / 2);
setBounds(xl, yl, xs, ys);
}Example 60
| Project: spring-rich-client-master File: ComboBoxBindingTests.java View source code |
public void testWithListModel() throws Exception {
DefaultListModel model = new DefaultListModel();
model.addElement("1");
model.addElement("2");
model.addElement("3");
model.addElement("4");
cbb.setSelectableItems(model);
cbb.doBindControl();
ComboBoxModel cbmodel = cb.getModel();
assertEquals(model.getSize(), cbmodel.getSize());
for (int i = 0, size = model.size(); i < size; i++) {
assertEquals(model.getElementAt(i), cbmodel.getElementAt(i));
}
}Example 61
| Project: springrcp-master File: ComboBoxBindingTests.java View source code |
public void testWithListModel() throws Exception {
DefaultListModel model = new DefaultListModel();
model.addElement("1");
model.addElement("2");
model.addElement("3");
model.addElement("4");
cbb.setSelectableItems(model);
cbb.doBindControl();
ComboBoxModel cbmodel = cb.getModel();
assertEquals(model.getSize(), cbmodel.getSize());
for (int i = 0, size = model.size(); i < size; i++) {
assertEquals(model.getElementAt(i), cbmodel.getElementAt(i));
}
}Example 62
| Project: tabletoptool-master File: HTMLPaneFormView.java View source code |
private Map<String, String> getDataFrom(Element ele, String selectedImageMap) {
Map<String, String> vals = new HashMap<String, String>();
for (int i = 0; i < ele.getElementCount(); i++) {
Element e = ele.getElement(i);
AttributeSet as = e.getAttributes();
if (as.getAttribute(StyleConstants.ModelAttribute) != null || as.getAttribute(HTML.Attribute.TYPE) != null) {
String type = (String) as.getAttribute(HTML.Attribute.TYPE);
String name = (String) as.getAttribute(HTML.Attribute.NAME);
Object model = as.getAttribute(StyleConstants.ModelAttribute);
if (// Text area has no HTML.Attribute.TYPE
type == null && model instanceof PlainDocument) {
PlainDocument pd = (PlainDocument) model;
try {
vals.put(name, encode(pd.getText(0, pd.getLength())));
} catch (BadLocationException e1) {
LOGGER.error(e1.getStackTrace());
}
} else if (type == null && model instanceof ComboBoxModel) {
vals.put(name, ((ComboBoxModel) model).getSelectedItem().toString());
} else if ("text".equals(type)) {
PlainDocument pd = (PlainDocument) model;
try {
vals.put(name, encode(pd.getText(0, pd.getLength())));
} catch (BadLocationException e1) {
LOGGER.error(e1.getStackTrace());
}
} else if ("submit".equals(type)) {
// Ignore
} else if ("image".equals(type)) {
if (name != null && name.equals(selectedImageMap)) {
String val = (String) as.getAttribute(HTML.Attribute.VALUE);
vals.put(name + ".value", encode(val == null ? "" : val));
}
} else if ("radio".equals(type)) {
if (as.getAttribute(HTML.Attribute.CHECKED) != null) {
vals.put(name, encode(encode((String) as.getAttribute(HTML.Attribute.VALUE))));
}
} else if ("checkbox".equals(type)) {
if (as.getAttribute(HTML.Attribute.CHECKED) != null) {
vals.put(name, encode(encode((String) as.getAttribute(HTML.Attribute.VALUE))));
}
} else if ("password".equals(type)) {
PlainDocument pd = (PlainDocument) model;
try {
vals.put(name, encode(pd.getText(0, pd.getLength())));
} catch (BadLocationException e1) {
LOGGER.error(e1.getStackTrace());
}
} else if ("hidden".equals(type)) {
vals.put(name, encode(encode((String) as.getAttribute(HTML.Attribute.VALUE))));
}
}
vals.putAll(getDataFrom(e, selectedImageMap));
}
return vals;
}Example 63
| Project: xmax-master File: ViewSpectra.java View source code |
private JComboBox<Object> getConvolveCB() {
if (convolveCB == null) {
List<String> options = new ArrayList<String>();
options.add("None");
for (Response resp : TraceView.getDataModule().getLoadedResponses()) {
options.add(resp.getLocalFileName());
}
ComboBoxModel<Object> convolveCBModel = new DefaultComboBoxModel<Object>(options.toArray());
convolveCB = new JComboBox<Object>();
convolveCB.setModel(convolveCBModel);
convolveCB.setPreferredSize(new java.awt.Dimension(128, 22));
convolveCB.setEnabled(false);
convolveCB.addItemListener(this);
}
return convolveCB;
}Example 64
| Project: antlrworks2-master File: CategorySupport.java View source code |
/** Very smart method which tries to set the values in the components correctly
*/
@SuppressWarnings("unchecked")
private void loadData(JComponent jc, AbstractFormatOption optionID, Preferences node) {
if (jc instanceof JTextField) {
JTextField field = (JTextField) jc;
field.setText(optionID.getValueAsString(node));
} else if (jc instanceof JToggleButton) {
JToggleButton toggle = (JToggleButton) jc;
toggle.setSelected(((BooleanFormatOption) optionID).getValue(node));
} else if (jc instanceof JComboBox) {
@SuppressWarnings("rawtypes") JComboBox cb = (JComboBox) jc;
Enum<?> value = ((EnumFormatOption<?>) optionID).getValue(node);
@SuppressWarnings("rawtypes") ComboBoxModel model = createModel(value);
cb.setModel(model);
ComboItem item = whichItem(value, model);
cb.setSelectedItem(item);
}
}Example 65
| Project: DLect-master File: AdvancedPlaylistSettingsPanel.java View source code |
private EnumMap<DownloadType, JComboBox> addDownloadTypeBoxes(final String postfix, GridBagConstraints gbc, boolean enabled, Formatter f) {
EnumMap<DownloadType, JComboBox> type = new EnumMap<DownloadType, JComboBox>(DownloadType.class);
for (DownloadType downloadType : DownloadType.values()) {
String label = downloadType + " " + postfix + " Style:";
ComboBoxModel m = new EnumComboBoxModel<DownloadType>(DownloadType.class, "None");
JLabel l = new JLabel(label);
JComboBox c = new JComboBox(m);
c.setEnabled(enabled);
//c.setSelectedItem(f.getNullableFormat(downloadType));
c.addActionListener(this);
gbc.gridy++;
gbc.gridx = 0;
gbc.gridwidth = 1;
gbc.weightx = 0;
gbc.fill = GridBagConstraints.NONE;
this.add(l, gbc);
gbc.gridx = 1;
gbc.gridwidth = 2;
gbc.weightx = 1;
gbc.fill = GridBagConstraints.BOTH;
this.add(c, gbc);
type.put(downloadType, c);
}
return type;
}Example 66
| Project: FEMultiplayer-master File: FEServer.java View source code |
public static void main(String[] args) {
final JFrame frame = new JFrame("FEServer");
Rout rout = new Rout();
Seize seize = new Seize();
maps = new HashMap<String, Objective[]>();
maps.put("town", new Objective[] { rout });
maps.put("plains", new Objective[] { rout, seize });
maps.put("fort", new Objective[] { rout, seize });
maps.put("decay", new Objective[] { rout, seize });
frame.getContentPane().setLayout(new BorderLayout(0, 0));
DefaultListModel sModel = new DefaultListModel();
// Modifiers
DefaultListModel model = new DefaultListModel();
model.addElement(new MadeInChina());
model.addElement(new Treasury());
model.addElement(new Veterans());
model.addElement(new DivineIntervention());
model.addElement(new SuddenDeath());
model.addElement(new Vegas());
final JPanel mainPanel = new JPanel();
frame.getContentPane().add(mainPanel, BorderLayout.CENTER);
mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
JPanel mapPanel = new JPanel();
mainPanel.add(mapPanel);
mapPanel.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
JLabel mapNameLabel = new JLabel("Map: ");
mapPanel.add(mapNameLabel);
JPanel objectivePanel = new JPanel();
mainPanel.add(objectivePanel);
JLabel objLabel = new JLabel("Objective: ");
objectivePanel.add(objLabel);
final JComboBox objComboBox = new JComboBox();
objectivePanel.add(objComboBox);
// populate list of maps
final JComboBox mapSelectionBox = new JComboBox();
mapSelectionBox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
objComboBox.setModel(new DefaultComboBoxModel(maps.get(mapSelectionBox.getSelectedItem())));
}
});
mapPanel.add(mapSelectionBox);
mapSelectionBox.setModel(new DefaultComboBoxModel(maps.keySet().toArray()));
JLabel label = new JLabel("Max units: ");
mapPanel.add(label);
final JSpinner maxUnitsSpinner = new JSpinner();
mapPanel.add(maxUnitsSpinner);
maxUnitsSpinner.setModel(new SpinnerNumberModel(8, 1, 8, 1));
// Objectives
ComboBoxModel oModel = new DefaultComboBoxModel(maps.get(mapSelectionBox.getSelectedItem()));
objComboBox.setModel(oModel);
JLabel lblPickMode = new JLabel("Pick mode: ");
objectivePanel.add(lblPickMode);
// Pick modes
ComboBoxModel pModel = new DefaultComboBoxModel(new PickMode[] { new Draft(), new AllPick() });
final JComboBox pickModeBox = new JComboBox();
pickModeBox.setModel(pModel);
objectivePanel.add(pickModeBox);
JSeparator separator = new JSeparator();
mainPanel.add(separator);
JLabel modifiersLabel = new JLabel("Modifiers");
modifiersLabel.setAlignmentX(Component.CENTER_ALIGNMENT);
mainPanel.add(modifiersLabel);
JPanel modifiersPane = new JPanel();
mainPanel.add(modifiersPane);
modifiersPane.setLayout(new BoxLayout(modifiersPane, BoxLayout.X_AXIS));
JScrollPane selectedModifiersScrollPane = new JScrollPane();
selectedModifiersScrollPane.setPreferredSize(new Dimension(120, 150));
modifiersPane.add(selectedModifiersScrollPane);
JScrollPane modifiersScrollPane = new JScrollPane();
modifiersScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
modifiersScrollPane.setPreferredSize(new Dimension(120, 150));
final ModifierList modifiersList = new ModifierList();
modifiersList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
modifiersScrollPane.add(modifiersList);
modifiersList.setModel(model);
modifiersScrollPane.setViewportView(modifiersList);
final ModifierList selectedModifiersList = new ModifierList();
selectedModifiersList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
selectedModifiersScrollPane.add(selectedModifiersList);
selectedModifiersList.setModel(sModel);
selectedModifiersScrollPane.setViewportView(selectedModifiersList);
JPanel buttonsPanel = new JPanel();
modifiersPane.add(buttonsPanel);
JButton addModifierBtn = new JButton("<-- Add");
addModifierBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
int index = modifiersList.getSelectedIndex();
if (index != -1) {
Object o = modifiersList.getModel().getElementAt(index);
((DefaultListModel) modifiersList.getModel()).remove(modifiersList.getSelectedIndex());
((DefaultListModel) selectedModifiersList.getModel()).add(0, o);
}
}
});
buttonsPanel.setLayout(new GridLayout(0, 1, 0, 0));
buttonsPanel.add(addModifierBtn);
JButton removeModifierBtn = new JButton("Remove -->");
removeModifierBtn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int index = selectedModifiersList.getSelectedIndex();
if (index != -1) {
Object o = selectedModifiersList.getModel().getElementAt(index);
((DefaultListModel) selectedModifiersList.getModel()).remove(selectedModifiersList.getSelectedIndex());
((DefaultListModel) modifiersList.getModel()).add(0, o);
}
}
});
buttonsPanel.add(removeModifierBtn);
modifiersPane.add(modifiersScrollPane);
Component verticalStrut = Box.createVerticalStrut(20);
mainPanel.add(verticalStrut);
final JButton startServer = new JButton("Start server");
startServer.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
frame.getContentPane().add(new JLabel("Server IP: " + InetAddress.getLocalHost().getHostAddress()) {
private static final long serialVersionUID = 1L;
{
this.setFont(getFont().deriveFont(20f));
this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
}
}, BorderLayout.NORTH);
frame.remove(mainPanel);
frame.remove(startServer);
} catch (UnknownHostException e1) {
e1.printStackTrace();
}
frame.pack();
Thread serverThread = new Thread() {
public void run() {
FEServer feserver = new FEServer();
try {
Session s = FEServer.getServer().getSession();
s.setMaxUnits((Integer) maxUnitsSpinner.getValue());
for (int i = 0; i < selectedModifiersList.getModel().getSize(); i++) {
Modifier m = (Modifier) selectedModifiersList.getModel().getElementAt(i);
s.addModifier(m);
}
s.setMap((String) mapSelectionBox.getSelectedItem());
s.setObjective((Objective) objComboBox.getSelectedItem());
s.setPickMode((PickMode) pickModeBox.getSelectedItem());
feserver.init();
feserver.loop();
} catch (Exception e) {
System.err.println("Exception occurred, writing to logs...");
e.printStackTrace();
try {
File errLog = new File("error_log_server" + System.currentTimeMillis() % 100000000 + ".log");
PrintWriter pw = new PrintWriter(errLog);
e.printStackTrace(pw);
pw.close();
} catch (IOException e2) {
e2.printStackTrace();
}
System.exit(0);
}
}
};
serverThread.start();
}
});
frame.getContentPane().add(startServer, BorderLayout.SOUTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setVisible(true);
}Example 67
| Project: FreeRoute-master File: WindowManualRules.java View source code |
/**
* Recalculates the values in the trace width fields.
*/
public void refresh() {
board.RoutingBoard routing_board = board_handling.get_routing_board();
javax.swing.ComboBoxModel new_model = new javax.swing.DefaultComboBoxModel(routing_board.rules.via_rules);
this.via_rule_combo_box.setModel(new_model);
rules.ClearanceMatrix clearance_matrix = board_handling.get_routing_board().rules.clearance_matrix;
if (this.clearance_combo_box.get_class_count() != routing_board.rules.clearance_matrix.get_class_count()) {
this.clearance_combo_box.adjust(clearance_matrix);
}
this.clearance_combo_box.setSelectedIndex(board_handling.settings.get_manual_trace_clearance_class());
int via_rule_index = board_handling.settings.get_manual_via_rule_index();
if (via_rule_index < this.via_rule_combo_box.getItemCount()) {
this.via_rule_combo_box.setSelectedIndex(board_handling.settings.get_manual_via_rule_index());
}
this.set_selected_layer(this.layer_combo_box.get_selected_layer());
this.repaint();
}Example 68
| Project: Freerouting-master File: WindowManualRules.java View source code |
/**
* Recalculates the values in the trace width fields.
*/
public void refresh() {
board.RoutingBoard routing_board = board_handling.get_routing_board();
javax.swing.ComboBoxModel new_model = new javax.swing.DefaultComboBoxModel(routing_board.rules.via_rules);
this.via_rule_combo_box.setModel(new_model);
rules.ClearanceMatrix clearance_matrix = board_handling.get_routing_board().rules.clearance_matrix;
if (this.clearance_combo_box.get_class_count() != routing_board.rules.clearance_matrix.get_class_count()) {
this.clearance_combo_box.adjust(clearance_matrix);
}
this.clearance_combo_box.setSelectedIndex(board_handling.settings.get_manual_trace_clearance_class());
int via_rule_index = board_handling.settings.get_manual_via_rule_index();
if (via_rule_index < this.via_rule_combo_box.getItemCount()) {
this.via_rule_combo_box.setSelectedIndex(board_handling.settings.get_manual_via_rule_index());
}
this.set_selected_layer(this.layer_combo_box.get_selected_layer());
this.repaint();
}Example 69
| Project: goworks-master File: CategorySupport.java View source code |
/** Very smart method which tries to set the values in the components correctly
*/
@SuppressWarnings("unchecked")
private void loadData(JComponent jc, AbstractFormatOption optionID, Preferences node) {
if (jc instanceof JTextField) {
JTextField field = (JTextField) jc;
field.setText(optionID.getValueAsString(node));
} else if (jc instanceof JToggleButton) {
JToggleButton toggle = (JToggleButton) jc;
toggle.setSelected(((BooleanFormatOption) optionID).getValue(node));
} else if (jc instanceof JComboBox) {
@SuppressWarnings("rawtypes") JComboBox cb = (JComboBox) jc;
Enum<?> value = ((EnumFormatOption<?>) optionID).getValue(node);
@SuppressWarnings("rawtypes") ComboBoxModel model = createModel(value);
cb.setModel(model);
ComboItem item = whichItem(value, model);
cb.setSelectedItem(item);
}
}Example 70
| Project: gtitool-master File: TinyComboBoxUI.java View source code |
/**
* Copied from BasicComboBoxUI, because isDisplaySizeDirty was declared
* private!? Returns the calculated size of the display area. The display area
* is the portion of the combo box in which the selected item is displayed.
* This method will use the prototype display value if it has been set.
* <p>
* For combo boxes with a non trivial number of items, it is recommended to
* use a prototype display value to significantly speed up the display size
* calculation.
*
* @return the size of the display area calculated from the combo box items
* @see javax.swing.JComboBox#setPrototypeDisplayValue
*/
protected Dimension getDisplaySize() {
if (!isDisplaySizeDirty) {
return new Dimension(cachedDisplaySize);
}
Dimension result = new Dimension();
ListCellRenderer renderer = comboBox.getRenderer();
if (renderer == null) {
renderer = new DefaultListCellRenderer();
}
Object prototypeValue = comboBox.getPrototypeDisplayValue();
if (prototypeValue != null) {
// Calculates the dimension based on the prototype value
result = getSizeForComponent(renderer.getListCellRendererComponent(listBox, prototypeValue, -1, false, false));
} else {
// Calculate the dimension by iterating over all the elements in the combo
// box list.
ComboBoxModel model = comboBox.getModel();
int modelSize = model.getSize();
Dimension d;
Component cpn;
if (modelSize > 0) {
for (int i = 0; i < modelSize; i++) {
// Calculates the maximum height and width based on the largest
// element
d = getSizeForComponent(renderer.getListCellRendererComponent(listBox, model.getElementAt(i), -1, false, false));
result.width = Math.max(result.width, d.width);
result.height = Math.max(result.height, d.height);
}
} else {
result = getDefaultSize();
if (comboBox.isEditable()) {
result.width = 100;
}
}
}
if (comboBox.isEditable()) {
Dimension d = editor.getPreferredSize();
result.width = Math.max(result.width, d.width);
result.height = Math.max(result.height, d.height);
}
// Set the cached value
cachedDisplaySize.setSize(result.width, result.height);
isDisplaySizeDirty = false;
return result;
}Example 71
| Project: jbox2d-master File: TestbedSidePanel.java View source code |
public void initComponents() {
// setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
TestbedSettings settings = model.getSettings();
VBox top = new VBox();
// top.setLayout(new GridLayout(0, 1));
// top.setBorder(BorderFactory.createCompoundBorder(new EtchedBorder(EtchedBorder.LOWERED),
// BorderFactory.createEmptyBorder(10, 10, 10, 10)));
DefaultComboBoxModel testList = model.getComboModel();
testList.addListDataListener(new ListDataListener() {
@Override
public void intervalRemoved(ListDataEvent e) {
updateTests((ComboBoxModel<ListItem>) e.getSource());
}
@Override
public void intervalAdded(ListDataEvent e) {
updateTests((ComboBoxModel<ListItem>) e.getSource());
}
@Override
public void contentsChanged(ListDataEvent e) {
updateTests((ComboBoxModel<ListItem>) e.getSource());
}
});
tests = new ComboBox<ListItem>();
updateTests((ComboBoxModel<ListItem>) testList);
tests.setOnAction(( actionEvent) -> {
testSelected();
});
tests.setCellFactory(ComboBoxListCell.<ListItem>forListView(new StringConverter<ListItem>() {
@Override
public String toString(ListItem listItem) {
if (listItem == null) {
return ("");
} else if (listItem.isCategory()) {
return (listItem.category);
} else {
return (listItem.test.getTestName());
}
}
@Override
public ListItem fromString(String string) {
return null;
}
}, tests.getItems()));
top.getChildren().add(new Label("Choose a test:"));
top.getChildren().add(tests);
addSettings(top, settings, SettingType.DRAWING);
setTop(top);
VBox middle = new VBox();
// middle.setLayout(new GridLayout(0, 1));
// middle.setBorder(BorderFactory.createCompoundBorder(new EtchedBorder(EtchedBorder.LOWERED),
// BorderFactory.createEmptyBorder(5, 10, 5, 10)));
addSettings(middle, settings, SettingType.ENGINE);
setCenter(middle);
pauseButton.setAlignment(Pos.CENTER);
stepButton.setAlignment(Pos.CENTER);
resetButton.setAlignment(Pos.CENTER);
saveButton.setAlignment(Pos.CENTER);
loadButton.setAlignment(Pos.CENTER);
quitButton.setAlignment(Pos.CENTER);
HBox buttonGroups = new HBox();
VBox buttons1 = new VBox();
buttons1.getChildren().add(resetButton);
VBox buttons2 = new VBox();
buttons2.getChildren().add(pauseButton);
buttons2.getChildren().add(stepButton);
VBox buttons3 = new VBox();
buttons3.getChildren().add(saveButton);
buttons3.getChildren().add(loadButton);
buttons3.getChildren().add(quitButton);
buttonGroups.getChildren().add(buttons1);
buttonGroups.getChildren().add(buttons2);
buttonGroups.getChildren().add(buttons3);
setBottom(buttonGroups);
}Example 72
| Project: josm-master File: AutoCompletingComboBox.java View source code |
private Object lookupItem(String pattern, boolean match) {
ComboBoxModel<AutoCompletionListItem> model = comboBox.getModel();
AutoCompletionListItem bestItem = null;
for (int i = 0, n = model.getSize(); i < n; i++) {
AutoCompletionListItem currentItem = model.getElementAt(i);
if (currentItem.getValue().equals(pattern))
return currentItem;
if (!match && currentItem.getValue().startsWith(pattern) && (bestItem == null || currentItem.getPriority().compareTo(bestItem.getPriority()) > 0)) {
bestItem = currentItem;
}
}
// may be null
return bestItem;
}Example 73
| Project: jpexs-decompiler-master File: FontPreviewDialog.java View source code |
private ComboBoxModel<String> getModel() {
List<String> sampleTexts = new ArrayList<>();
BufferedReader br = new BufferedReader(new InputStreamReader(FontPreviewDialog.class.getResourceAsStream("/com/jpexs/decompiler/flash/tags/font/font_preview_samples.txt"), Utf8Helper.charset));
String s;
try {
while ((s = br.readLine()) != null) {
sampleTexts.add(s);
}
} catch (IOException ex) {
Logger.getLogger(FontPreviewDialog.class.getName()).log(Level.SEVERE, "Cannot read font preview dialog sample texts", ex);
}
return new DefaultComboBoxModel<>(sampleTexts.toArray(new String[sampleTexts.size()]));
}Example 74
| Project: mct-master File: TableSettingsControlPanelDemo.java View source code |
protected static void createAndShowGUI() {
JFrame frame = new JFrame("Table Settings Dialog");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
TableSettingsController controller = new TableSettingsController() {
@Override
public boolean getShowGrid() {
return true;
}
@Override
public boolean selectedCellsHaveMixedEnumerations() {
return true;
}
@Override
public TableOrientation getTableOrientation() {
return TableOrientation.ROW_MAJOR;
}
@Override
public void setShowGrid(boolean showGrid) {
System.out.println("New show grid: " + showGrid);
}
@Override
public void setTableOrientation(TableOrientation orientation) {
System.out.println("New table orientation: " + orientation);
}
@Override
public void transposeTable() {
// TODO Auto-generated method stub
}
@Override
public int getSelectedCellCount() {
return 1;
}
@Override
public int getSelectedColumnCount() {
return 1;
}
@Override
public int getSelectedRowCount() {
return 1;
}
@Override
public boolean isCanHideHeaders() {
return true;
}
@Override
public int getColumnWidth() {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getRowHeight() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void setColumnWidth(int newWidth) {
// TODO Auto-generated method stub
}
@Override
public void setRowHeight(int newHeight) {
// TODO Auto-generated method stub
}
@Override
public ComboBoxModel getEnumerationModel() {
DefaultComboBoxModel model = new DefaultComboBoxModel(new Object[] { "one", "two", "three" });
model.setSelectedItem("two");
return model;
}
@Override
public void setEnumeration(ComboBoxModel model) {
// TODO Auto-generated method stub
}
@Override
public void setDecimalPlaces(ComboBoxModel model) {
// TODO Auto-generated method stub
}
@Override
public boolean showDecimalPlaces() {
// TODO Auto-generated method stub
return false;
}
@Override
public Integer getDecimalPlaces() {
// TODO Auto-generated method stub
return 0;
}
@Override
public boolean canSetOrientation() {
return true;
}
@Override
public boolean canTranspose() {
return true;
}
@Override
public AbbreviationSettings getCellLabelAbbreviationSettings() {
return TableSettingsControlPanelDemo.getAbbreviationSettings("Voltage");
}
@Override
public AbbreviationSettings getColumnLabelAbbreviationSettings() {
return TableSettingsControlPanelDemo.getAbbreviationSettings("Fiber Optic MDC System");
}
@Override
public AbbreviationSettings getRowLabelAbbreviationSettings() {
return TableSettingsControlPanelDemo.getAbbreviationSettings("Channel 1 Video Baseband Signal Processor");
}
@Override
public void setCellLabelAbbreviations(AbbreviationSettings settings) {
// TODO Auto-generated method stub
}
@Override
public void setColumnLabelAbbreviations(AbbreviationSettings settings) {
// TODO Auto-generated method stub
}
@Override
public void setRowLabelAbbreviations(AbbreviationSettings settings) {
// TODO Auto-generated method stub
}
@Override
public ContentAlignment getRowHeaderAlignment() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setRowHeaderAlignment(ContentAlignment newAlignment) {
// TODO Auto-generated method stub
}
@Override
public ContentAlignment getColumnHeaderAlignment() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setColumnHeaderAlignment(ContentAlignment newAlignment) {
// TODO Auto-generated method stub
}
@Override
public ContentAlignment getCellAlignment() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setCellAlignment(ContentAlignment newAlignment) {
// TODO Auto-generated method stub
}
@Override
public int getTableRowCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public int getTableColumnCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public void setDateFormat(ComboBoxModel model) {
// TODO Auto-generated method stub
}
@Override
public DateFormatItem getDateFormat() {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean enumerationIsNone(ComboBoxModel model) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean dateIsNone(ComboBoxModel model) {
// TODO Auto-generated method stub
return false;
}
@Override
public BorderState getBorderState() {
// TODO Auto-generated method stub
return null;
}
@Override
public void mergeBorderState(BorderState controllerState) {
// TODO Auto-generated method stub
}
@Override
public JVMFontFamily getCellFontName() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setCellFont(ComboBoxModel model) {
// TODO Auto-generated method stub
}
@Override
public void setRowHeaderFontName(ComboBoxModel model) {
// TODO Auto-generated method stub
}
@Override
public void setColumnHeaderFontName(ComboBoxModel model) {
// TODO Auto-generated method stub
}
@Override
public JVMFontFamily getRowHeaderFontName() {
// TODO Auto-generated method stub
return null;
}
@Override
public JVMFontFamily getColumnHeaderFontName() {
// TODO Auto-generated method stub
return null;
}
@Override
public void mergeCellFontStyle(ButtonModel boldModel, ButtonModel italicModel) {
// TODO Auto-generated method stub
}
@Override
public void setCellFontStyle(int newStyle) {
// TODO Auto-generated method stub
}
@Override
public void setRowHeaderFontStyle(int newStyle) {
// TODO Auto-generated method stub
}
@Override
public void setColumnHeaderFontStyle(int newStyle) {
// TODO Auto-generated method stub
}
@Override
public void setCellFontSize(int fontSize) {
// TODO Auto-generated method stub
}
@Override
public void setRowHeaderFontSize(int fontSize) {
// TODO Auto-generated method stub
}
@Override
public void setColumnHeaderFontSize(int fontSize) {
// TODO Auto-generated method stub
}
@Override
public void setCellFontColor(Color fontColor) {
// TODO Auto-generated method stub
}
@Override
public void setRowHeaderFontColor(Color fontCOlor) {
// TODO Auto-generated method stub
}
@Override
public void setColumnHeaderFontColor(Color fontColor) {
// TODO Auto-generated method stub
}
@Override
public Integer getCellFontStyle() {
// TODO Auto-generated method stub
return null;
}
@Override
public Integer getRowFontStyle() {
// TODO Auto-generated method stub
return null;
}
@Override
public Integer getColumnHeaderFontStyle() {
// TODO Auto-generated method stub
return null;
}
@Override
public Integer getCellFontSize() {
// TODO Auto-generated method stub
return null;
}
@Override
public Integer getRowHeaderFontSize() {
// TODO Auto-generated method stub
return null;
}
@Override
public Integer getColumnHeaderFontSize() {
// TODO Auto-generated method stub
return null;
}
@Override
public Color getCellFontColor() {
// TODO Auto-generated method stub
return null;
}
@Override
public Color getRowHeaderFontColor() {
// TODO Auto-generated method stub
return null;
}
@Override
public Color getColumnHeaderFontColor() {
// TODO Auto-generated method stub
return null;
}
@Override
public Color getRowHeaderBackgroundColor() {
// TODO Auto-generated method stub
return null;
}
@Override
public Color getColumnHeaderBackgroundColor() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setRowHeaderBackgroundColor(Color fontColor) {
// TODO Auto-generated method stub
}
@Override
public void setColumnHeaderBackgroundColor(Color fontColor) {
// TODO Auto-generated method stub
}
@Override
public void setCellBackgroundColor(Color backgroundColor) {
// TODO Auto-generated method stub
}
@Override
public Color getCellBackgroundColor() {
// TODO Auto-generated method stub
return null;
}
@Override
public Integer getRowHeaderTextAttribute() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setRowHeaderTextAttribute(int newTextAttribute) {
// TODO Auto-generated method stub
}
@Override
public void setColumnHeaderTextAttribute(int newTextAttribute) {
// TODO Auto-generated method stub
}
@Override
public Integer getColumnHeaderTextAttribute() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setCellFontTextAttribute(int fontStyle) {
// TODO Auto-generated method stub
}
@Override
public Integer getCellFontTextAttribute() {
// TODO Auto-generated method stub
return null;
}
@Override
public BorderState getRowHeaderBorderState() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setRowHeaderBorderState(BorderState newBorderState) {
// TODO Auto-generated method stub
}
@Override
public BorderState getColumnHeaderBorderState() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setColumnHeaderBorderState(BorderState newBorderState) {
// TODO Auto-generated method stub
}
@Override
public void mergeRowHeaderBorderState(BorderState controllerState) {
// TODO Auto-generated method stub
}
@Override
public void mergeColumnHeaderBorderState(BorderState controllerState) {
// TODO Auto-generated method stub
}
@Override
public Color getRowHeaderBorderColor() {
// TODO Auto-generated method stub
return null;
}
@Override
public Color getColumnHeaderBorderColor() {
// TODO Auto-generated method stub
return null;
}
@Override
public void setRowHeaderBorderColor(Color borderColor) {
// TODO Auto-generated method stub
}
@Override
public void setColumnHeaderBorderColor(Color borderColor) {
// TODO Auto-generated method stub
}
};
//Create and set up the content pane.
TableSettingsControlPanel panel = new TableSettingsControlPanel(controller);
//content panes must be opaque
panel.setOpaque(true);
frame.setContentPane(panel);
//Display the window.
frame.pack();
frame.setVisible(true);
}Example 75
| Project: nbgit-master File: UpdatePanel.java View source code |
// </editor-fold>//GEN-END:initComponents
/**
* Must NOT be run from AWT.
*/
private void setupModels() {
// XXX attach Cancelable hook
// NOI18N
final ProgressHandle ph = ProgressHandleFactory.createHandle(NbBundle.getMessage(RevertModificationsPanel.class, "MSG_Refreshing_Update_Versions"));
try {
Set<String> initialRevsSet = new LinkedHashSet<String>();
// NOI18N
initialRevsSet.add(NbBundle.getMessage(RevertModificationsPanel.class, "MSG_Fetching_Revisions"));
ComboBoxModel targetsModel = new DefaultComboBoxModel(new Vector<String>(initialRevsSet));
revisionsComboBox.setModel(targetsModel);
refreshViewThread = Thread.currentThread();
// clear interupted status
Thread.interrupted();
ph.start();
refreshRevisions();
} finally {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
ph.finish();
refreshViewThread = null;
}
});
}
}Example 76
| Project: netbeans-mmd-plugin-master File: MovePanel.java View source code |
private void initValues() {
final String text;
if (this.files.length > 1) {
text = String.format(BUNDLE.getString("MovePanel.multiFileText"), Integer.toString(this.files.length));
} else {
text = String.format(BUNDLE.getString("MovePanel.singleFileText"), this.files[0].getName());
}
this.labelMessage.setText(text);
final List<Project> projects = new ArrayList<Project>();
for (final Project p : OpenProjects.getDefault().getOpenProjects()) {
projects.add(p);
}
final ComboBoxModel<Project> projectModel = new DefaultComboBoxModel<Project>(projects.toArray(new Project[projects.size()]));
final ItemListener listener = new ItemListener() {
@Override
public void itemStateChanged(final ItemEvent e) {
if (comboProjects.equals(e.getSource())) {
updateFolders();
parent.stateChanged(null);
} else if (comboFolders.equals(e.getSource())) {
parent.stateChanged(null);
}
}
};
this.comboProjects.addItemListener(listener);
this.comboFolders.addItemListener(listener);
this.comboProjects.setModel(projectModel);
this.comboProjects.setSelectedItem(FileOwnerQuery.getOwner(this.files[0]));
updateFolders();
final ExplorerContext explorerContext = this.lookup.lookup(ExplorerContext.class);
if (explorerContext != null) {
final Node targetNode = explorerContext.getTargetNode();
if (targetNode != null) {
final DataObject dobj = targetNode.getLookup().lookup(DataObject.class);
if (dobj != null) {
final FileObject fo = dobj.getPrimaryFile();
if (fo != null && fo.isValid() && fo.isFolder()) {
final Project proj = FileOwnerQuery.getOwner(fo);
if (proj != null) {
this.comboProjects.setSelectedItem(proj);
this.comboFolders.setSelectedItem(FileUtil.getRelativePath(proj.getProjectDirectory(), fo));
}
}
}
}
}
}Example 77
| Project: nmedit-master File: SaveInSynthDialog.java View source code |
private void updateData() {
form.cbSlot.removeAllItems();
form.cbBank.removeAllItems();
Synthesizer synth = (Synthesizer) form.cbSynth.getSelectedItem();
ComboBoxModel model = getSlotModel(synth);
if (model != null)
form.cbSlot.setModel(model);
if (usedBankModel != null) {
usedBankModel.uninstallListeners();
}
model = createBankModel(synth);
if (model != null)
form.cbBank.setModel(model);
}Example 78
| Project: The-Digital-Parrot-master File: ChainLinkView.java View source code |
private ComboBoxModel getTypesForInstance(NodeWrapper instance) {
List<Object> typesList = new ArrayList<Object>();
if (instance == null) {
typesList.addAll(chain.getPossibleTypes(link));
Collections.sort(typesList, comparator);
} else {
if (!instance.isType()) {
typesList.addAll(chain.getPossibleTypesForIndividual(instance));
Collections.sort(typesList, comparator);
}
}
typesList.add(0, ANY_TYPE);
return new DefaultComboBoxModel(typesList.toArray());
}Example 79
| Project: tizzit-master File: TinyComboBoxUI.java View source code |
/**
* Copied from BasicComboBoxUI, because isDisplaySizeDirty was declared private!?
* Returns the calculated size of the display area. The display area is the
* portion of the combo box in which the selected item is displayed. This
* method will use the prototype display value if it has been set.
* <p>
* For combo boxes with a non trivial number of items, it is recommended to
* use a prototype display value to significantly speed up the display
* size calculation.
*
* @return the size of the display area calculated from the combo box items
* @see javax.swing.JComboBox#setPrototypeDisplayValue
*/
protected Dimension getDisplaySize() {
if (!isDisplaySizeDirty) {
return new Dimension(cachedDisplaySize);
}
Dimension result = new Dimension();
ListCellRenderer renderer = comboBox.getRenderer();
if (renderer == null) {
renderer = new DefaultListCellRenderer();
}
Object prototypeValue = comboBox.getPrototypeDisplayValue();
if (prototypeValue != null) {
// Calculates the dimension based on the prototype value
result = getSizeForComponent(renderer.getListCellRendererComponent(listBox, prototypeValue, -1, false, false));
} else {
// Calculate the dimension by iterating over all the elements in the combo
// box list.
ComboBoxModel model = comboBox.getModel();
int modelSize = model.getSize();
Dimension d;
Component cpn;
if (modelSize > 0) {
for (int i = 0; i < modelSize; i++) {
// Calculates the maximum height and width based on the largest
// element
d = getSizeForComponent(renderer.getListCellRendererComponent(listBox, model.getElementAt(i), -1, false, false));
result.width = Math.max(result.width, d.width);
result.height = Math.max(result.height, d.height);
}
} else {
result = getDefaultSize();
if (comboBox.isEditable()) {
result.width = 100;
}
}
}
if (comboBox.isEditable()) {
Dimension d = editor.getPreferredSize();
result.width = Math.max(result.width, d.width);
result.height = Math.max(result.height, d.height);
}
// Set the cached value
cachedDisplaySize.setSize(result.width, result.height);
isDisplaySizeDirty = false;
return result;
}Example 80
| Project: cids-navigator-master File: FastBindableReferenceCombo.java View source code |
/**
* DOCUMENT ME!
*
* @param o DOCUMENT ME!
*
* @return DOCUMENT ME!
*/
public int getIndexOf(final Object o) {
final ComboBoxModel m = getModel();
if (m instanceof DefaultComboBoxModel) {
return ((DefaultComboBoxModel) m).getIndexOf(o);
} else if (m != null) {
for (int i = 0; i < m.getSize(); ++i) {
final Object cur = m.getElementAt(i);
if ((o == cur) || ((cur != null) && cur.equals(o))) {
return i;
}
}
}
return -1;
}Example 81
| Project: cruisecontrol-master File: BuildAgentUtility.java View source code |
private void doRefreshAgentList() {
try {
final List<ServiceItem> tmpList = new ArrayList<ServiceItem>();
final String agentInfoAll = buildAgentUtility.getAgentInfoAll(tmpList);
final ServiceItem[] serviceItems = tmpList.toArray(new ServiceItem[tmpList.size()]);
final ComboBoxModel comboBoxModel = new DefaultComboBoxModel(ComboItemWrapper.wrapArray(serviceItems));
//"BuildAgentUtility setcomboBoxModel Thread"
SwingUtilities.invokeLater(new Runnable() {
public void run() {
updateLUSCountUI(buildAgentUtility.lastLUSCount);
cmbAgents.setModel(comboBoxModel);
}
});
setInfo(agentInfoAll);
} finally {
//"BuildAgentUtility btn.enable Thread"
SwingUtilities.invokeLater(new Runnable() {
public void run() {
btnRefresh.setEnabled(true);
btnInvokeOnAll.setEnabled(true);
cmbAgents.setEnabled(true);
}
});
}
}Example 82
| Project: DensiTree-master File: LineWidthPanel.java View source code |
@Override
public void stateChanged(ChangeEvent e) {
List<String> selection = new ArrayList<String>();
List<String> selectionTop = new ArrayList<String>();
selection.add(LineWidthMode.DEFAULT.toString());
selectionTop.add(SAME_AS_BOTTOM);
selectionTop.add(MAKE_FIT_BOTTOM);
if (m_dt.m_bMetaDataReady) {
selection.add(LineWidthMode.BY_METADATA_PATTERN.toString());
selectionTop.add(LineWidthMode.BY_METADATA_PATTERN.toString());
selection.add(LineWidthMode.BY_METADATA_NUMBER.toString());
selectionTop.add(LineWidthMode.BY_METADATA_NUMBER.toString());
for (int i = 0; i < m_dt.m_metaDataTags.size(); i++) {
if (m_dt.m_metaDataTypes.get(i).equals(MetaDataType.NUMERIC)) {
selection.add(m_dt.m_metaDataTags.get(i));
selectionTop.add(m_dt.m_metaDataTags.get(i));
}
}
}
ComboBoxModel<String> model = new DefaultComboBoxModel<>(selection.toArray(new String[0]));
comboBoxBottom.setModel(model);
model = new DefaultComboBoxModel<>(selectionTop.toArray(new String[0]));
comboBoxTop.setModel(model);
if (m_dt.m_lineWidthMode == LineWidthMode.DEFAULT) {
comboBoxBottom.setSelectedItem(LineWidthMode.DEFAULT.toString());
} else if (m_dt.m_lineWidthMode == LineWidthMode.BY_METADATA_PATTERN) {
comboBoxBottom.setSelectedItem(LineWidthMode.BY_METADATA_PATTERN.toString());
} else if (m_dt.m_lineWidthMode == LineWidthMode.BY_METADATA_NUMBER) {
comboBoxBottom.setSelectedItem(LineWidthMode.BY_METADATA_NUMBER.toString());
} else {
comboBoxBottom.setSelectedItem(m_dt.m_lineWidthTag);
}
if (m_dt.m_lineWidthModeTop == LineWidthMode.DEFAULT) {
if (m_dt.m_bCorrectTopOfBranch) {
comboBoxTop.setSelectedItem(MAKE_FIT_BOTTOM);
} else {
comboBoxTop.setSelectedItem(SAME_AS_BOTTOM);
}
} else if (m_dt.m_lineWidthModeTop == LineWidthMode.BY_METADATA_PATTERN) {
comboBoxTop.setSelectedItem(LineWidthMode.BY_METADATA_PATTERN.toString());
} else if (m_dt.m_lineWidthModeTop == LineWidthMode.BY_METADATA_NUMBER) {
comboBoxTop.setSelectedItem(LineWidthMode.BY_METADATA_NUMBER.toString());
} else {
comboBoxTop.setSelectedItem(m_dt.m_lineWidthTagTop);
}
updateEnabled();
}Example 83
| Project: freemind-mmx-master File: AttributeTable.java View source code |
/**
*
*/
public Component prepareEditor(TableCellEditor tce, int row, int col) {
ComboBoxModel model;
JComboBox comboBox = (JComboBox) ((DefaultCellEditor) tce).getComponent();
MindMapNode node = getAttributeTableModel().getNode();
AttributeRegistry attributes = node.getMap().getRegistry().getAttributes();
switch(col) {
case 0:
model = attributes.getComboBoxModel();
comboBox.setEditable(!attributes.isRestricted());
break;
case 1:
String attrName = getAttributeTableModel().getValueAt(row, 0).toString();
model = attributes.getDefaultComboBoxModel(attrName);
comboBox.setEditable(!attributes.isRestricted(attrName));
break;
default:
model = getDefaultComboBoxModel();
}
comboBox.setModel(model);
model.setSelectedItem(getValueAt(row, col));
comboBox.addFocusListener(focusListener);
comboBox.getEditor().getEditorComponent().addFocusListener(focusListener);
Component editor = super.prepareEditor(tce, row, col);
updateFontSize(editor, getZoom());
return editor;
}Example 84
| Project: gephi-neo4j-plugin-master File: MergeColumnsUI.java View source code |
public boolean validate(Problems problems, String string, ComboBoxModel t) {
if (t.getSelectedItem() != null) {
if (ui.canExecuteSelectedStrategy()) {
return true;
} else {
problems.add(NbBundle.getMessage(MergeColumnsUI.class, "MergeColumnsUI.problems.not_executable_strategy"));
return false;
}
} else {
problems.add(NbBundle.getMessage(MergeColumnsUI.class, "MergeColumnsUI.problems.less_than_2_columns_selected"));
return false;
}
}Example 85
| Project: iranAdempiere-master File: TinyComboBoxUI.java View source code |
/**
* Copied from BasicComboBoxUI, because isDisplaySizeDirty was declared private!?
* Returns the calculated size of the display area. The display area is the
* portion of the combo box in which the selected item is displayed. This
* method will use the prototype display value if it has been set.
* <p>
* For combo boxes with a non trivial number of items, it is recommended to
* use a prototype display value to significantly speed up the display
* size calculation.
*
* @return the size of the display area calculated from the combo box items
* @see javax.swing.JComboBox#setPrototypeDisplayValue
*/
protected Dimension getDisplaySize() {
if (!isDisplaySizeDirty) {
return new Dimension(cachedDisplaySize);
}
Dimension result = new Dimension();
ListCellRenderer renderer = comboBox.getRenderer();
if (renderer == null) {
renderer = new DefaultListCellRenderer();
}
Object prototypeValue = comboBox.getPrototypeDisplayValue();
if (prototypeValue != null) {
// Calculates the dimension based on the prototype value
result = getSizeForComponent(renderer.getListCellRendererComponent(listBox, prototypeValue, -1, false, false));
} else {
// Calculate the dimension by iterating over all the elements in the combo
// box list.
ComboBoxModel model = comboBox.getModel();
int modelSize = model.getSize();
Dimension d;
Component cpn;
if (modelSize > 0) {
for (int i = 0; i < modelSize; i++) {
// Calculates the maximum height and width based on the largest
// element
d = getSizeForComponent(renderer.getListCellRendererComponent(listBox, model.getElementAt(i), -1, false, false));
result.width = Math.max(result.width, d.width);
result.height = Math.max(result.height, d.height);
}
} else {
result = getDefaultSize();
if (comboBox.isEditable()) {
result.width = 100;
}
}
}
if (comboBox.isEditable()) {
Dimension d = editor.getPreferredSize();
result.width = Math.max(result.width, d.width);
result.height = Math.max(result.height, d.height);
}
// Set the cached value
cachedDisplaySize.setSize(result.width, result.height);
isDisplaySizeDirty = false;
return result;
}Example 86
| Project: Jailer-master File: AdditionalSubjectsDialog.java View source code |
/**
* Gets list model for the subject-combobox.
*
* @return list model for the subject-combobox
*/
private ComboBoxModel<String> subjectListModel(boolean withNull) {
Vector<String> tableNames = new Vector<String>();
for (Table table : extractionModel.dataModel.getTables()) {
tableNames.add(extractionModel.dataModel.getDisplayName(table));
}
Collections.sort(tableNames);
if (withNull) {
tableNames.add(0, "");
}
DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>(tableNames);
return model;
}Example 87
| Project: jmeter-master File: CookiePanel.java View source code |
/**
* Create the drop-down list to changer render
* @return List of all render (implement ResultsRender)
*/
private JComboBox<String> createComboHandler() {
ComboBoxModel<String> nodesModel = new DefaultComboBoxModel<>();
// drop-down list for renderer
selectHandlerPanel = new JComboBox<>(nodesModel);
selectHandlerPanel.setActionCommand(HANDLER_COMMAND);
selectHandlerPanel.addActionListener(this);
// if no results render in jmeter.properties, load Standard (default)
List<String> classesToAdd = Collections.emptyList();
try {
classesToAdd = JMeterUtils.findClassesThatExtend(CookieHandler.class);
} catch (IOException e1) {
}
String tmpName = null;
for (String clazz : classesToAdd) {
String shortClazz = clazz.substring(clazz.lastIndexOf('.') + 1);
if (DEFAULT_IMPLEMENTATION.equals(clazz)) {
tmpName = shortClazz;
}
handlerMap.put(shortClazz, clazz);
}
// Only add to selectHandlerPanel after handlerMap has been initialized
for (String shortClazz : handlerMap.keySet()) {
selectHandlerPanel.addItem(shortClazz);
}
// preset to default impl
nodesModel.setSelectedItem(tmpName);
return selectHandlerPanel;
}Example 88
| Project: limewire5-ruby-master File: FileInfoGeneralPanel.java View source code |
/**
* Loads a combo box and selects the currently selected item.
*/
private void setupComboBox(JComboBox comboBox, String current, List<String> possibles) {
if (current == null) {
current = "";
}
// If any are listed, current is non-empty, and possibles doesn't contain, add it in.
if (!possibles.contains(current) && !current.equals("") && possibles.size() > 0) {
possibles = new ArrayList<String>(possibles);
possibles.add(0, current);
possibles = Collections.unmodifiableList(possibles);
}
ComboBoxModel model = new CollectionBackedComboBoxModel(possibles);
comboBox.setModel(model);
comboBox.setSelectedItem(current);
}Example 89
| Project: pdfxtk-master File: XMIllumDesktop.java View source code |
public void actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser();
fc.setCurrentDirectory(new File((String) Preferences.get(XSLT_DIRECTORY, "")));
fc.addChoosableFileFilter(new FileFilter() {
public boolean accept(File f) {
return f.isDirectory() || f.getName().endsWith(".xsl");
}
public String getDescription() {
return ".xsl Stylesheets";
}
});
if (JFileChooser.APPROVE_OPTION == fc.showOpenDialog(null)) {
Preferences.set(XSLT_DIRECTORY, fc.getCurrentDirectory().getAbsolutePath());
File file = fc.getSelectedFile();
stylesheetList.insertItemAt(file.getAbsolutePath(), 0);
stylesheetList.setSelectedIndex(0);
// Save combobox contents to preferences
ComboBoxModel model = stylesheetList.getModel();
int size = model.getSize();
String[] lastUsed = new String[(model.getSize() <= 10) ? model.getSize() : 10];
for (int i = 0; i < lastUsed.length; i++) {
lastUsed[i] = (String) model.getElementAt(i);
}
Preferences.set(XSLT_LASTUSED, lastUsed);
}
}Example 90
| Project: pentaho-reporting-master File: RepositoryOpenDialog.java View source code |
public void setSelectedView(final FileObject selectedView) {
this.selectedView = selectedView;
if (selectedView != null) {
logger.debug("Setting selected view to " + selectedView);
try {
if (selectedView.getType() == FileType.FILE) {
logger.debug("Setting filename in selected view to " + selectedView.getName().getBaseName());
this.fileNameTextField.setText(URLDecoder.decode(selectedView.getName().getBaseName(), "UTF-8"));
}
} catch (Exception e) {
logger.debug("Unable to determine file type. This is not fatal.", e);
}
final ComboBoxModel comboBoxModel = createLocationModel(selectedView);
this.locationCombo.setModel(comboBoxModel);
this.table.setSelectedPath((FileObject) comboBoxModel.getSelectedItem());
} else {
this.fileNameTextField.setText(null);
this.table.setSelectedPath(null);
this.locationCombo.setModel(new DefaultComboBoxModel());
}
}Example 91
| Project: swingsane-master File: KnownSaneOptions.java View source code |
public static ComboBoxModel<String> getColorModeComponent(Scanner scanner) {
DefaultComboBoxModel<String> colorModel = new DefaultComboBoxModel<String>();
HashMap<String, StringOption> stringOptions = scanner.getStringOptions();
StringOption stringOption = stringOptions.get(SANE_NAME_SCAN_MODE);
if (stringOption == null) {
return null;
}
Constraints constraints = stringOption.getConstraints();
List<String> values = constraints.getStringList();
for (String value : values) {
colorModel.addElement(value);
}
if (values.size() > 0) {
return colorModel;
} else {
return null;
}
}Example 92
| Project: dsql-master File: DSJTable.java View source code |
private void init() {
MyTransferHandler myTransferHandler = new MyTransferHandler(getTransferHandler());
setTransferHandler(myTransferHandler);
ActionMap actionMap = getActionMap();
Action copyAction = MyTransferHandler.getCopyAction();
actionMap.put(I18n.get("COPY"), copyAction);
setAutoCreateRowSorter(true);
setRowSelectionAllowed(true);
setDragEnabled(true);
setDefaultEditor(ComboBoxModel.class, new ComboBoxModelCellEditor());
setDefaultEditor(GeoPt.class, new GoogleObjectCellEditor(GeoPt.class));
setDefaultEditor(ShortBlob.class, new ShortBlobCellEditor());
setDefaultEditor(Blob.class, new BlobCellEditor());
setDefaultEditor(Rating.class, new RatingCellEditor());
setDefaultEditor(PostalAddress.class, new GoogleObjectCellEditor(PostalAddress.class));
setDefaultEditor(PhoneNumber.class, new GoogleObjectCellEditor(PhoneNumber.class));
setDefaultEditor(Link.class, new GoogleObjectCellEditor(Link.class));
setDefaultEditor(Text.class, new TextCellEditor());
setDefaultEditor(Email.class, new GoogleObjectCellEditor(Email.class));
setDefaultEditor(Category.class, new GoogleObjectCellEditor(Category.class));
setDefaultRenderer(ComboBoxModel.class, new ComboBoxModelCellRenderer());
setDefaultRenderer(GeoPt.class, new GoogleObjectTableCellRenderer());
setDefaultRenderer(ShortBlob.class, new ShortBlobTableCellRenderer());
setDefaultRenderer(Blob.class, new BlobTableCellRenderer());
setDefaultRenderer(Rating.class, new GoogleObjectTableCellRenderer());
setDefaultRenderer(PostalAddress.class, new GoogleObjectTableCellRenderer());
setDefaultRenderer(PhoneNumber.class, new GoogleObjectTableCellRenderer());
setDefaultRenderer(Link.class, new GoogleObjectTableCellRenderer());
setDefaultRenderer(Text.class, new GoogleObjectTableCellRenderer());
setDefaultRenderer(Email.class, new GoogleObjectTableCellRenderer());
setDefaultRenderer(Category.class, new GoogleObjectTableCellRenderer());
}Example 93
| Project: FDEB-master File: DynamicSettingsPanel.java View source code |
private TimeUnit getSelectedTimeUnit(ComboBoxModel comboBoxModel) {
if (comboBoxModel.getSelectedItem().equals(DAYS)) {
return TimeUnit.DAYS;
} else if (comboBoxModel.getSelectedItem().equals(HOURS)) {
return TimeUnit.HOURS;
} else if (comboBoxModel.getSelectedItem().equals(MILLISECONDS)) {
return TimeUnit.MILLISECONDS;
} else if (comboBoxModel.getSelectedItem().equals(MINUTES)) {
return TimeUnit.MINUTES;
} else if (comboBoxModel.getSelectedItem().equals(SECONDS)) {
return TimeUnit.SECONDS;
}
return null;
}Example 94
| Project: gephi-gsoc13-legendmodule-master File: DynamicSettingsPanel.java View source code |
private TimeUnit getSelectedTimeUnit(ComboBoxModel comboBoxModel) {
if (comboBoxModel.getSelectedItem().equals(DAYS)) {
return TimeUnit.DAYS;
} else if (comboBoxModel.getSelectedItem().equals(HOURS)) {
return TimeUnit.HOURS;
} else if (comboBoxModel.getSelectedItem().equals(MILLISECONDS)) {
return TimeUnit.MILLISECONDS;
} else if (comboBoxModel.getSelectedItem().equals(MINUTES)) {
return TimeUnit.MINUTES;
} else if (comboBoxModel.getSelectedItem().equals(SECONDS)) {
return TimeUnit.SECONDS;
}
return null;
}Example 95
| Project: gephi-master File: DynamicSettingsPanel.java View source code |
private TimeUnit getSelectedTimeUnit(ComboBoxModel comboBoxModel) {
if (comboBoxModel.getSelectedItem().equals(DAYS)) {
return TimeUnit.DAYS;
} else if (comboBoxModel.getSelectedItem().equals(HOURS)) {
return TimeUnit.HOURS;
} else if (comboBoxModel.getSelectedItem().equals(MILLISECONDS)) {
return TimeUnit.MILLISECONDS;
} else if (comboBoxModel.getSelectedItem().equals(MINUTES)) {
return TimeUnit.MINUTES;
} else if (comboBoxModel.getSelectedItem().equals(SECONDS)) {
return TimeUnit.SECONDS;
}
return null;
}Example 96
| Project: JAME-master File: RenderedPaletteParamPanel.java View source code |
/**
* @param paletteParam
*/
protected void updateParam(final RenderedPaletteParam paletteParam) {
ColorFieldModel colorFieldModel = getColorFieldModel(RenderedPaletteParamPanel.COLOR_MODEL_START);
if (colorFieldModel != null) {
colorFieldModel.setColor(new Color(paletteParam.getColor(0), true), false);
}
colorFieldModel = getColorFieldModel(RenderedPaletteParamPanel.COLOR_MODEL_END);
if (colorFieldModel != null) {
colorFieldModel.setColor(new Color(paletteParam.getColor(1), true), false);
}
ComboBoxModel comboBoxModel = getComboBoxModel(RenderedPaletteParamPanel.FORMULA_COMBOBOX_MODEL_ALPHA);
if (comboBoxModel != null) {
try {
comboBoxModel.setSelectedItem(MandelbrotRegistry.getInstance().getPaletteRendererFormulaExtension(paletteParam.getFormula(0).getExtensionId()));
} catch (final ExtensionNotFoundException e) {
e.printStackTrace();
}
}
comboBoxModel = getComboBoxModel(RenderedPaletteParamPanel.FORMULA_COMBOBOX_MODEL_RED);
if (comboBoxModel != null) {
try {
comboBoxModel.setSelectedItem(MandelbrotRegistry.getInstance().getPaletteRendererFormulaExtension(paletteParam.getFormula(1).getExtensionId()));
} catch (final ExtensionNotFoundException e) {
e.printStackTrace();
}
}
comboBoxModel = getComboBoxModel(RenderedPaletteParamPanel.FORMULA_COMBOBOX_MODEL_GREEN);
if (comboBoxModel != null) {
try {
comboBoxModel.setSelectedItem(MandelbrotRegistry.getInstance().getPaletteRendererFormulaExtension(paletteParam.getFormula(2).getExtensionId()));
} catch (final ExtensionNotFoundException e) {
e.printStackTrace();
}
}
comboBoxModel = getComboBoxModel(RenderedPaletteParamPanel.FORMULA_COMBOBOX_MODEL_BLUE);
if (comboBoxModel != null) {
try {
comboBoxModel.setSelectedItem(MandelbrotRegistry.getInstance().getPaletteRendererFormulaExtension(paletteParam.getFormula(3).getExtensionId()));
} catch (final ExtensionNotFoundException e) {
e.printStackTrace();
}
}
}Example 97
| Project: jclic-master File: ActiveBagContentControlPanel.java View source code |
public void setActiveBagContent(ActiveBagContent abc, ActiveBagContent altAbc) {
this.abc = abc;
this.altAbc = altAbc;
altNull = (altAbc == null);
// ActiveBagContent objects with more cells than the specified by the Shaper.
if (abc != null && !simpleMode)
abc.checkCells();
if (altAbc != null && !simpleMode)
altAbc.checkCells();
// -----
altChk.setSelected(!altNull);
altChk.setEnabled(abc != null);
toggleAlt.setSelected(false);
toggleAlt.setEnabled(!altNull);
imgButton.setMediaBagEditor(parent.mediaBagEditor);
imgButton.setImgName(abc != null ? abc.imgName : null);
imgButton.setEnabled(abc != null);
boxBaseButton.setBoxBase(abc != null ? abc.bb : null);
parent.abcpp.setActiveBagContent(visualIndex, abc, altAbc, null);
boxBaseButton.setPreview(parent.abcpp.getAbstractBox(visualIndex));
boxBaseButton.setEnabled(abc != null);
Shaper sh = (abc != null ? abc.getShaper() : null);
ComboBoxModel model = shaperCombo.getModel();
int modelSize = model.getSize();
int i = -1;
if (sh != null) {
String s = sh.getClassName();
for (i = 0; i < modelSize; i++) {
TripleString ts = (TripleString) model.getElementAt(i);
if (s.equals(ts.getClassName()))
break;
}
}
shaperCombo.setSelectedIndex(i < modelSize ? i : -1);
shaperCombo.setEnabled(abc != null);
shaperEditBtn.setEnabled(sh != null && sh.getEditorPanelClassName() != null);
nColsEdit.setValue(sh != null ? sh.getNumColumns() : 1);
nColsEdit.setEnabled(abc != null);
nRowsEdit.setValue(sh != null ? sh.getNumRows() : 1);
nRowsEdit.setEnabled(abc != null);
widthEdit.setValue(abc != null ? (int) abc.w : 30);
widthEdit.setEnabled(abc != null);
heightEdit.setValue(abc != null ? (int) abc.h : 20);
heightEdit.setEnabled(abc != null);
borderChk.setSelected(abc != null ? abc.border : false);
borderChk.setEnabled(abc != null);
}Example 98
| Project: jo-widgets-master File: ComboBoxImpl.java View source code |
private ComboBoxModel createComboBoxModel(final String[] elements) { final ComboBoxModel result; if (isAutoCompletionMode) { if (isSelectionMode) { int max = 0; for (final String item : elements) { max = Math.max(item.length(), max); } maxLength = max; } autoCompletionModel = new AutoCompletionModel(elements); result = autoCompletionModel; } else { result = new DefaultComboBoxModel(elements); autoCompletionModel = null; } return result; }
Example 99
| Project: LimeWire-Pirate-Edition-master File: FileInfoGeneralPanel.java View source code |
/**
* Loads a combo box and selects the currently selected item.
*/
private void setupComboBox(JComboBox comboBox, String current, List<String> possibles) {
if (current == null) {
current = "";
}
comboBox.setForeground(foreground);
// If any are listed, current is non-empty, and possibles doesn't contain, add it in.
if (!possibles.contains(current) && !current.equals("") && possibles.size() > 0) {
possibles = new ArrayList<String>(possibles);
possibles.add(0, current);
possibles = Collections.unmodifiableList(possibles);
}
ComboBoxModel model = new CollectionBackedComboBoxModel(possibles);
comboBox.setModel(model);
comboBox.setSelectedItem(current);
}Example 100
| Project: netbeans-gradle-project-master File: ProfileBasedPanel.java View source code |
private void sortProfileComboItems() {
ComboBoxModel<ProfileItem> model = jProfileCombo.getModel();
int itemCount = model.getSize();
List<ProfileItem> configs = new ArrayList<>(itemCount);
for (int i = 0; i < itemCount; i++) {
Object element = model.getElementAt(i);
if (element instanceof ProfileItem) {
configs.add((ProfileItem) element);
}
}
Collections.sort(configs, ProfileItem.ALPHABETICAL_ORDER);
jProfileCombo.setModel(new DefaultComboBoxModel<>(configs.toArray(new ProfileItem[0])));
}Example 101
| Project: openrocket-master File: RocketPanel.java View source code |
/**
* Creates the layout and components of the panel.
*/
private void createPanel() {
setLayout(new MigLayout("", "[shrink][grow]", "[shrink][shrink][grow][shrink]"));
setPreferredSize(new Dimension(800, 300));
// View Type Dropdown
ComboBoxModel cm = new DefaultComboBoxModel(VIEW_TYPE.values()) {
@Override
public void setSelectedItem(Object o) {
super.setSelectedItem(o);
VIEW_TYPE v = (VIEW_TYPE) o;
if (v.is3d) {
figure3d.setType(v.type);
go3D();
} else {
figure.setType(v.type);
// when switching from side view to back view, need to clear CP & CG markers
updateExtras();
go2D();
}
}
};
add(new JLabel(trans.get("RocketPanel.lbl.ViewType")), "spanx, split");
add(new JComboBox(cm));
// Zoom level selector
scaleSelector = new ScaleSelector(scrollPane);
add(scaleSelector);
// Stage selector
StageSelector stageSelector = new StageSelector(configuration);
add(stageSelector);
// Flight configuration selector
//// Flight configuration:
JLabel label = new JLabel(trans.get("RocketPanel.lbl.Flightcfg"));
label.setHorizontalAlignment(JLabel.RIGHT);
add(label, "growx, right");
add(new JComboBox(new FlightConfigurationModel(configuration)), "wrap");
// Create slider and scroll pane
DoubleModel theta = new DoubleModel(figure, "Rotation", UnitGroup.UNITS_ANGLE, 0, 2 * Math.PI);
UnitSelector us = new UnitSelector(theta, true);
us.setHorizontalAlignment(JLabel.CENTER);
add(us, "alignx 50%, growx");
// Add the rocket figure
add(figureHolder, "grow, spany 2, wmin 300lp, hmin 100lp, wrap");
// Add rotation slider
// Minimum size to fit "360deg"
JLabel l = new JLabel("360" + Chars.DEGREE);
Dimension d = l.getPreferredSize();
add(rotationSlider = new BasicSlider(theta.getSliderModel(0, 2 * Math.PI), JSlider.VERTICAL, true), "ax 50%, wrap, width " + (d.width + 6) + "px:null:null, growy");
//// <html>Click to select Shift+click to select other Double-click to edit Click+drag to move
infoMessage = new JLabel(trans.get("RocketPanel.lbl.infoMessage"));
infoMessage.setFont(new Font("Sans Serif", Font.PLAIN, 9));
add(infoMessage, "skip, span, gapleft 25, wrap");
addExtras();
}