Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

LayoutFocusTraversalPolicy  RSS feed

 
Fred Henkel
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I've been looking for some sample code that shows how to assign a new LayoutFocusTraversalPolicy to a Layout. Any hints or nudges would be appreciated. Thanks.
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"henfr01" -

Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it here.

Thanks! and welcome to the JavaRanch!
 
Fred Henkel
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can be more specific:
How do you add the LayoutFocusTraversalPolicy object to the Layout object?
And I can be more long winded:
I was able to add a FocusTraversalPolicy to a JFrame using setFocusTraversalPolicy() as shown below and it managed the buttons I put on the content pane just fine - dispite the fact that I was using a layout. So, you say "you got it to work, what's your beef?". Well, I spent a lot of time trying to find a way get LayoutFocusTraversalPolicy to work - I'm just stupid that way. I can't see how you couple up a LayoutFocusTraversalPolicy with a Layout. I couldn't find any examples or clear explanation searching the web. (Doesn't mean it doesn't exist, just I couldn't find it). There is something I'm just not getting here.

class Policy extends FocusTraversalPolicy{
.
.
//defined methods here
.
}
public class Prob01GUI extends JFrame {
private Policy travPol;
public Prob01GUI(){
.
.
.
getContentPane().setLayout( new BorderLayout() );
// add some buttons
getContentPane().add( twelve, "North");
getContentPane().add( three, "East");
getContentPane().add( six, "South");
getContentPane().add( nine, "West");
.
.
.
this.setFocusTraversalPolicy( travPol );
.
.
.
}
}

thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!