🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.jbuilder.java.swing
2 messages
2 total messages Started by Maxim Golubitsky Sun, 23 Jan 2005 15:13
Focus traversal issue
#695
Author: Maxim Golubitsky
Date: Sun, 23 Jan 2005 15:13
42 lines
2116 bytes
Hello,

I translated my application from AWT to Swing and now have problem with
focus traversal in it.
The problem can be described using following example, where we have three
JTextFields:
One at the left side of two others, that are placed in a JPanel one above
the other.
           [  b  ]
[  a  ]
           [  c  ]
import javax.swing.*;
import java.awt.*;

public class Test extends JFrame {

  public Test(){
    getContentPane().setFocusTraversalPolicy(new
ContainerOrderFocusTraversalPolicy());
    getContentPane().setLayout(new FlowLayout());
    getContentPane().add(new JTextField("a"));
    JPanel panel = new JPanel();
    panel.setLayout(new GridLayout(2, 1));
    panel.add(new JTextField("b"));
    panel.add(new JTextField("c"));
    getContentPane().add(panel);
    pack();
  }

  public static void main(String[] args){
    new Test().show();
  }
}

In AWT, the focus was transferred in this order: a - b - c
However, in Swing it goes: b - c - a even if I am trying to explicitly set
ContainerOrderFocusTraversalPolicy.

Can somebody give me an idea how to get it to work in the correct order?

Thank you in advance,
Maxim Golubitsky
Re: Focus traversal issue
#696
Author: John McGrath [TeamB]
Date: Sun, 23 Jan 2005 21:09
18 lines
1497 bytes
On 1/23/2005 at 10:13:23 AM, Maxim Golubitsky wrote:

> In AWT, the focus was transferred in this order: a - b - c
> However, in Swing it goes: b - c - a even if I am trying to explicitly
> set ContainerOrderFocusTraversalPolicy.
> 
> Can somebody give me an idea how to get it to work in the correct order?

http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html

-- 
Regards,

John McGrath [TeamB]

---------------------------------------------------
Before sending me e-mail, please read:
    http://www.JPMcGrath.net/newsgroups/e-mail.html
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads