Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. Copyright 2012-2015 the original author or authors.
package org.assertj.swing.jide.grids.driver;
import  com.jidesoft.combobox.AbstractComboBox;
import  com.jidesoft.converter.ObjectConverterManager;

A CellReader for extracting a String representation of a value in an AbstractComboBox.

Peter Murray
public class AbstractComboBoxCellReader {

Returns the internal value of a cell in a ListComboBox as expected in a test. This method first tries to get the value from the toString implementation of the object stored in the JComboBox's model at the specified index. If it fails, it returns the value displayed in the ListComboBox's cell renderer.

comboBox the given ListComboBox.
index the index of the cell.
the internal value of a cell in a ListComboBox as expected in a test.
  public String valueAt(AbstractComboBox comboBoxint index) {
	final Object item = itemAt(comboBoxindex);
	return valueAsText(comboBoxitem);
  public String valueAsText(AbstractComboBox comboBoxObject value) {
	if (value == null) {
	  return null;
	if (comboBox.getConverter() != null) {
	  return comboBox.getConverter().toString(valuecomboBox.getConverterContext());
	return ObjectConverterManager.toString(value,
  private Object itemAt(AbstractComboBox comboBoxint index) {
	return comboBox.getModel().getElementAt(index);
New to GrepCode? Check out our FAQ X