wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Passing key strokes between objects Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Passing key strokes between objects" Watch "Passing key strokes between objects" New topic
Author

Passing key strokes between objects

Shane Roylance
Ranch Hand

Joined: Aug 29, 2001
Posts: 72
I have a dialog that comes up to the user (JDialog). In this dialog is a JPanel containing JButtons, and a JScrollPane with a JTextArea. When the dialog first comes up the button has focus, but if the user types page up or page down I want to transfer that key stroke to my JTextArea. Can this be done? I do have a key listener on my button, but I don't know if I can transfer that key stroke or if that is even the right approach to my problem.
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4446
    
    5

I think a better approach would be to make the button a default button (see JRootPane.setDefaultButton(javax.swing.JButton)) then bring the form up with the JTextArea having focus.

------------------
Junilu Lacar
Sun Certified Programmer for the Java� 2 Platform


Junilu - [How to Ask Questions] [How to Answer Questions]
Shane Roylance
Ranch Hand

Joined: Aug 29, 2001
Posts: 72
That would be a great idea, I did not know about that functionality. But unfortunately I have a JScrollPane inside of my RootPane, if I give focus to my text field the scroll pane will eat up the activation event. Is there any way around that?
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4446
    
    5

Shane, I requested that this thread be moved here so that you'll have a better chance of getting answers.
------------------
Junilu Lacar
Sun Certified Programmer for the Java� 2 Platform
 
 
subject: Passing key strokes between objects
 
Similar Threads
JOptionPane buttons
Select Directory
JTextArea
how to create key stroke listen?
Passing key strokes between objects