public class GenericCellEditor extends DefaultCellEditor
TableCellEditor genérico.DefaultCellEditor.EditorDelegateclickCountToStart, delegate, editorComponentchangeEvent, listenerList| Constructor and Description |
|---|
GenericCellEditor()
Construtor.
|
GenericCellEditor(JTextField textField)
Construtor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancelCellEditing() |
void |
clearInvalidValueWarning()
Apaga qualquer aviso dado ao usuário de que o valor que ele havia inserido
era inválido.
|
Object |
getCellEditorValue() |
Component |
getTableCellEditorComponent(JTable table,
Object value,
boolean isSelected,
int row,
int column) |
GenericCellEditor |
setHorizontalAlignment(int alignment)
Define o alinhamento horizontal do texto na célula.
|
boolean |
stopCellEditing() |
protected Object |
valueOf(String stringValue,
JTable table,
int row,
int column)
Extrai de stringValue o valor da célula no tipo esperado pela coluna.
|
void |
warnInvalidValue(Exception e)
Informa ao usuário que ele está tentando inserir um valor inválida.
|
getClickCountToStart, getComponent, getTreeCellEditorComponent, isCellEditable, setClickCountToStart, shouldSelectCelladdCellEditorListener, fireEditingCanceled, fireEditingStopped, getCellEditorListeners, removeCellEditorListenerclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitaddCellEditorListener, removeCellEditorListenerpublic GenericCellEditor(JTextField textField)
textField - campo de texto a ser utilizado na edição.public GenericCellEditor()
public GenericCellEditor setHorizontalAlignment(int alignment)
alignment - o alinhamento horizontal do texto.JTextField.LEFT
JTextField.CENTER
JTextField.RIGHT
JTextField.LEADING
JTextField.TRAILING
public void clearInvalidValueWarning()
public void warnInvalidValue(Exception e)
e - Exceção lançada pelo método
valueOf(String, JTable, int, int) quando o usuário tenta
submeter um valor inválido.valueOf(String, JTable, int, int)public boolean stopCellEditing()
stopCellEditing in interface CellEditorstopCellEditing in class DefaultCellEditorpublic void cancelCellEditing()
cancelCellEditing in interface CellEditorcancelCellEditing in class DefaultCellEditorpublic Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column)
getTableCellEditorComponent in interface TableCellEditorgetTableCellEditorComponent in class DefaultCellEditorpublic Object getCellEditorValue()
getCellEditorValue in interface CellEditorgetCellEditorValue in class DefaultCellEditorprotected Object valueOf(String stringValue, JTable table, int row, int column) throws Exception
Extrai de stringValue o valor da célula no tipo esperado pela coluna.
Este método também pode ser utilizado para validação, lançando uma exceção
caso o valor não seja permitido.
Por exemplo, se o valor for um percentual, ele deve estar entre 0 e
1.0.
protected Object valueOf(String stringValue, JTable table, int row, int column) {
Double value = super.valueOf(stringValue, table, row, column);
if (value > 1.0) {
throw new IllegalArgumentException("value > 1.0");
}
if (value < 0.0) {
throw new IllegalArgumentException("value < 0.0");
}
}
stringValue - Representação textual do valor da célula.table - Tabela a qual a célula pertence.column - Índice da coluna da célula.row - Índice da coluna da linha.Exception - Caso não seja possível fazer a conversão de tipo ou o
valor convertido não seja válido. Nesse caso o texto da exceção
será apresentado na statusbar da aplicação e a célula ficará com a
borda vermelha.Copyright © 2018. All rights reserved.