Focus Traversal Problem

Hello,
I implemented my own focus traversal policy provider for a JPanel. It appears to be working fine except for one of my components (a JTextArea contained in a JScrollPane). If I ctrl+tab out of the JTextArea, my custom FTP is never used.
I am still new to the focus subsystem, so I am not sure how to properly debug the situation. I checked the following properties on the JScrollPane and the JTextArea:
--Focusable:  True for both
--FocusCycleRootAncestor:  My JPanel for both
--getFocusTraversalPolicy:  null for both
--FocusCycleRoot:  False for both
Since my Custom FTP is not used when tabbing out of the JTextArea, the focus is sent to the wrong component. This is not the only JTextArea in the JPanel (all of them are in JScrollPanes), but it is the only one that with this problem.
Is there a way for me to detect which FTP is being used? Any ideas why my FTP is not being used?
Aaron

Hello,
I implemented my own focus traversal policy provider for a JPanel. It appears to be working fine except for one of my components (a JTextArea contained in a JScrollPane). If I ctrl+tab out of the JTextArea, my custom FTP is never used.
I am still new to the focus subsystem, so I am not sure how to properly debug the situation. I checked the following properties on the JScrollPane and the JTextArea:
--Focusable:  True for both
--FocusCycleRootAncestor:  My JPanel for both
--getFocusTraversalPolicy:  null for both
--FocusCycleRoot:  False for both
Since my Custom FTP is not used when tabbing out of the JTextArea, the focus is sent to the wrong component. This is not the only JTextArea in the JPanel (all of them are in JScrollPanes), but it is the only one that with this problem.
Is there a way for me to detect which FTP is being used? Any ideas why my FTP is not being used?
Aaron

Similar Messages

  • Newbie Focus Traversal Problem

    I'm trying to do the equivalent of checking the "Tab Stop" checkbox in the MS C++ compiler's dialog layout tool. In other words, I want to go from field to field with the tab key. I've cut and pasted some code from another web site into my code but it doesn't do anything. Is this really the right code? I can't help be think I'm way off base here because it can't possibly be this insanely complex to do the equivalent of checking a checkbox in C++. Can it? What am I doing wrong?
    None of the println statements are ever hit.
    --gary
    import javax.swing.JDialog;
    import java.awt.event.ActionListener;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JButton;
    import java.awt.event.ActionEvent;
    import java.awt.Point;
    import java.awt.Dimension;
    import java.awt.*;
    import javax.swing.*;
    import java.net.*;
    import java.io.*;
    import javax.swing.border.*;
    import java.util.Arrays;
    import java.util.List;
    public class LoginDialog extends JDialog implements ActionListener {
        private boolean cancel = false;
        private boolean loggedIn = false;
        private String postUrl;
        private JButton cancelButton;
        private JButton loginButton;
        private JPanel myPanel;
        private JTextArea taLogin;
        private JPasswordField taPassword;
        private JTextArea taAccount;
        private Border outline;
        private Border margins;
        LoginDialog(JFrame frame) {
            super(frame, "Login to Your Account", true);
            myPanel = new JPanel();
            margins = BorderFactory.createEmptyBorder(15, 15, 15, 15);
            myPanel.setBorder(margins);
            getContentPane().add(myPanel);
            myPanel.setMaximumSize(new Dimension(100,100));
            myPanel.setLayout(new GridLayout(4,2));
            outline = BorderFactory.createLineBorder( Color.black );
            myPanel.add(new JLabel("Account Name:  "));
            taAccount = new JTextArea("",1,16);
            myPanel.add(taAccount);
            taAccount.setBorder(outline);
            myPanel.add(new JLabel("Admin ID:"));
            taLogin = new JTextArea("",1,10);
            myPanel.add(taLogin);
            taLogin.setBorder(outline);
            myPanel.add(new JLabel("Admin Acct Password:"));
            taPassword = new JPasswordField("");
            taPassword.setEchoChar('*');
            taPassword.addActionListener(this);
            myPanel.add(taPassword);
            cancelButton = new JButton("Cancel");
            cancelButton.addActionListener(this);
            cancelButton.setBounds(80, 40, 100, 100);
            myPanel.add(cancelButton);       
            loginButton = new JButton("Login");
            loginButton.addActionListener(this);
            myPanel.add(loginButton);
            final Component order[] =
              new Component[] {taAccount, taLogin, taPassword};
            FocusTraversalPolicy policy = new FocusTraversalPolicy() {
              List list = Arrays.asList(order);
              public Component getFirstComponent(Container focusCycleRoot) {
    System.out.println("returning first object");
                return order[0];
              public Component getLastComponent(Container focusCycleRoot) {
    System.out.println("returning last object");
                return order[order.length-1];
              public Component getComponentAfter(Container focusCycleRoot,
                  Component aComponent) {
                int index = list.indexOf(aComponent);
    System.out.println("returning next object");
                return order[(index + 1) % order.length];
              public Component getComponentBefore(Container focusCycleRoot,
                  Component aComponent) {
                int index = list.indexOf(aComponent);
                return order[(index - 1 + order.length) % order.length];
              public Component getDefaultComponent(Container focusCycleRoot) {
    System.out.println("returning default object");
                return order[0];
            setFocusCycleRoot(true);
            myPanel.setFocusTraversalPolicy(policy);
            pack();
            setLocationRelativeTo(frame);
            setVisible(true);
        public void actionPerformed(ActionEvent e) {
            Object source = e.getSource();
            boolean good = false;
            loggedIn = false;
            if(source==cancelButton) {
                cancel = true;
                setVisible(false);
            } else if (source==loginButton) {
                String account = taAccount.getText();
                String login = taLogin.getText();
                String password = new String(taPassword.getPassword());
                String postData = account+")+("+login+")+("+password;
                try {
                    URL my_url = new URL("http://www.--myURL--.com/logger.php");
                    HttpURLConnection connection =  (HttpURLConnection)my_url.openConnection();
                    connection.setDoOutput(true);
                    connection.setUseCaches (false);
                    connection.setRequestMethod("POST");
                    connection.setFollowRedirects(true);
                    connection.setRequestProperty("Content-Length", ""+postData.length());
                    connection.setRequestProperty("Content-Language", "en-US");
                    connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
                    DataOutputStream posted = new DataOutputStream (connection.getOutputStream ());
                    posted.writeBytes(postData);
                    posted.flush ();
                    posted.close ();
                    BufferedReader inStream = new BufferedReader(new InputStreamReader(connection.getInputStream()));
                    String inputLine;
                    good = false;
                    while ((inputLine = inStream.readLine()) != null) {
                        System.out.println("Server response: "+inputLine);
                        if (inputLine.substring(0,4).equals("url=")) {
                            postUrl = inputLine.substring(4);
                            good = true;
                            cancel = false;
                            loggedIn = true;
                        } else if (inputLine.equals("invalid login")) {
                            good = true; // server did respond, but response was "invalid login"
                            loggedIn = false;
                    inStream.close();
                    if (!good) {
                         JOptionPane.showMessageDialog(null, "Unable to contact server.\nTry again later.", "alert", JOptionPane.ERROR_MESSAGE);
                } catch (MalformedURLException me) {
                    System.out.println("MalformedURLException: " + me);
                    JOptionPane.showMessageDialog(null, "Unable to contact server.\nTry again later.", "alert", JOptionPane.ERROR_MESSAGE);
                } catch (IOException ioe) {
                    System.out.println("IOException: " + ioe);
                    JOptionPane.showMessageDialog(null, "Unable to contact server.\nTry again later.", "alert", JOptionPane.ERROR_MESSAGE);
                if (loggedIn) {
                    setVisible(false);
                } else {
                    JOptionPane.showMessageDialog(null, "Login or password not correct.", "alert", JOptionPane.ERROR_MESSAGE);
        public boolean ifCancel() { return cancel; }
        public boolean ifLoggedIn() { return loggedIn; }
        public String getPostUrl() { return postUrl; }
    }

    an example here
    http://forum.java.sun.com/thread.jspa?threadID=738872
    which changes a GridLayout's traversal from left-right to up-down
    basically you put the components (in the order you want) into a Component[],
    which is used by the FocusTraversalPolicy for next/previous etc.
    note: won't work across FocusCycles - needs additional code for that

  • Problems with focus traversal after moving to j2sdk_1.4.1_02

    Hi,
    Just moved to j2sdk_1.4.1_02 and we are having problems where
    focus stays on wrong UI component e.g. a user(user2) is taking edit/write permissions from another user(user1) that has write permissions. User1 is told that they will lose write permissions in
    the next 15 minutes ( information dialog displayed on their screen ) while at the same time on user2's window a text label is updated
    every 5 seconds to say how long before they will have write permissions,
    however, the information dialog displayed on user1 hangs and
    the user can't remove this dialog. Control seems to stay with user2.
    This used to work with the previous java version we used.
    Hope someone can help,
    Thanks

    Didn't say what version you came FROM, but I'm guessing if
    you're having focus related problems it was from PRIOR to 1.4
    when focus handling was revamped.
    You probably need to make sure you are using requestFocusInWindow()
    everywhere instead of requestFocus().
    Check here and possibly search for 1.4 and KeyboardFocusManager
    for new focus handling tutorials.

  • Setting a JTree renderer breaks the focus traversal order

    Hello,
    I am not sure what's wrong, but when I set a customize JTree renderer it breaks the focus traversal order of my UI. Can someone tell me what's wrong and also how to prevent it from changing the order of my components?
    For instance, if I have component order 1, 2, 3, 4, 5 to begin with and after I call JTree.setCellRenderer(new SomeRenderer()), the order would change to something like this 1, 2, 4, 5, 3
    To give you an overview of what I am creating, I am customizing a UI that will be plug into JFileChooser to replace the default UI. I know I can create my own FocusTraversalPolicy, but the thing is that I don't know some of my components ahead of time. As long as I can prevent the order change, I think it would be fixed.
    Regards,
    Soot

    Try creating a Short, Self-Contained, Compileable, Executable
    program which has this problem. Right now it would take a
    mind-reader to solve your problem.

  • JApplet Focus Traversal 1.4

    I am writing a new JApplet and I am having problem with focus traversal.
    Hitting the tab key on Windows 2000 doesn't traverse through the
    components that are on the JApplet's contentpane. It happens with the 1.4
    appletviewer and with IE5.5 and IE6 using the 1.4 plugin. Below is the code and if I change
    it to extend Applet and add Buttons it works fine. Furthermore, if I run
    it as a standalone application (by extending JFrame) OR if I pop up an external JFrame from the applet it works fine. Is there something I missing?
    import javax.swing.*;
    import java.awt.*;
    public class AppletTest extends JApplet {
         public void init() {
              Container c = getContentPane();
              c.setLayout(new FlowLayout());
              c.add(new JButton("button1"));
              c.add(new JButton("button2"));
              c.add(new JButton("button3"));          
         public void start() {
    Anthony

    Try this!
    As I found out that when I used the plugin with the show console option, the focus traversal worked fine. But when I changed this option to hide or don't start up, the focus traversal failed to work.
    So I tried to find out what the differences where. I found this. When the show console option
    is selected, the parent frame (provided by the browser) has a focus traversal policy named:
    javax.swing.LayoutFocusTraversalPolicy
    With both the other options this was the java.awt.DefaultFocusTraversalPolicy.
    This code will set the DefaultFocusTraversalPolicy to the javax.swing.LayoutFocusTraversalPolicy.
    After this everything works normal.
    Place this in the start of the init () method of JApplet
    Container parent = this.getParent ();
    while (!(parent instanceof Window) && parent != null)
    parent= parent.getParent ();
    if (parent != null)
    parent.setFocusTraversalPolicy (new javax.swing.LayoutFocusTraversalPolicy ());

  • Changing the application wide default focus traversal policy

    Hi,
    I have a Swing application built using JDK1.3 where there lots of screens (frames, dialogs with complex screens - panels, tables, tabbed panes etc), in some screens layouts have been used and in other screens instead of any layout, absolute positions and sizes of the controls have been specified.
    In some screens setNextFocusableComponent() methods for some components have been called at some other places default focus traversal is used. (which I think is the order in which the components are placed and their postions etc). Focus traversal in each screen works fine.
    Now I have to migrate to JDK1.4. Problem now is that after migrating to JDK1.4.2, focus traversal has become a headache. In some screens there is no focus traversal and in some there is it is not what I wanted.
    So I thought to replace applicaiton wide default focus traversal policy and I did the following:
    ///////// Replace default focus traversal policy
    java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalPolicy(new java.awt.ContainerOrderFocusTraversalPolicy());
    But there is no change in the behaviour.
    Then I tried following:
    ///////// Replace default focus traversal policy
    java.awt.KeyboardFocusManager.getCurrentKeyboardFocusManager().setDefaultFocusTraversalPolicy(new java.awt.DefaultFocusTraversalPolicy());
    I did all this in the main() method of the application before anything else just to ensure that all the components get added after this policy has been set. But no luck.
    Does someone has any idea what is the problem here ? I do not want to define my own focus traversal policy for each screen that I use (because thats lot of codes).
    Thanks

    not that hard if you only have the one focus cycle ( > 1 cycle and it gets a bit harder, sometimes stranger)
    import javax.swing.*;
    import java.awt.*;
    class Testing
      int focusNumber = 0;
      public void buildGUI()
        JTextField[] tf = new JTextField[10];
        JPanel p = new JPanel(new GridLayout(5,2));
        for(int x = 0, y = tf.length; x < y; x++)
          tf[x] = new JTextField(5);
          p.add(tf[x]);
        final JTextField[] focusList = new JTextField[]{tf[1],tf[0],tf[3],tf[2],tf[5],tf[4],tf[7],tf[6],tf[9],tf[8]};
        JFrame f = new JFrame();
        f.setFocusTraversalPolicy(new FocusTraversalPolicy(){
          public Component getComponentAfter(Container focusCycleRoot,Component aComponent)
            focusNumber = (focusNumber+1) % focusList.length;
            return focusList[focusNumber];
          public Component getComponentBefore(Container focusCycleRoot,Component aComponent)
            focusNumber = (focusList.length+focusNumber-1) % focusList.length;
            return focusList[focusNumber];
          public Component getDefaultComponent(Container focusCycleRoot){return focusList[0];}
          public Component getLastComponent(Container focusCycleRoot){return focusList[focusList.length-1];}
          public Component getFirstComponent(Container focusCycleRoot){return focusList[0];}
        f.getContentPane().add(p);
        f.pack();
        f.setLocationRelativeTo(null);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setVisible(true);
      public static void main(String[] args)
        SwingUtilities.invokeLater(new Runnable(){
          public void run(){
            new Testing().buildGUI();
    }

  • Problematic focus traversal (JTextArea)

    I have a data entry dialog with several JTextFields and one JTextArea.
    Focus traversal (with the tab key) works nicely between instances of JTextField, but it is not possible to tab out of the JTextArea to the next JTextField (as a tab is inserted in the text area instead). I've have looked up swing focus traversal in books, but no cigar when it comes to dealing with JTextAreas
    Does anyone know how to fix this? I don't need to enter tabs into the text area.
    thanks,
    Andy

    There is a Swing forum for Swing related questions.
    Have you tried searching the forum?. Using keywords "+jtextarea +tab" would be a good place to start. You'll be amazed how many times this question has been asked/answered before.
         This example shows two different approaches for tabbing out of a JTextArea
    import java.awt.*;
    import java.util.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class TextAreaTab extends JFrame
         public TextAreaTab()
              // Reset the FocusManager
              JTextArea textArea1 = new JTextArea(5, 30);
              textArea1.setText("1\n2\n3\n4\n5\n6\n7\n8\n9");
              JScrollPane scrollPane1 = new JScrollPane( textArea1 );
              getContentPane().add(scrollPane1, BorderLayout.NORTH);
              textArea1.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, null);
              textArea1.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, null);
              scrollPane1.getVerticalScrollBar().setFocusable(false);
              scrollPane1.getHorizontalScrollBar().setFocusable(false);
              //  Replace the Tab Actions
              JTextArea textArea2 = new JTextArea(5, 30);
              textArea2.setText("1\n2\n3\n4\n5\n6\n7\n8\n9");
              getContentPane().add(new JScrollPane(textArea2), BorderLayout.SOUTH);
              InputMap im = textArea2.getInputMap();
              KeyStroke tab = KeyStroke.getKeyStroke("TAB");
              textArea2.getActionMap().put(im.get(tab), new TabAction(true));
              KeyStroke shiftTab = KeyStroke.getKeyStroke("shift TAB");
              im.put(shiftTab, shiftTab);
              textArea2.getActionMap().put(im.get(shiftTab), new TabAction(false));
         class TabAction extends AbstractAction
              private boolean forward;
              public TabAction(boolean forward)
                   this.forward = forward;
              public void actionPerformed(ActionEvent e)
                   if (forward)
                        tabForward();
                   else
                        tabBackward();
              private void tabForward()
                   final KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
                   manager.focusNextComponent();
                   SwingUtilities.invokeLater(new Runnable()
                        public void run()
                             if (manager.getFocusOwner() instanceof JScrollBar)
                                  manager.focusNextComponent();
              private void tabBackward()
                   final KeyboardFocusManager manager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
                   manager.focusPreviousComponent();
                   SwingUtilities.invokeLater(new Runnable()
                        public void run()
                             if (manager.getFocusOwner() instanceof JScrollBar)
                                  manager.focusPreviousComponent();
         public static void main(String[] args)
              TextAreaTab frame = new TextAreaTab();
              frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
              frame.pack();
              frame.setLocationRelativeTo(null);
              frame.setVisible(true);

  • How to disable the Tab key Focus Traversal

    I have to disable the default focus traversal function of tab key

    The method tht you need to look into is setTraversalPolicy()

  • JavaFx Adding Focus Traversable Keys.  Any Ideas?

    Hallo,
    Since there is currently now way to add other keys to the focus traversable list, I have to create my own method of doing it.  What I want to do is have a single scene, and in that scene I want the enter key to behave  
    the same as a tab key.  But there are a lot of Buttons, TextField, ChoiceBoxes etc.  Therefore Pressing enter key must take me to the next focusable item.  I have really been struggling to find a method that work.  I am really stuck.  Some help would be much appreciated.
    Thank you

    Well there are a few things you can do imo.
    1.  Create KeyEvents for each of your controls.
    2. http://download.java.net/jdk8/jfxdocs/index.html? click Scene, then NODE(for some reason the HTML links do not appear, and the one I had was for "SHAPE 3D").
    focusedpublic final ReadOnlyBooleanProperty focusedPropertyIndicates whether this Node currently has the input focus. To have the input focus, a node must be the Scene's focus owner, and the scene must be in a Stage that is visible and active. See requestFocus() for more information.
    See Also:
    isFocused(), setFocused(boolean)
    Default value:
    false
    focusTraversablepublic final BooleanProperty focusTraversablePropertySpecifies whether this Node should be a part of focus traversal cycle. When this property is true focus can be moved to this Node and from this Node using regular focus traversal keys. On a desktop such keys are usually TAB for moving focus forward andSHIFT+TAB for moving focus backward. When a Scene is created, the system gives focus to a Node whose focusTraversable variable is true and that is eligible to receive the focus, unless the focus had been set explicitly via a call to requestFocus().
    See Also:
    isFocusTraversable(), setFocusTraversable(boolean)
    Default value:
    false
    If you click either property it will brng you to the entire 8000 lines of the code, which I also cannot link for some reason.
    Both will link you to the area of code, and possibly you could edit this yourself.

  • N900 Camera: Video focus same problem as on N97?

    Ok so i've seen a few threads querying about the 2nd camera.  Not asking about that.  I noticed that back when i was using the N97 that when you tried to zoom in on images or even writing on the wall during a video recording, the camera's focus wouldn't auto update.  however when you are taking simple stills, the camera tries to focus before you take a shot.
    to me i see no difference between the two and by that i mean the same problem has been ported over to the n900.
    Anyone else notice this?  has this been mentioned on maemo.org or other sites were developers are aware of this?
    Bagz Rules

    So generous people; thank you for your time.
    I visited the camera store and we discovered that my camera lcd was set to the maximum brightness level which completely distorted any understanding of my exposure. What I now see on the lcd in terms of ligt and shadow is very similar to what I see on my computer screen.
    Maybe you can shed light on this:
    I also may need to just upgrade my imac. On the camera store's late model imac my images were tac sharp but on my imac they look quite soft and still have less light.
    There is also still some difference in terms of color settings. My camera's colors have a brighter pinkish tone and on the camera store's imac and mine the tone is yellowish orange.
    I will try DPReview and Nikoncafe. My first step is to reset my cameras to factory defaults and then upload and compare.
    Thank you both for your help

  • Focus Management Problems in JDK 1.4.0

    Hallo all,
    I have a severe problem in focus management. I inherited an applet designed in JDK 1.2.2 using focus events to generate calls in the correcponding server application. Now I'm trying to port this applet to JDK 1.4.0 for some good reasons such as character sets for eastern europe. But the focus management is complety changed and all attempts where stopped by bugs and workarounds for bugs in JDK 1.2.2 which are not valid in JDK 1.4.0.
    At the moment I'm searching a way to veto all focus events generated before "now" but accepting all generated after "now". Unfortunately no time stamps were supported for FocusEvents. By the way, "now" is the situation I find the server call while executing a focusLost on a component.
    Have anybody an idea how I can build a VetoableChangeListener blocking all FocusEvents generated before a special moment?
    Thanks for kinds of hints or answers!
    Werner

    The problem you are having is that jdev doesn't support the new beta..I have the same problem and I am currently compiling and executing from the command line
    I heard there is a workaround but I have never found it
    sorry

  • Tab Traversal problem in JTable

    Hi all,
    I am having a requirement in my current project to traverse across the cells of a JTable. Some of the cells were set CustomCelleditor(mainly textfield).
    I have gone through the threads in this forum and tried a code snippet which is now highlighting the text on tab traversal. But there are 2 problems with which I am facing with :-
    1. I need to press tab twice to move to the next cell(one is stopping cell editing and the other is to traverse to the next cell).
    2. When I moved from cell 1 to cell2 using tab and then click on cell1, the text is not getting highlighted.
    Please help me in resolving these issues ?
    The code I tried includes :-
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.table.*;
    import javax.swing.text.*;
    public class TableSelectAll extends JFrame{
         JTable table;
         public TableSelectAll() {     
              Object[][] data = { {"1", "A"}, {"2", "B"}, {"3", "C"}, {"4", "D"} };
              String[] columnNames = {"Number","Letter"};
              DefaultTableModel model = new DefaultTableModel(data, columnNames);
              table = new JTable(model) {   
              public void changeSelection(int row, int column, boolean toggle,
    boolean extend) {
              super.changeSelection(row, column, toggle, extend);
                   SwingUtilities.invokeLater( new Runnable(){                 
                   public void run() {    
                        table.dispatchEvent(new KeyEvent( table,                               KeyEvent.KEY_PRESSED,
                             0,
                             0,
                             KeyEvent.VK_F2,
                             KeyEvent.CHAR_UNDEFINED) );
                   JScrollPane scrollPane = new JScrollPane( table );
                   getContentPane().add( scrollPane );
                   MyCellEditor dce = new MyCellEditor( new SelectAllEditor() );
                   dce.setClickCountToStart( 1 );
                   table.setDefaultEditor(Object.class, dce );
         class SelectAllEditor extends JTextField implements FocusListener { 
              public SelectAllEditor() {           
              setBorder( new LineBorder(Color.black) );
              addFocusListener( this );
    public void setText(String text) {
         super.setText(text);
         System.out.println("text");
         selectAll();
    public void focusGained(FocusEvent e) { 
         System.out.println("gained");
         if (getSelectionStart() == getSelectionEnd())
         selectAll();
         public void focusLost(FocusEvent e) {}
    class MyCellEditor extends DefaultCellEditor {
    public MyCellEditor(JTextField t) {
    super(t);
    public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int
    row, int column) {
    final Component c = super.getTableCellEditorComponent(table, value, isSelected, row, column);
    if (c != null && c instanceof JTextField) {
    try {
    c.requestFocus();
    } catch (Exception e) {
    //handleException(e);
    return c;
    public static void main(String[] args) {   
         TableSelectAll frame = new TableSelectAll();
         frame.setDefaultCloseOperation( EXIT_ON_CLOSE );
    frame.pack(); frame.setVisible(true);
    Regards
    Nagalakshmi

    Additional info:[http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=017300]

  • Forms 10g - mouse focus/navigation problem

    Hello.
    We use:
    - IE 6
    - Java Plug-in 1.5.0_04
    - iAS 10.1.2.0.2 (patch 5023945) on HP-UX 11i
    We are experiencing an annoying problem. Our ORACLE Forms 10g application (migrated a few months ago from forms 4.5) sometimes loses navigation: mouse clicks stop changing cursor item focus or executing buttons ... Many users can't avoid pressing CTL+ALT+DEL to stop it...
    It seams to happen more frequently when users have different windows from different applications opened, navigate to them and then return focus to our application...
    We made a workaround that minimized some specific situations:
    - avoided enabled image items
    - reviewed navigation code to blocks whose first item wasn't navigable (we switched some GO_BLOCK to GO_ITEM)
    Should we go to Patch ID 6311490 (focus fix) for 10.1.2.2 iDS and iAS? Is there any other one more suitable?
    Which patch should we consider for this situation?
    Thanks in advance.
    Luis Amorim

    Hi Luis
    I've seen this sort of thing before and it wasn't easy to solve. There are things you can do to make it better. Check out Oracle Bug 6737974 on metalink. The main cause seemed to be when-deactive-window trigger.
    HTH & Good luck
    Steve

  • Component that is focusable, but not focus- traversable

    Hi,
    I have found a tidy solution to this, and posted it in the thread I thought was most appropriate, THEN I found, it was in the REFLECTION forum - duh.
    I won't cross post the whole solution here.
    So if you're interested, bowl over there for the answer
    http://forum.java.sun.com/thread.jspa?messageID=3541807&#3541807
    Cheers
    Bruce

    Answer,
    I have a status field on my dialog that shouldn't be keyboard traversible, but I would like the user to be able to cut the contents (such as an error display), so I need to be able to have it focusable by mouse click.
    I did this by enclosing the component inside a focusCycleRoot container that isn't itself focusable !!
    original code, status widget gets focus when traversing via keyboard.
            JTextField status = new JTextField();
            status.setColumns(40);
            status.setEditable(false);
            status.setFocusable(true); // So user can cut the text with mouse
            status.setBorder(new javax.swing.border.EmptyBorder(status.getInsets()));
            container.add(status, "layout stuff");This is the modified code, which stops status being traversible by keyboard.
            JTextField status = new JTextField();
            status.setColumns(40);
            status.setEditable(false);
            status.setFocusable(true); // So user can cut the text with mouse
            status.setBorder(new javax.swing.border.EmptyBorder(status.getInsets()));
            Container statusTraversalHider = new JPanel();
            statusTraversalHider.add(status);
            statusTraversalHider.setFocusCycleRoot(true);
            statusTraversalHider.setFocusable(false);
            container.add(statusTraversalHider, "layout stuff");

  • Tablerow focus lost problem

    Hello to all
         First of all, I have to excuse for my english - I know, it is horrible. In looking for someone, who can give me some advices/solutions for fellowing problem with/in Swing.
    I have to determine if row in JTable looses focus. If that's the case, focus must return to specific column. When focust is transfered within table (from one row to another)
    that no problem, but if the user clicks for example button somewhere on panel outside table, focus must be trasferred back to table and to row that has been left.
    To make the task more difficult the action started when the user click the button has to be canceled also. For the first part of the problem I've try to do fellowing:
    //widget - my JTable
    widget.addFocusListener(new FocusAdapter() {
           @Override
        public void focusLost(FocusEvent e) {         
             final int selectedRow = widget.getColumnModel().getSelectionModel().getAnchorSelectionIndex();
             //determining currently selected row, checking if its not empty and if focus wasn't transferred to any of
             //cell editors
           if (selectedRow != -1 && checkRowEmptyness.isRowEmpty(selectedRow) && !widget.isEditing()) {
            widget.requestFocusInWindow();
            widget.changeSelection(selectedRow, checkRowEmptyness.colNumber(), false, false);
      }); For the cancel event part of described problem - I have simply no idea how to do that. Can someone help my with that or at least point my to the right direction?
    Thanks.

    If you have a requirement that all the columns in a single row must have valid values then why not create a popup dialog to edit/change all the values at once. That way you can control when the dialog is closed. "Cancel" would ignore the changes and "Ok" would validate that all fields have a valid value before you close the dialog and update the model.

Maybe you are looking for

  • Line item wise billing

    Hi All, Can we do sale order related billing for individual line item wise and quantity wise? If this is for delivery related billing then the setting will be in item category, billing relevance as K. But what will be the settings for order related b

  • Increase in fees

    I received my latest bill and it's significantly higher than past bills. There was a recent change in service, which I didn't request, so why am I being charged? Also, this is my 4th bill after being charged the installation fees so my anticipation w

  • PO  with reference to Purchase requisition

    Hi Friends Good Morning, could you please help me out on one issue.My Client requirement is that Purchase order should be created only with reference to Purchase requisition.How can this be done please help ASAP. Regards VS

  • Confused over video sizing and positioning

    I'm using FB 4.5.1 to create a mobile app and having a bit of trouble figuring out what's happening with sizing.  My stage is 480x800 so that's what I set my container to but no change in video size.  So I size the video but I have to use 320x240 to

  • Getting return value of a method in an interface

    Hello! I have a problem. I have an interface called I. One of the declared method in this interface is M. And I have a class called C. Class C declares Interface I. I want to get the return value of the method M. I used invoke method. M.invoke(anInst