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.

Similar Messages

  • Focus Lost - Sticky Cursor

    Hi folks,
    When using 10gRel2 we get a lot of 'focus lost' problems. I read all threads here and in metalink; this problem is a very serious one and in some cases hard to reproduce. at least 10 different situation causes different focus lost situations.
    Oracle has concentrated that issue in the base bug 5358366.
    The fix for the focus lost problems will be implemented in JRE 1.5.0_9 which is currently not available at SUN. Nevertheless, has anybody received that internal version for testing? What's your experience?
    Thanks, werner

    Hi kndwds,
    Would be very interested in sharing some information re your Focus Lost question. We have had very similar issues in all versions of Forms (and occassionally have managed to create test cases) resulting in a number of patches. In 10.1.2 and the Sun JVM, the issue is very much worse, but currently we can not reproduce a repeatable test case.
    I have reviewed all the bugs, but this does not provide much meaningful information.
    Can you provide any update on the situation with your TAR, and if at all possible, full details of the test case that you have been able to provide.
    Any help much appreciated.
    Regards
    Marc Ludwig

  • JTable discards input when focus lost

    Hi! Im running Java 1.4.2-b28.
    Problem as follows:
    I have a JTable where the user can enter som data.
    I also have a button with the caption "Minimize" that starts processing of the same data.
    If i enter a value into the table (say "foo") and press "Minimize" when the cell is in editing mode, "foo" is NOT SAVED into the JTable's TableModel! getValueAt(int row, int col) returns an old value instead!
    How can i change the focus lost behaviour on the cell? Is this a bug??
    Regards
    /Alex

    Found an answer to this, sorry everyone. Well, here it is:
    http://forums.java.sun.com/thread.jsp?thread=350530&forum=57&message=1453945

  • Focus lost first ?

    i have 2 text fields, A and B. when i hit tab, focus travel from A to B, my question is which focus event occur first ? focus lost for A or focus gained for B ?

    i have a more complex problem, why i press the tab, the program won't fire the ket event? when i press enter, it fire the key event ? a sample code is provided and anyone can explain the result ?
    Ai got the focus
    key event fired
    Bi got the focus
    Ai lost the focus
    Ai lost the focus
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class test10 implements FocusListener, ActionListener, KeyListener
      private static JFrame frame;
      private static JPanel pane1;
      private static JTextField tfield1, tfield2;
      private static JTextField current = null;
      public test10()
        frame = new JFrame( "A frame" );
        frame.setSize( 100, 50 );
        pane1 = new JPanel();  
        tfield1 = new JTextField( "A", 5 );
        tfield1.setName( "A" );
        tfield1.addFocusListener( this );
        tfield1.addActionListener( this );
        tfield1.addKeyListener( this );
        tfield2 = new JTextField( "B", 5 );
        tfield2.setName( "B" );
        tfield2.setEnabled( false );
        tfield2.addFocusListener( this );
        tfield2.addActionListener( this );
        tfield2.addKeyListener( this );
        pane1.add( tfield1 );
        pane1.add( tfield2 );    
        frame.getContentPane().add( pane1 );
        frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
        frame.pack();
        frame.setVisible( true );
      public void keyPressed(KeyEvent e)
    System.out.println( "key event fired" );
        if(e.getKeyCode() == e.VK_TAB)
          if( current == tfield1 )
            tfield1.setEnabled( false );
            tfield2.setEnabled( true );
            tfield2.requestFocus();
          if( current == tfield2 )
            tfield2.setEnabled( false );
            tfield1.setEnabled( true );
            tfield1.requestFocus();
      public void keyTyped( KeyEvent e )
      public void keyReleased(KeyEvent e)   
      public void focusGained( FocusEvent fe )
        System.out.println( ((JTextField)fe.getSource()).getName() + "i got the focus" );
        current = (JTextField)fe.getSource(); 
      public void focusLost( FocusEvent fe )
        if( fe.getSource() == tfield1 )
          tfield2.setEnabled( true );
          tfield2.requestFocus();     
          tfield1.setEnabled( false );
          System.out.println( ((JTextField)fe.getSource()).getName() + "i lost the focus" );   
        if( fe.getSource() == tfield2 )
          tfield1.setEnabled( true );
          tfield1.requestFocus();  
          tfield2.setEnabled( false );  
          System.out.println( ((JTextField)fe.getSource()).getName() + "i lost the focus" );   
      public void actionPerformed( ActionEvent ae )
        if( ae.getSource() == tfield1 )
          tfield1.setEnabled( false );
          tfield2.setEnabled( true );
          tfield2.requestFocus();     
          System.out.println( ((JTextField)ae.getSource()).getName() + "i lost the focus" );   
        if( ae.getSource() == tfield2 )
          tfield2.setEnabled( false );          
          tfield1.setEnabled( true );
          tfield1.requestFocus();
          System.out.println( ((JTextField)ae.getSource()).getName() + "i lost the focus" );   
      public static void main( String[] args )
        test10 t = new test10();
    }

  • How to handle cell events like focus lost in  jtable

    Hi,
    I have faced a problem relating jtable.Upon focus lost on particular cell the values in the other cells need to change accordingly.Out of 7 columns, upon entering an integer value in one column accordingly 3 columns need to update the values fetched from database and get disabled.The columns being updated have a combobox in which the value is to be shown.....Please look at it and provide a working solution.
    Looking forward,
    chandra

    Try using a TableModelListener:
    http://forum.java.sun.com/thread.jspa?forumID=57&threadID=566133

  • Focus lost when a popup menu is activated...

    It seems that when a popup menu is activated the component invoker lost focus. this is ugly because a focus lost can trigger unexpected events (formatting, validating, etc). how can I avoid this?
    thanx

    I must seem a bit weird being the only one to reply to my posts, but I found what is occuring, is that when I do the mouse click the InputVerifier for that JTextField is firing. This is causing a problem, because this input verifier pops up a dialog saying please enter correct values ... and then highlights the entire text field. Problem is if the input is currently invalid I can't use the mouse.
    Any ideas?
    Tom

  • JTable Focus Lost

    Hi All,
    I have a JTable with 6 columns and the last column has a button attached called EXPAND.
    Also I have another navigation buttons called Next, Back, Save and Refresh.
    Whenever I make changes to the cell and then click on the expand button of the 6th column, it saves my changes.
    but when i make changes to the cell and then click some where else (other than on the JTable) ...here for example on the Refresh button ...and then click on the expand button on JTable, I could not save my changes ...
    i.e. it is not invoking my focusLost ...Is there any work around for this problem ...
    I am posting my focus Lost code :
    public void focusLost(FocusEvent e) {
    if (jTable.getSelectedColumn() >= 0) {
    if (jTable.getColumnName(jTable.getSelectedColumn()).equalsIgnoreCase("Expand")) {
    saveData();
    Many Thanks
    Mahesh

    try tableChange Listener, something like this
    class TableListener
           implements TableModelListener {
          private JTable table;
          public TableListener(JTable table) {
          this.table = table;
          public void tableChanged(TableModelEvent e) {
             int editRow = table.getEditingRow();
             String value = table.getValueAt(editRow, 1).toString();
             if (e.getType() == TableModelEvent.UPDATE) {
                save();
    [/code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Feature Request: Microsoft Excel 2013 - Don't hide status bar text on focus lost (AVERAGE, COUNT, SUM)

    Could you please disable hiding of status bar text on focus lost.
    I use this in Excel 2013, where I select a few cells, then move to another Excel to write the sum of those cells as read from the status bar or to check with other values in the second window. This really makes my life easier and I see no reason to hide
    the status bar text when the window looses focus.

    Hi,
    Thanks for your suggestions.
    You can also send your feedback to the Office team by the steps as below:
    1. Inside any new Office application you’ll see a yellow smiley face in the top-right corner. Click on the face and choose either
    Send a Smile to send positive feedback or
    Send a Frown to send negative feedback.
    2. In the window that appears, provide details about your feedback or issue. Also, be sure to provide a link to this thread.
    3. Next, you can choose whether or not to send a screenshot. You can also enter your email address so the Office team can contact you directly if they have any questions.
    Note: Most feedback requests do not result in responses from the Office team.
    4. Click the Send button at the bottom of the form to send your feedback.
    Best Regards,
    Judy

  • Focus lost called multiple time

    Hi
    I have created a simple search panel containing a JFormattedTextField
    and a button next to it .
    Now if focus is in JFormattedTextField and user press TAB , focus lost method is called and i have to validate the values , which is very straight forward .
    This focus lost method is being called only <b>once</b> on fedora linux , but is being called <b>thrice</b> on Windows XP .
    Any lead please ?
    Thanks
    Sunny Jain

    Two suggestions:
    1. Use an InputVerifier instead
    http://java.sun.com/javase/6/docs/api/javax/swing/InputVerifier.html
    2. If you insist on taking the FocusListener route, maybe you can check the isTemporary() flag on the FocusEvent? I'm guessing two of the three focus lost events will have isTemporary() == true (but I could very well be wrong).

  • Preventing Focus Lost

    I am trying to stop a focus lost on a JTextField. I was not able to find anything on this in the Forum or searching.
    Basically, I want to prevent a user from leaving a text field when the data is invalid, so focus lost should only be granted when valid.
    I tried overriding .transferFocus(), but of course you can just click on another component.
    I did find something that works at times, but is very dangerous. I added a focus listener and did something like this:
                public void focusLost(FocusEvent e)
                    try
                    {                    Toolkit.getDefaultToolkit().getSystemEventQueue().getNextEvent();
                    catch (InterruptedException ex){}
                    requestFocus();
                }Calling this will remove the focus gained event after the focus lost and .requestFocus() can be called to regain focus.
    Anyone have any ideas?

    Check out the InputVerifier class.
    Or, you can also use a [url http://java.sun.com/docs/books/tutorial/uiswing/components/generaltext.html#filter]Document Filter to prevent invalid character from being entered the the text field.
    Or, you can use a JFormattedTextField.

  • Connection lost problem while updating my Nokia As...

    Dear All,
    I face a connection lost problem while I am updating Nokia Asha 200 using Nokia Suite
    I installed Nokia software too many times, and tried to repair it. Also, I used another USB cable, but the problem still  happen
    While it is installing the software, it suddenly stops and show connection lost to your phone.
    When I try to restart and reconnect the USB cable, the problem still happen
    Nokia200
    V 10.61
    02-03-12
    RM-761
    Thanks in advance

    Dear Farby
    Thanks for your kind and quick reply.
    please note that I tried again now, and when the messages for connection lost appears again, I waited for 5 minutes, and nothing happens
    because it shows me to do steps, as follows :
    1. Disconnect USB cable from phone.
    2. restart your phone
    3. reconnect the USB cable
    4. Wait for the installation to continue.
    and when I do these steps, the phone restarts in a test mode, all I see is a test mode message over its screen.
    I believe that this is a fatal error which happens through the installation process and which leads to unsuccessful installation
    I lost hope in updating the software of this phone, escaially I need to do so, because I face problems with these phone, which doing a hard reset even don't fix.
    Thanks again, Farby ... for your help
    Regards,

  • Focus lost moving from one form to another in web deployed forms6i

    I have developed an application using forms6i rel 2
    The forms server is installed on windows 2000 and all necessary set up is done on the forms server. Patch 18 is also applied.
    On the client side I am using IE 6 and JRE Java 2 Ver 1.5.0_9-b03
    Everything works fine. But when I navigate from one form to another, the cursor focus is lost. This also happens when I navigate from one block to another block within the same form.
    In such situation when I press Windows button on the key board twice, the cursor reappears. It seems the problem is because the applet window where the forms is running is not refreshed while navigating to different forms.
    Can anybody guide me to solve this problem.
    Thanks
    Kamlesh

    Hi,
    I also have same problem ´but with forms 10g.
    If i set SeprateFrame=True then it works fine. but if applet is inside ie window and i move from this IE window to any other window and come back then focus is set to first menu item.
    whenever user comes back to forms apps, has to click somewhere in applet to activate it, this is so irritating.
    Seems that even oracle does not have any workaround for this, same thing happens on forms demo which is provided by oracle.
    Mehul

  • JFileChooser - Selection Highlight lost on Focus Lost

    I have a form with a JFileChooser, a JButton and a JTree. When I select files and that I select another object, the JFileChooser remove the highlight of my selected files (the object still have the list of selected files). So when I reselect the JFileChooser, its look like nothing was selected.
    Is there a setting to keep highlight when the focus is lost?
    Thanks

    U mean these:
    import java.applet.*;
    import java.awt.*;
    public class Cyclus extends Applet {
    public void init() {
    System.out.println("init");
    public void start() {
    System.out.println("start");
    public void update(Graphics g) {
    System.out.println("update");
    public void paint(Graphics g) {
    System.out.println("paint");
    public void stop() {
    System.out.println("stop");
    public void destroy() {
    System.out.println("destroy");
    the problem is that these methods are first called when the event has happent. I need it WHEN it happens....

  • Window Focus Lost After Saving Page - Any Way To Get It Back With Keyboard?

    I've recently begun using Safari for Windows after having used Opera for years, and have run into a problem with window focus that I didn't have with Opera. Specifically, if you save a web page in Safari, you then find that the following functions are no longer available from the keyboard:
    1. Going back to a web page previous to the one that you just saved. Ctrl+[ does not function.
    2. Performing a search. Ctrl+F does not function.
    3. Scrolling to the bottom or top of the page. Ctrl+End and Ctrl+Home do not function. (For some reason, however, the PageUp and PageDown keys do still work in this situation.)
    Why is this, and more importantly, is there a quick and easy way that you can, using only the keyboard, regain the window focus so that these functions will work again? I'm currently having to click somewhere on the page I've just saved in order to regain the focus. This is a nuisance.
    Thanks for any advice.
    George
    Message was edited by: safwin

    Thanks very much. Hitting 'Alt' button after saving the page does resolve the first (and most important) two of the three issues I listed above. FWIW, the Ctrl+End and Ctrl+Home functions only work in this post-save scenario (as I discovered by experimenting a few minutes ago) if you hit the 'Alt' button twice (or if you do something else, like perform a search and then use Ctrl+End/Home).
    By the way, before posting a few days ago, I had tried using the Alt+Tab method when I had two or more applications' windows open, and it didn't help. But, after reading your last post, I've found that if you use Alt+Tab when Safari is the only window open, then it does resolve the issue, although of course, as you've indicated, it's not actually necessary to hit the 'Tab' key.
    Thanks again!
    George
    Message was edited by: safwin

  • Focus lost in Oracle Application Server

    Dear All,
    We developed a custom system using Oracle Forms Developer 10.1.2.0.2. An Oracle Application Server 10g runs our forms. Users use it across the Internet using MS Internet Explorer 7. If a form contains 2 blocks and a user clicks the another block, the focus remains at previous block even the cursor is in the proper field.
    It used to work properly for a while (about 6 months). About 3 weeks ago the administrator restarted the server due to an error and since then we have been noticing this problem. We tried different versions of Java, different browsers(IE 7 and Firefox 3.6.3) at client side but the result is the same. I think the problem must be at server side but I don't have more ideas where it is.
    Can anybody help me?
    Thanks & Regards,
    Laszlo

    Laszlo,
    Use the Sun Java console in Internet Explorer to see if you can find any errors ( IE -> Tools -> Sun Java Console). There is not much to see here but you can turn all kinds of logging on. See:
    http://java.sun.com/j2se/1.5.0/docs/guide/deployment/deployment-guide/console.html
    regards,
    Bernhard Jongejan
    http://bernhardjongejan.spaces.live.com

Maybe you are looking for