Focus with JTable - JDK 1.4

Hi all, I wonder if there's anyone out there know about focus change on jdk1.4, please help me on this if you can:
with jdk 1.3, when I change focus between components on the same panel, I override this method of JTable to stop focus from being on table's rows only when the table has Focus since it does not move focus to the next component on the panel:
public boolean isManagingFocus() {
return false;
But when I use jdk 1.4 now, this method seems not work as expected anymore. The focus is now switch just between the rows when table has the focus and it does not move the focus to the next components on the panel when I hit TAB key.
If anyone knows how to fix this, please help me through. Anyhelp will be very appreciated.
CL

Sorry it's late but here goes.
isManagingFocus is deprecated in 1.4 so it's probably best not to use that anyway. It's also called from the constructor of JComponent so if it uses instance variables you might get things like NullPointerException if you're not careful.
I think the recommended way to approach it is to set the focus traversal keys something like this
// get your table from somewhere
JTable table = new JTable();
// use java.awt.AWTKeyStroke to set up the appropriate focus
// traversal keys
AWTKeyStroke tab = AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, 0);
AWTKeyStroke shiftTab = AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_DOWN_MASK);
AWTKeyStroke ctrlTab = AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, KeyEvent.CTRL_DOWN_MASK);
AWTKeyStroke ctrlShiftTab = AWTKeyStroke.getAWTKeyStroke(KeyEvent.VK_TAB, KeyEvent.CTRL_DOWN_MASK | KeyEvent.SHIFT_DOWN_MASK);
// create a java.util.Set for forwards and backwards focus traversal
// keys. The actual concrete Set you use probably doesn't matter.
// I've used a java.util.HashSet
HashSet forwardKeys = new HashSet();
HashSet backwardKeys = new HashSet();
// add the appropriate keys to the appropriate sets
forwardKeys.add(tab);
forwardKeys.add(ctrlTab);
backwardKeys.add(shiftTab);
backwardKeys.add(ctrlShiftTab);
// set the focus traversal keys on the table.
table.setFocusTraversalKeys(KeyboardFocusManager.FORWARD_TRAVERSAL_KEYS, forwardKeys);
table.setFocusTraversalKeys(KeyboardFocusManager.BACKWARD_TRAVERSAL_KEYS, backwardKeys);

Similar Messages

  • Issue with JTable

    Hi,
    I have a issue with JTable. I am reading an array and populating the cells in the JTable. After editing the cell values, on clicking a button, I update the value in to an array. The probelm is that after editing the value in the cell, if I don't use tab or enter key and move the focus away from the cell, I dont get the updated value when using the getValueAt method. Pleease let me know if there is any workaround for this behaviour.
    Thanks,
    Baskar N

    Just so you understand why that code snippit works, you have to stop or cancel editing before you can get the updated value of a cell.

  • Another problem with JTable

    Hi,
    I have encountered a problem with JTable, i am trying to display some 15 columns and their values , one of the columns value is null, then the JTable is not displaying its value from this column(which is with null value) onwards.
    Can anybody assiss me in this matter.
    Regards
    khiz_eng

    I don't know If I can fix your problem, but
    I know just that it works on my PC.... It's very very
    slow... I don't know how to insert PageSetUp option... I have to study the problem.....
    However I don't think it's a hard problem....
    I want ask to you if you have found some problems when you are in Editing mode in a cell.....
    in the jdk1.2 version I could save while was in editing mode using the editingStopped method.
    It permit to update all data .... also the data in the cell I was editing.
    in the jdk 1.3 if I use this method It doesn't work properly... It maybe destroy the content object in the Cell..... because I'm able to print all the table except the editing cell (it throw an exception...)
    What's changed????
    I don't know...
    Can u help me?

  • A problem with JTable

    Hi !
    I have a problem with JTable - would like to use this component as a simple list of rows taken from a database : don't want to be able select or set a focus to a column - want only to be able select and set focus to a row ( just like in the menus). How to disable "focusability" for a cell with JTable ? Could You help me ?
    thnx in advance

    The Border is changed by the renderer, depending on whether the cell has focus or not. So you will need to create custom renderers without a Border. Something like:
    class NoBorderRenderer extends DefaultTableCellRenderer
         public Component getTableCellRendererComponent(
              JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column)
              super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
              setBorder(null);
              return this;
    }

  • Mouselistner is not working with jtable in the browser

    Hi
    I am having a problem with jTable.
    I added a mouselistener to table header to sort table but when i run that applet from my netbean ide it works fine but when i run that applet in my browser it doesn't work, i have tested, its not even generate mouseclick event .Please help me guys.
    I call this function after calling initComponents() method of JApplet.
    public void setTableAction()
    //set mouselistener to sort table on click of table header
    final JTableHeader head= jTable1.getTableHeader();
    head.addMouseListener(new java.awt.event.MouseAdapter()
    public void mouseClicked(java.awt.event.MouseEvent evt)
    Vector data= ((DefaultTableModel)jTable1.getModel ()).getDataVector();
    sortTable(data, head.columnAtPoint(evt.getPoint()));
    //set action map to change the default action performed for enter key pressed
    InputMap imap = jTable1.getInputMap(JTable.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    KeyStroke enterKey = KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0);
    KeyStroke tabKey = KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0);
    final Action oldAction= jTable1.getActionMap().get(imap.get(tabKey)); // get map to set enter key.
    imap.put(enterKey, "enter"); // set enter key
    Action newAction = new AbstractAction(){
    public void actionPerformed(ActionEvent e) {
    oldAction.actionPerformed(e);
    JTable table= (JTable)e.getSource();
    table.changeSelection(0,0,false,false);
    if(table.isCellEditable(0,0))
    String sTemp= (String)table.getValueAt(0,0);
    if(sTemp.length()>0) {
    if(bRenewItem)
    retrieveRcodeDetails("",sTemp);
    else
    processRCodeDetails(sTemp, e);
    }else
    table.editCellAt(0,0);
    jTable1.getActionMap().put("enter", newAction);
    jTable1.setPreferredScrollableViewportSize(jTable1.getPreferredSize());
    }

    Hi,
    I also am using the Bépo layout with an encrypted drive and encountered the same problem: the Return key does not work.
    It seems to work fine if you use the fr-bepo-latin9 keymap.
    # /etc/vconsole.conf
    KEYMAP=fr-bepo-latin9
    But I also looked at the files /usr/share/kbd/keymaps/i386/bepo/fr-bepo.map.gz and /usr/share/kbd/keymaps/i386/bepo/fr-bepo-latin9.map.gz (you can open gzipped files in vim directly). fr-bepo-latin9.map.gz defines keycode 28 (Return) but fr-bepo.map.gz does not.
    I modified fr-bepo.map.gz:
    # vim /usr/share/kbd/keymaps/i386/bepo/fr-bepo.map.gz # Append that line : "keycode 28 = Return".
    # mkinitcpio -p linux # Rebuild the initramfs.
    The Return key now works, but the Backspace (14, "Delete") and Shift (54) keys don’t work. I found that both the cf.map.gz (french canadian layout) and fr-bepo-latin9.map.gz files define those keycodes as well as other non-printing keys so I copied the following lines from fr-bepo-latin9.map.gz to fr-bepo.map.gz:
    keycode 1 = Escape Escape
    keycode 14 = Delete Delete
    keycode 15 = Tab Tab
    keycode 28 = Return
    keycode 29 = Control
    keycode 42 = Shift
    keycode 54 = Shift
    keycode 56 = Alt
    keycode 58 = Caps_Lock
    keycode 97 = Control
    It works! Don’t forget to rebuild the initramfs after you change the keymap file.
    # mkinitcpio -p linux
    I will send a message to the kbd and bépo projects mailing lists and report back.

  • Selection Problem with JTable

    Hello,
    i have a selection problem with JTable. I want to allow only single cell selection and additionally limit the selection to the first column.
    I preffered the style from MS Outlook Express where you can select the email accounts to edit.
    It is a table like this:
    Account name  |   Type  |   ...
    --------------|---------|---------------------
    Hotmail       |   POP3  |
    GMX           |   IMAP  |The selection should be only avaibable at 'Hotmail' or 'GMX' - not at 'POP3', 'IMAP' or as complete row selection.
    Please help me!
    Thanks.
    Warlock

    Maybe this will helpimport java.awt.*;
    import javax.swing.*;
    public class Test3 extends JFrame {
      public Test3() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = getContentPane();
        String[] head = {"One", "Two"};
        String[][] data = {{"R1-C1", "R1-C2"}, {"R2-C1", "R2-C2"}};
        JTable jt = new JTable(data, head);
        jt.getColumnModel().setSelectionModel(new MyTableSelectionModel());
        content.add(new JScrollPane(jt), BorderLayout.CENTER);
        jt.setCellSelectionEnabled(true);
        jt.setRowSelectionAllowed(false);
        jt.setColumnSelectionAllowed(false);
        setSize(300, 300);
        setVisible(true);
      public static void main(String[] arghs) { new Test3(); }
    class MyTableSelectionModel extends DefaultListSelectionModel {
      public void setSelectionInterval(int index0, int index1) {
        super.setSelectionInterval(0, 0);
    }

  • Any body please can solve my problem that iam facing with JTable

    Dear sir,
    Iam doing an educational product using Swing as front end in that
    iam using JTables. And back end iam using sqlserver. With jtable iam
    facing very serious problem the problem is actually iam entering the values
    in all the columns after that iam pressing the save button its not
    saving but if i click on any of the columns and try to save its saving.
    please anybody can solve my problem.Please if a piece of code is there ill
    be very thankful to you. my mailid is [email protected]
    regards
    surya

    The problem is, the cellEditor does not know that editing has stopped and therefore has not updated the model (where the data actually resides). When you click off the cell to another cell, the first cell knows it must be done editing because you are leaving it. If you click a button (or anything other than another cell), the cell being edited has no knowledge of this. You need to call stopCellEditing() on the cell editor and your problem will be solved. To do this, put the following method into your code and call it when you click the button to clear, save or whatever you need to do.
    public void ceaseEditing() {    int row = this.getEditingRow();
      int col = this.getEditingColumn();
      if (row != -1 && col != -1)
        this.getCellEditor(row,col).stopCellEditing(); 
      }Hope this helped...

  • Plz tell me how to use JSpinner with JTable

    I have retrieve records from database but as the number of records(rows) are more than 1000 , i want to use JSpinner with JTable . plz solve my problem by giving the appropriate code for the same.

    hi
    check this links
    http://www.exampledepot.com/egs/javax.swing.table/CustRend.html
    http://java.sun.com/docs/books/tutorial/uiswing/components/table.html
    hope this will help you.. this explains exactly what you want.
    regards
    Aniruddha

  • JComboBox With JTable as Editor

    Hi everybody
    I'm working with JTable and having a ComboBox as first CellEditor. for that purpose i used following code
            cmbFeeType.setModel(new javax.swing.DefaultComboBoxModel(DefaultFee.FeeTypeItemList()));       
            DefaultCellEditor DCEFeeType = new DefaultCellEditor(cmbFeeType);
            DCEFeeType.setClickCountToStart(2);here DefaultFee.FeeTypeItemList is a vector returns array. This is working fine except that the ComboBox remains visible till I dobule clik on a column for editing. Then It becomes invisible and works fine.
    my JComboBox is a seperate Control on a JFrame I do not want to use
    Class FeeTypeEditor extends JComboBox implements TableCellEditoras a ComboBox editor for JTable
    Please Help Me.

    Hi
    I am giving u a sample code which simulate the error
    * TestJTable.java
    * Created on August 5, 2008, 11:05 AM
    package TestJTable;
    import javax.swing.DefaultCellEditor;
    import javax.swing.table.TableColumn;
    * @author  yogi
    public class TestJTable extends javax.swing.JFrame {
        /** Creates new form TestJTable */
        public TestJTable() {
            initComponents();
            DefaultCellEditor ColumnEditor = new DefaultCellEditor(jComboBox1);
            ColumnEditor.setClickCountToStart(2);
            TableColumn column = jTable1.getColumnModel().getColumn(0);
            column.setCellEditor(ColumnEditor);       
        /** This method is called from within the constructor to
         * initialize the form.
         * WARNING: Do NOT modify this code. The content of this method is
         * always regenerated by the Form Editor.
        // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
        private void initComponents() {
            jScrollPane1 = new javax.swing.JScrollPane();
            jTable1 = new javax.swing.JTable();
            jComboBox1 = new javax.swing.JComboBox();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            getContentPane().setLayout(null);
            jTable1.setModel(new javax.swing.table.DefaultTableModel(
                new Object [][] {
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null},
                    {null, null, null, null}
                new String [] {
                    "Title 1", "Title 2", "Title 3", "Title 4"
            jScrollPane1.setViewportView(jTable1);
            getContentPane().add(jScrollPane1);
            jScrollPane1.setBounds(10, 10, 340, 180);
            jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
            getContentPane().add(jComboBox1);
            jComboBox1.setBounds(180, 220, 120, 20);
            pack();
        }// </editor-fold>//GEN-END:initComponents
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    TestJTable TJTable = new TestJTable();
                    TJTable.setExtendedState(MAXIMIZED_BOTH);               
                    TJTable.setVisible(true);
        // Variables declaration - do not modify//GEN-BEGIN:variables
        private javax.swing.JComboBox jComboBox1;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JTable jTable1;
        // End of variables declaration//GEN-END:variables
    }Above code is generated by Netbeans IDE 6.0
    My promblem is that when you run the code the combobox JComboBox1 remains visible till i starts to edit the Table after once started editing it disappears.
    I want to avoid this
    thanks in advance

  • [svn:fx-trunk] 11488: Resubmitting binary distribution of xercesPatch. jar from the third party module in the SDK and compiled it with Sun JDK 1.4 .2_12.

    Revision: 11488
    Author:   [email protected]
    Date:     2009-11-05 17:10:10 -0800 (Thu, 05 Nov 2009)
    Log Message:
    Resubmitting binary distribution of xercesPatch.jar from the third party module in the SDK and compiled it with Sun JDK 1.4.2_12.
    QE notes: N/A
    Doc notes: N/A
    Bugs:
    SDK-16818 - Must open-source the code for xercesPatch.jar.
    Reviewer: Discussed with Gordon
    Tests run: Checkintests
    Is noteworthy for integration: No
    Ticket Links:
        http://bugs.adobe.com/jira/browse/SDK-16818
    Modified Paths:
        flex/sdk/trunk/lib/xercesPatch.jar
        flex/sdk/trunk/modules/thirdparty/xerces-patch/build.xml

    Did you try this:
    http://forum.java.sun.com/thread.jsp?thread=434718&forum=60&message=1964421

  • How can I update Jdev with new JDK

    I currently have JDev323 and I wonder how can I update it with new JDK 1.4.

    What you should do is update the JDeveloper version that you use - 3.2 is sooooo old.
    Get Oracle JDeveloper 9.0.4 and you'll have JDK 1.4 built in.
    I don't remember if that feature was in 3.2 but since JDeveloper 9 you can switch the JDK - it is in the online help - do a search for the word JDK.

  • Back button focusing with the 6D

    I cannot get my 6D's back button focus (AF-ON) to work.  After following directions on Canon's website on how to set it up, the button just does not do anything.  Auto focus only works  with the shutter button.  I have the function set to "P" which I understood to be o.k.  Would resetting the camera to factory default help?  I would prefer not to have to send the camera to Canon for a one button repair.  The camera body was purchased new and is still under warranty.
    Thanks
    Solved!
    Go to Solution.

    It's super easy to set up BBF on a 6D....
    If you have already been changing some things and are unsure which ones, you might want to reset all the Custom Functions to factory default, before starting. (Note: There is a way to view which C.Fns are set and to what each is assigned... As you enter each of the four C.Fn groups, note the list in the lower LH corner of the LCD screen, that shows all the C.Fns in that group at a glance. The top line is the C.Fn number, the bottom line is the setting for each C.Fn.)
    To set up BBF....
    All you have to do is go into the menu, Custom Functions, C.Fn III-5, operations/others, button assignments. Select and enter that and then press "set" and this should take you right to the top of the LH column, which is a graphic illustration of the shutter release button. Press set again to enter this, then scroll to select the center option "start metering" and press "set" once more to select this choice, then press "menu" button several times to back out of the menus. Done!
    What this does is remove AF start from the shutter release button.  By default it's already assigned to the AF-On button on the back of the camera too, so BBF is set up and ready to use as soon as you remove it from the shutter release button.
    Metering and Image Stabilization will continue to start with a half press of the shutter release button or whenever you press the AF-On button. But AF will  only start with your thumb on the AF-On button. Using BBF, you now can use AI Servo most of the time, for stationary or moving subjects. If you want to "focus and recompose", simply focus and then lift your thumb off the AF-On button to leave focus where it is and recompose as you see fit. (Without BBF, you cannot do focus and recompose.... it will cause mis-focused shots.) You still might want to switch back to One Shot when you want high precision focus with stationary subjects.
    There is another option you may want to consider...
    Using the same Custom Function III-5, if you prefer you can swap the functions of the AF-On and * (AE Lock) buttons. I do this on my cameras for a couple reasons: One is that the * button is larger, more prominent, and closer to my thumb... so I prefer to use it for focusing. The other reason is that older Canon models that didn't have the AF-On button, you had to use the * button and that's the way I learned to use BBF (Note: In some cases there was an AF-On button on the body but not on the vertical grip, while older cameras simply didn't have an AF-On button at all, on the body or the grip).
    Alan Myers
    San Jose, Calif., USA
    "Walk softly and carry a big lens."
    GEAR: 5DII, 7D(x2), 50D(x3), some other cameras, various lenses & accessories
    FLICKR & PRINTROOM 

  • -Xmx1024M is working with Jrockit but not with Sun JDK.

    Hi,
    We have a window server box with 8GB RAM. in which there are few other processes running apart from that we have more than 1GB space available.
    We have weblogic 10.3 present in this system. when we try to Run a managed server with JRockit JVM with -Xmx as 1024M -- it is allocating the space properly.
    but when we try the same with Sun JDK , it is failing to allocate memory.
    Please let me know if any one have come across this situaton.

    Maybe you have a large number of DLLs loaded and have insufficient amounts of contiguous free memory for the Sun JVM? Unlike Sun, JRockit does not require a contiguous heap.
    Background:
    http://blogs.oracle.com/jrockit/2008/09/how_to_get_almost_3_gb_heap_on_windows.html
    Edited by: Henrik (JRockit PM) on 2009-sep-15 07:17

  • Weblogic 9.0 on WinXP 64bit with Sun JDK 64bit

    I installed Weblogic 9.0 on WindowXP 64bit version and it's fine with build in Sun's JDK and JRockit JDK but as soon as I switch to Sun's 64bit implementation of JDK (update 5) it fails to start.
    Am I doing something wrong or it is not compatible with 64bit JDK on windows platform?
    If so are there any plans to make it compatible with Sun's JDK 64bit version on windows platform in the near future, or any chance of 64bit JRockit JDK for windows?

    On 07/20/2015 06:35 AM, Itzhak Hovav wrote:
    > hi
    > [snip]
    > [root@p22 eclipse]# cat eclipse.ini -startup
    > plugins/org.eclipse.equinox.launcher_1.3.0.v20120522-1813.jar
    > --launcher.library
    > plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20120913-144807
    >
    > -showsplash
    > org.eclipse.platform
    > --launcher.XXMaxPermSize
    > 256m
    > --launcher.defaultAction
    > openFile
    > -vmargs
    > -Xms40m
    > -Xmx512m
    > [snip]
    Try this: http://wiki.eclipse.org/Eclipse.ini. You should have read the
    sticky posts at forum's top for getting started help.

  • Where can I find a JClient demo with JTable ?

    Hi,
    Where can I find a good JClient demo with JTable and Bc4J?
    Thanks
    Friedhold

    Friedhold,
    there exist a JTable example on otn.oracle.com/products/jdev
    For example ther exists a component binding demo
    http://otn.oracle.com/sample_code/products/jdev/jclient/JClientBindingDemo.zip
    that also shows a table
    and a sorter demo that shows how to sort JTables with JClient
    http://otn.oracle.com/sample_code/products/jdev/jclient/TableSorter.zip
    Finally, a demo that shows how to replace a table cell by a combo box using the table cell renderer
    http://otn.oracle.com/sample_code/products/jdev/jclient/JTableCombo.zip
    Frank

Maybe you are looking for