• Post Reply Bookmark Topic Watch Topic
  • New Topic

Fixed length Table Column  RSS feed

 
Rambo Rambabu
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I defined my custo textItem with a constructor like this:
----------------------------------------
public POSTTextField(int maxlength) {
super();
init();
this.maxLength = maxlength;
addKeyListener(new KeyAdapter() {
public void keyTyped(KeyEvent evt) {
System.out.println("maxlength is|"+POSTTextField.this.maxLength+" currlength is|"+getText().length());

if ( (getText().length() >= POSTTextField.this.maxLength) &&
(!(evt.getKeyChar() == '')) ) // check for backspace key stroke and allow it
evt.consume();
}
});
}
---------------------------------
This works fine for any of my text items I am creating by passing an int for the max length.
When I try to use this field for a local text field and use that one to create a local cell editor and use that editor for a table column, the keyTyped method is not getting called. Any work arounds or other implementation ideas? Here is my code for creating the table column...
---------------------------------
private TableColumn getStdObjDayColumn() {
if (stdObjDayColumn == null) {
try {
DefaultTableCellRenderer localCellRenderer;
localCellRenderer = new DefaultTableCellRenderer();
localCellRenderer.setName("localCellRenderer");
localCellRenderer.setFont(new Font("sansserif", 0, 12));
localCellRenderer.setBorder(LineBorder.createBlackLineBorder());
localCellRenderer.setBackground(Color.white);
localCellRenderer.setForeground(Color.black);
POSTTextField localTextField = new POSTTextField(2);
DefaultCellEditor localCellEditor = new DefaultCellEditor(localTextField);
stdObjDayColumn = new TableColumn();
stdObjDayColumn.setCellRenderer(localCellRenderer);
scheduledHoursColumn.setCellEditor(localCellEditor);
stdObjDayColumn.setHeaderValue("Std. Obj. Day");
stdObjDayColumn.setMaxWidth(123);
stdObjDayColumn.setModelIndex(3);
stdObjDayColumn.setWidth(123);
stdObjDayColumn.setMinWidth(123);
stdObjDayColumn.setResizable(false);
// user code begin {1}
// user code end
} catch (java.lang.Throwable Exc) {
// user code begin {2}
// user code end
handleException(Exc);
}
}
return stdObjDayColumn;
}
-------------------
thank you for your help.
-- Rambo
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!