Moderator: JIDE Support
package com.jidesoft.grid;
import com.jidesoft.combobox.MultilineStringComboBox;
import com.jidesoft.swing.JideSwingUtilities;
import javax.swing.*;
import javax.swing.table.TableCellEditor;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* A multiple line text cell editor.
*/
public class MultilineStringCellEditor extends ContextSensitiveCellEditor implements TableCellEditor, ItemListener {
public final static EditorContext CONTEXT = new EditorContext("MultilineString");
private MultilineStringComboBox _comboBox;
/**
* Creates a FileNameCellEditor.
*/
public MultilineStringCellEditor() {
_comboBox = createMultilineStringComboBox();
_comboBox.setBorder(BorderFactory.createEmptyBorder());
}
/**
* Creates the MultilineStringComboBox used by this cell editor.
* @return a MultilineStringComboBox.
*/
protected MultilineStringComboBox createMultilineStringComboBox() {
return new MultilineStringComboBox();
}
/**
* Gets the value of the cell editor.
*
* @return the value in this cell editor.
*/
public Object getCellEditorValue() {
_comboBox.setSelectedItem(_comboBox.getEditor().getItem());
return _comboBox.getSelectedItem();
}
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected,
int row, int column) {
if (table != null) {
JideSwingUtilities.installColorsAndFont(_comboBox, table.getBackground(), table.getForeground(), table.getFont());
}
_comboBox.setSelectedItem(value, false);
_comboBox.setConverterContext(getConverterContext());
_comboBox.addItemListener(this);
return _comboBox;
}
public boolean stopCellEditing() {
_comboBox.setPopupVisible(false);
return super.stopCellEditing();
}
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
_comboBox.removeItemListener(this);
stopCellEditing();
}
}
}
192.168.1.0 / 24
Users browsing this forum: No registered users and 5 guests