• Post Reply Bookmark Topic Watch Topic
  • New Topic

When the focus is on a component....

 
Laurent S
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a JEditorPane nameEditCpy and i would like to use the method nameEditCpy.selectAll() when the focus is on nameEditCpy. How can I make?
thx
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Laurent,
Just make the JEditorPane a FocusListener. Then inside the focusGained method you can place the call to selectAll method.
...
JEditorPane nameEditCpy = new JEditorPane();
nameEditCpy.addFocusListener(
new FocusAdapter()
{
public void focusGained( FocusEvent fe )
{
selectAll();
}
});
...
Regards,
Manfred.
 
Laurent S
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great thx
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!