thanks in advance
ej
Hope this helps,
linda
In article <373800AE...@hotmail.com>,
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
thanks in advance
jh
Unfortunatly, with Swing components, most of the time 'requestFocus()'
does not work as expected. The following code will do what you need. the
key here is 'invokeLater()'. This will cause your request for focus to
occur at the end of all other focus processing.
...
JTextField textField = new JTextField();
...
SwingUtilities.invokeLater( new FocusGrabber( textField ) );
/**
* Runnable inner class for refocusing JComponent.
*/
private class FocusGrabber implements Runnable
{
JComponent component;
/**
* Constructor.
*
* @parameter JComponent to refocus.
*/
public FocusGrabber( JComponent component )
{
this.component = component;
}
/**
* Run method.
*/
public void run()
{
refocusHandler( component );
}
}
/**
* Default method for refocusing an instance of JComponent
* May be overridden by child class.
*
* @param component JComponent to refocus.
*/
public void refocusHandler( JComponent component )
{
component.grabFocus();
}
In article <373AA9D3...@hotmail.com>,
--
Later.....Scott...
thanks in advance
jh
thankyou
jh
I think perhaps people have been giving answers (good ones, too) to the wrong
question.
If you want to validate data entry, and prevent the editor from closing in
some cases, you should look into the TableCellEditor interface, which derives
from CellEditor.
In particular, check the stopCellEditing() method in CellEditor. Its javadoc
states: " Tell the editor to stop editing and accept any partially edited
value as the value of the editor. The editor returns false if editing was not
stopped, useful for editors which validates and can not accept invalid
entries. "
Chances are, you will need to make your own full implementation of a
CellEditor/TableCellEditor, because DefaultCellEditor is really picky, and may
not suit your needs. FWIW, see the bug/RFE I submitted about it at the
bug parade, # 4222700.
Another (possibly simpler) answer is to create a custom document that does
all the validation itself... Then, just set the document of the editing
component to your custom document.
Patrick Forhan.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
Thanks!
jp
In article <373FEAB7...@hotmail.com>,
j wrote:
> I take that back. It does work.
>
> thankyou
> jh
>
> jh wrote:
>
> > Thank you for the reply scott
> > still no joy on this. it tried the invokeLater() but it only seems
to fire
> > once when
> > the table is setup. If I call editCellAt() is there any way to make
the
> > celleditor
> > stay in the cell. By the way i am using java 1.2.
> >