121 |
*/ |
*/ |
122 |
public boolean isCellEditable(EventObject event) |
public boolean isCellEditable(EventObject event) |
123 |
{ |
{ |
124 |
if (!(event instanceof MouseEvent)) |
if (event == null || !(event instanceof MouseEvent) || |
125 |
|
(((MouseEvent) event).getClickCount() >= getClickCountToStart())) |
126 |
return true; |
return true; |
|
|
|
|
//Todo: if the right number of clicks has occured, return true; |
|
127 |
return false; |
return false; |
128 |
} // isCellEditable() |
} // isCellEditable() |
129 |
|
|
231 |
public DefaultCellEditor(JTextField textfield) |
public DefaultCellEditor(JTextField textfield) |
232 |
{ |
{ |
233 |
editorComponent = textfield; |
editorComponent = textfield; |
234 |
clickCountToStart = 2; |
clickCountToStart = 3; |
235 |
} // DefaultCellEditor() |
} // DefaultCellEditor() |
236 |
|
|
237 |
/** |
/** |
339 |
} // cancelCellEditing() |
} // cancelCellEditing() |
340 |
|
|
341 |
/** |
/** |
342 |
* getTreeCellEditorComponent |
* Sets an initial value for the editor. |
343 |
* |
* This will cause the editor to stopEditing and lose any partially |
344 |
* @param tree TODO |
* edited value if the editor is editing when this method is called. |
345 |
* @param value TODO |
* Returns the component that should be added to the client's Component |
346 |
* @param isSelected TODO |
* hierarchy. Once installed in the client's hierarchy this component will |
347 |
* @param expanded TODO |
* then be able to draw and receive user input. |
348 |
* @param leaf TODO |
* |
349 |
* @param row TODO |
* @param tree - the JTree that is asking the editor to edit; this |
350 |
|
* parameter can be null |
351 |
|
* @param value - the value of the cell to be edited |
352 |
|
* @param isSelected - true is the cell is to be renderer with selection |
353 |
|
* highlighting |
354 |
|
* @param expanded - true if the node is expanded |
355 |
|
* @param leaf - true if the node is a leaf node |
356 |
|
* @param row - the row index of the node being edited |
357 |
* |
* |
358 |
* @returns Component |
* @returns Component the component for editing |
359 |
*/ |
*/ |
360 |
public Component getTreeCellEditorComponent(JTree tree, Object value, |
public Component getTreeCellEditorComponent(JTree tree, Object value, |
361 |
boolean isSelected, |
boolean isSelected, |
362 |
boolean expanded, boolean leaf, |
boolean expanded, boolean leaf, |
363 |
int row) |
int row) |
364 |
{ |
{ |
365 |
return null; // TODO |
if (editorComponent instanceof JTextField) |
366 |
|
{ |
367 |
|
((JTextField)editorComponent).setText(value.toString()); |
368 |
|
delegate = new EditorDelegate(); |
369 |
|
((JTextField)editorComponent).addActionListener(delegate); |
370 |
|
} |
371 |
|
else if (editorComponent instanceof JCheckBox) |
372 |
|
{ |
373 |
|
((JCheckBox)editorComponent).setText(value.toString()); |
374 |
|
delegate = new EditorDelegate(); |
375 |
|
((JCheckBox)editorComponent).addActionListener(delegate); |
376 |
|
} |
377 |
|
else if (editorComponent instanceof JComboBox) |
378 |
|
{ |
379 |
|
((JComboBox)editorComponent).setSelectedItem(value.toString()); |
380 |
|
delegate = new EditorDelegate(); |
381 |
|
((JComboBox)editorComponent).addActionListener(delegate); |
382 |
|
} |
383 |
|
|
384 |
|
return editorComponent; |
385 |
} // getTreeCellEditorComponent() |
} // getTreeCellEditorComponent() |
386 |
|
|
387 |
/** |
/** |