Article View: borland.public.jbuilder.java.language
Article #19346Please help with this bit of code
From: Walter Draffin
Date: Thu, 12 Feb 1998 00:00
Date: Thu, 12 Feb 1998 00:00
59 lines
2328 bytes
2328 bytes
Alex McManus wrote:
>In Java, the tabbing order within a container is determined by the
order in
>which the components are added. If this is not convenient, you can use
the
>Container.add( Component, int ) form of the method to add the component
at a
>specified position.
I need to do the latter, but I'm not sure quite how to go about it since
the component I actually
want to get the focus is not directly on the Container but actually
inside another compnent. Would
I do this by saying: if paper_gb_recdate receives focus, set focus to
paper_tf_recdate? This way I
would set focus to the groupbox and it would automatically set the focus
to the text field. How does
this sound or is there a better way?
Paper is a frame
paper_gb_recdate and paper_gb_time are groupboxes
paper_tf_recdate and paper_tf_time are textfields
paper_tf_recdate.addKeyListener(new Applet1_Enter_keyAdapter(this));
paper_tf_time.addKeyListener(new Applet1_Enter_keyAdapter(this));
Paper.add(paper_gb_recdate, new GridBagConstraints2(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new
Insets(0, 0, 0, 0), 102, -6));
paper_gb_recdate.add(paper_tf_recdate, BorderLayout.CENTER);
Paper.add(paper_gb_time, new GridBagConstraints2(1, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.CENTER, GridBagConstraints.NONE, new
Insets(0, 0, 0, 0), 98, -5));
paper_gb_time.add(paper_tf_time, BorderLayout.CENTER);
void Enter_keyReleased(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER){
transferFocus();
}
}
class Applet1_Enter_keyAdapter extends java.awt.event.KeyAdapter {
Applet1 adaptee;
Applet1_Enter_keyAdapter(Applet1 adaptee) {
this.adaptee = adaptee;
}
public void keyReleased(KeyEvent e) {
adaptee.Enter_keyReleased(e);
}
}
Technical Details
Message-ID:
<34E344F5.F9C9447C@telegraph.net>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,3e4b29618936e9e0,start X-Google-Attributes: gidf74b3,public From: Walter Draffin <draffin@telegraph.net> Subject: Please help with this bit of code Date: 1998/02/12 Message-ID: <34E344F5.F9C9447C@telegraph.net> X-Deja-AN: 324510969 Content-Transfer-Encoding: 7bit Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: None Newsgroups: borland.public.jbuilder.java.language