Changing tab order indexing

B

bruce

How do I change the tab order of my components? I checked the
properties for the components and didn't see anything germane.

Thanks..

Bruce
 
B

bruce


I created my JFrame by using NetBeans and drag & dropping the base
frame on my form. I can't figure out how to "name" this base frame. I
want to try

//Make textField get the focus whenever frame is activated.

frame.addWindowFocusListener(new WindowAdapter() {
public void windowGainedFocus(WindowEvent e) {
textField.requestFocusInWindow();
}
});

which is in the URL you sent me.

How can I do that?

Thanks...

Bruce
 
J

John B. Matthews

bruce said:
I created my JFrame by using NetBeans and drag & dropping the base
frame on my form. I can't figure out how to "name" this base frame.
I want to try

//Make textField get the focus whenever frame is activated.

frame.addWindowFocusListener(new WindowAdapter() {
public void windowGainedFocus(WindowEvent e) {
textField.requestFocusInWindow();
}
});

which is in the URL you sent me.

How can I do that?

In this example, <http://pastebin.com/nWHciPh0>, Main extends JFrame.
After line 10, one might add the following:

this.addWindowFocusListener(new WindowAdapter() {...});
 
M

markspace

I created my JFrame by using NetBeans and drag& dropping the base
frame on my form. I can't figure out how to "name" this base frame. I
want to try

If you have a component on your JFrame, it's got a name. Right click,
pick Change Variable Name... or look at the Inspector window. The
JFrame itself doesn't have a name, because it's not instantiated yet.
You can of course use "this" inside any of its instance methods to refer
to the JFrame.
public void windowGainedFocus(WindowEvent e) {


This appears to be only available on the JFrame itself. Right click on
it, pick Events > Window Focus > WindowGainedFocus. If you need to
propagate this to your sub-component, a little programming may be in order.
 
L

Lew

In this example,<http://pastebin.com/nWHciPh0>, Main extends JFrame.
After line 10, one might add the following:

this.addWindowFocusListener(new WindowAdapter() {...});

Another way is to have a main class contain a JFrame member. This is useful
when you don't need to specialize the behavior of the JFrame. The JFrame can
also live as a local variable inside a 'main' or other method.

The question of extending (inheritance) vs. including (composition) is part of
the art.
 
A

Arne Vajhøj

Another way is to have a main class contain a JFrame member. This is
useful when you don't need to specialize the behavior of the JFrame. The
JFrame can also live as a local variable inside a 'main' or other method.

The question of extending (inheritance) vs. including (composition) is
part of the art.

That style is occasionally used.

But it seems as if extending JFrame is the most commonly
used model.

Maybe just because SUN created a lot of examples with that
model.

Arne
 
J

John B. Matthews

Another way is to have a main class contain a JFrame member. This
is useful when you don't need to specialize the behavior of the
JFrame. The JFrame can also live as a local variable inside a
'main' or other method.

The question of extending (inheritance) vs. including (composition)
is part of the art.

That style is occasionally used.

But it seems as if extending JFrame is the most commonly
used model.

Maybe just because SUN created a lot of examples with that
model.[/QUOTE]

It surely influenced me, although the example I cited above was
generated by NetBeans. Two pitfalls I've seen with extending JFrame,
especially when re-factoring: it's easier to leak "this", and it's
harder to reuse the code.

FWIW, a colleague advocates using the designer more for the occasional
difficult panel, rather the for an entire application.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,172
Latest member
NFTPRrAgenncy
Top