aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes The story of the Enter and the Tab keys Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "The story of the Enter and the Tab keys" Watch "The story of the Enter and the Tab keys" New topic
Author

The story of the Enter and the Tab keys

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

In most applications that I have known as a user, the enter and the tab key where the same thing. They both would validate and they both would move to the next focusable object.
However in Java, they are different, one triggers an ActionEvent, while the other triggers a FocusEvent. one stays in the Object while the other moves to the next focusable object.
hmm, which behavior is better? what do you think? and If you want them both to validate and move to the next focusable object, what would you do to make this happen?
The problem I am having with this dilemna, is the validation and work that I am having one JTextfield accomplish.
It is a Textfield that accepts a Date only, not only does it validate that it is a date, but it will then pop up a dialog asking if it is a new Date, a modify of the another date, or cancel. If it is a new Date it adds the date to a JList, if it modifies a date, it modifies the corresponding date in the JList, and if they hit cancel it goes back into the Jtextfield, and not to the next Focusable field.
Here is the code I have tried:
client.slWin.bid.estDateAction(new ActionListener(){
public void actionPerformed(ActionEvent e){
actions.changeEstDate(e, client);
}
});
client.slWin.bid.estDateAction(new FocusAdapter(){
public void focusLost(FocusEvent e){
if (!e.isTemporary()){
actions.changeEstDate(e, client);
}
}
});
I use isTemporary() because I don't want to trigger the action if the user clicks out of the field with their mouse, which they might do before filling in the field completely, and getting into an infinite loop of messages saying "Invalid Date. Re-enter"
any suggestions?
Thanks
Mark Spritzler


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

Someone please help.
Thanks
Mark
Angela Lamb
Ranch Hand

Joined: Feb 22, 2001
Posts: 156
It's not quite clear what your question is. If you're asking how to get the actionPerformed method to transfer focus, try the following:

Calling transferFocus on a component will shift the focus to the next component.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17260
    
    6

ACtually your answer is what I was looking for. Thanks
Mark Spritzler
p.s. Have you done this and found that two Components had cursors blinking in them? I get that and I am not sure why?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: The story of the Enter and the Tab keys