TAB in JTable works in 1.3 doesnt in 1.4

Hello World!
i wrote an application with a jtable.
now i want to navigate in this table with TAB (from left to right, top down)
and
with ENTER (like TAB).
i created a KeyListener on the table.
i wrote my app in 1.3 and it works well in jre 1.3
now i tested it in jre 1.4 and it doesnt work.
any ideas??
thanks
Sergej

Hi
//it works well JDK1.4.1
JTable table = new JTable(model);
table.addKeyListener(new KeyAdapter()
public void keyPressed(KeyEvent e)
if (e.getKeyCode()==KeyEvent.VK_ENTER)
e.consume();
KeyEvent tabEvent = new KeyEvent(table,e.getID(),
e.getWhen()+1,e.getModifiers(),KeyEvent.VK_TAB,'\t');
table.dispatchEvent(tabEvent);
});

Similar Messages

  • Tab inside JTable (works for any key but tab)

    Hi there
    I have looked on the internet and forums for the answer to how to do this, but I have had no solution.
    I have a JTable and the second column is full of editable cells. The requirement is that when a cell is being edited and tab is pressed, that the editor moves to the next editable cell. (In this case the one below it.)
    I can get the code to work for pressing an arbitrary key (like F11) but for tab I cannot get it to work.
    Any help would be most appreciated.
    Many kind regards,
    Rachel

    Hi Rachel,
    I did this some time ago for a small project. Please note that the code that I'm pasting is a little too specific for your goal, but you'll be able to modify it so that it works.
    public class TableKeyboardAction extends AbstractAction {
          * Constructs a TableKeyboardAction.
         public TableKeyboardAction() {
              super();
         } //end constructor
          * Deals with all keyboard focus movement caused by the TAB, SHIFT+TAB & ENTER keys.
          * @param ae The ActionEvent indicating that either TAB, SHIFT+TAB or ENTER has been
          * pressed.
          * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
         public void actionPerformed(ActionEvent ae) {
              JTable table = (JTable)ae.getSource();
              String ac = ae.getActionCommand();
              boolean tab = ac.equals("\t");
              boolean enter = ac.equals("\n");
              if (tab && (ae.getModifiers() & KeyEvent.SHIFT_MASK) == KeyEvent.SHIFT_MASK) tab = false;
              int row = table.getSelectedRow();
              int col = table.getSelectedColumn();
              //if tab or enter has been pressed
              if (tab || enter) {
                   TableCellEditor tce = table.getCellEditor();
                   //if the first column
                   if (col == 1) {
                        //if the cell is currently being edited
                        if (tce != null) {
                             //if the cell can stop being edited
                             if (tce.stopCellEditing()) {
                                  if (table.isCellEditable(row, col+1)) table.changeSelection(row, col+1, false, false);
                             else {
                                  ((DoubleTableModel)table.getModel()).fireTableDataChanged();
                                  table.changeSelection(row, col, false, false);
                        else {
                             //if tab has been pressed
                             if (tab) {
                                  Double val = (Double)table.getValueAt(row, col);
                                  if (val == null) table.transferFocus();
                                  else if (table.isCellEditable(row, col+1)) table.changeSelection(row, col+1, false, false);
                   else {
                        //if the cell is currently being edited.
                        if (tce != null) {
                             //if the cell can stop being edited
                             if (tce.stopCellEditing()) {
                                  if (row == table.getModel().getRowCount()) table.transferFocus();
                                  else if (table.isCellEditable(row+1, 1)) table.changeSelection(row+1, 1, false, false);
                             else {
                                  ((DoubleTableModel)table.getModel()).fireTableDataChanged();
                                  table.changeSelection(row, col, false, false);
                        else {
                             //if tab has been pressed
                             if (tab) {
                                  if (row == table.getModel().getRowCount()) table.transferFocus();
                                  else if (table.isCellEditable(row+1, 1)) table.changeSelection(row+1, 1, false, false);
              else {
                   //if it is a tab+shift combination
                   TableCellEditor tce = table.getCellEditor();
                   //if first column
                   if (col == 1) {
                        //if the cell is being edited
                        if (tce != null) {
                             //if the cell can stop being edited
                             if (tce.stopCellEditing()) {
                                  //if it's not the first row in the table
                                  if (row != 0) {
                                       if (table.isCellEditable(row-1, col+1))     table.changeSelection(row-1, col+1, false, false);
                             else {
                                  ((DoubleTableModel)table.getModel()).fireTableDataChanged();
                                  table.changeSelection(row, col, false, false);
                        else {
                             //if it's not the first row in the table
                             if (row != 0) {
                                  if (table.isCellEditable(row-1, col+1))     table.changeSelection(row-1, col+1, false, false);
                             else table.transferFocusBackward();
                   else {
                        //if the cell is being edited
                        if (tce != null) {
                             //if the cell can stop being edited
                             if (tce.stopCellEditing()) {
                                  if (table.isCellEditable(row, col-1)) table.changeSelection(row, col-1, false, false);
                             else {
                                  ((DoubleTableModel)table.getModel()).fireTableDataChanged();
                                  table.changeSelection(row, col, false, false);
                        else {
                             if (table.isCellEditable(row, col-1)) table.changeSelection(row, col-1, false, false);
         } //end actionPerformed
    } //end class
    Now use it like so:
    JTable table = new JTable();
    table.getInputMap(JTable.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, 0), "next");
    table.getInputMap(JTable.WHEN_FOCUSED).put(KeyStroke.getKeyStroke(KeyEvent.VK_TAB, KeyEvent.SHIFT_MASK),"next");
    table.getActionMap().put("next", new TableKeyboardAction());Hope it works for you!
    -Muel

  • Middle mosue button don't open a link on a new tab, the button works for scrolling etc.

    Middle mosue button don't open a link on a new tab, the button works for scrolling etc. Thats teh problem, seem like I'm the only with the problem...

    I had the same problem. If you're running Greasemonkey, you need to update it. There's a conflict between Greasemonkey 0.9.10 and Tab Mix Plus on Firefox 6.0.2. Until the add-ons site approves Greasemonkey 0.9.11, you'll have to install it manually.
    [https://addons.mozilla.org/en-US/firefox/addon/greasemonkey/versions/0.9.11 Greasemonkey 0.9.11]
    [http://turbulentsky.com/middle-clickcmdclick-on-a-link-doesnt-open-tabs-in-firefox-6-0-2.html Middle-click/Cmd+click on a Link Doesn’t Open Tabs in Firefox 6.0.2]

  • Just installed on a HP ProBook 450 G0 laptop and the menu, tab etc. dont work, although I do get a www site when I type it in.

    Just installed on a HP ProBook 450 G0 laptop and the menu, tab etc. dont work, although I do get a www site when I type it in. It's very strange, almost like the left click doesnt work on the scratchpad (although it's not that as using keystrokes also fails). OS is Windows7 Pro 64. Tested both Chrome and IE and they work fine.

    Hello scavens,
    Thank you for contacting Mozilla Support. Certain Firefox problems can be solved by performing a ''Clean reinstall''. This means you remove Firefox program files and then reinstall Firefox. Please follow these steps:
    '''Note:''' You might want to print these steps or view them in another browser.
    #Download the latest Desktop version of Firefox from http://www.mozilla.org and save the setup file to your computer.
    #After the download finishes, close all Firefox windows (click Exit from the Firefox or File menu).
    #Delete the Firefox installation folder, which is located in one of these locations, by default:
    #*'''Windows:'''
    #**C:\Program Files\Mozilla Firefox
    #**C:\Program Files (x86)\Mozilla Firefox
    #*'''Mac:''' Delete Firefox from the Applications folder.
    #*'''Linux:''' If you installed Firefox with the distro-based package manager, you should use the same way to uninstall it - see [[Installing Firefox on Linux]]. If you downloaded and installed the binary package from the [http://www.mozilla.org/firefox#desktop Firefox download page], simply remove the folder ''firefox'' in your home directory.
    #Now, go ahead and reinstall Firefox:
    ##Double-click the downloaded installation file and go through the steps of the installation wizard.
    ##Once the wizard is finished, choose to directly open Firefox after clicking the Finish button.
    Please report back to see if this helped you!
    Thank you.

  • Tab into JTable with one tab instead of two?

    Tabbing into a JTable only almost works; the first time you hit tab from the immediately prior component the cursor just disappears, and it takes a second tab to get it into the JTable. I've found out that Swing thinks the focus is in the JTable even after first tab, so JTable is somehow hiding the focus in limbo until you say "no, I _really_ want the focus to be in you", so to speak.
    There's a simple example that replicates this bug here (don't even need to use custom focus traversal, shows up with normal):
    http://java.sun.com/docs/books/tutorial/uiswing/misc/focus.html#customFocusTraversal
    But I couldn't find anything on Google about it. Is there a known workaround for this? I tried tinkering with editCellAt, selectAll etc but no effect.
    Thanks,

    I think the problem is when a JTable is created there is no selected cell, and no current position. Focusable elements remember the latest position the cursor was in; if this does not point to any cell, the table itself will be focused only. At a second Tab the first cell will be focused. Once a cell was selected, the focusing will work as expected for the remainig time of execution, the focus will always return to the last clicked cell, not depending on the selections made.
    Is this what you mean?

  • Safari show all tabs doesn't work all the time

    It is annoying: safari show all tabs doesn't work all the time. The little icon to the right of the "New Tab" area sometimes works, and sometimes doesn't. The Shift Command Back-slash, sometimes works, and sometimes doesn't. I find no rhyme nor reason for this. I have a MacBook Pro, Mountain Lion, the latest updates. It doesn't matter if I am in Full Screen or not.
    I am quite confused regarding this.

    Open the Finder. From the Finder menu bar click Go > Go to Folder
    Type of copy paste the following:
    ~/Library/Caches/com.apple.Safari/Cache.db
    Click Go then move the Cache.db file to the Trash.
    Quit and relaunch Safari to test.
    If that helped, empty the cache more often from your keyboard.
    Command + Option + E

  • The open a new tab doesn't work

    the button named : ''Open a new tab'' toes not work....when i pres it in does nothing....i just upgraded firefox and after that it doesn't work

    That can a problem with the Ask<i></i>.com toolbar (Tools > Add-ons > Extensions)
    See:
    * [[Troubleshooting extensions and themes]]

  • Click on obiee dashboard tabs is not working

    Hi,
    One remote user using cisco vpn to access OBIEE dashboards. everything is all right but when he click on dashboard tabs is not working. I tried with firefox 3.6.0 and IE 8 both have same problem. we dont have this problem within the network. I dont think it's a firewall issue because everything else is working fine. we dont have any custom java script in obiee dashboards. Is it a browser problem? does any one else got this problem before?
    Thanks
    Jay.

    Hi Jay
    Yes Its browser issue. Please make sure the patch updates of IE are updated and i do have the same problem with IE 6 when user remotes (or) use citrix
    One more important point is we have made the dashboards available directly instead of residing in group folder. If you have Dashboards under group folder, give access to that Dashboard directly instead of Group folder
    Eg: Groupfolder A contains A1,A2,A3....A10 dashboards. Give acceess to A1,A2 instead of groupfolder A
    Please mark it Helpful or correct if this solved

  • The option to open a new tab is not working?

    The option to open a new tab is not working?
    I click on the little box but nothing happens?

    Uninstall the Ask toolbar and it should work again. There is a compatibility issue with the Ask toolbar and Firefox that prevents new tabs from being opened.
    There are a couple of places to check for the Ask toolbar:
    * Check the Windows Control panel for the Ask Toolbar - http://about.ask.com/apn/toolbar/docs/default/faq/en/ff/index.html#na4
    * Also check your list of extensions, you may be able to uninstall it from there - https://support.mozilla.com/kb/Uninstalling+add-ons

  • New tab is not working properly as before. if i click on new tab symbol(+),it is not opening.how to make it work?

    new tab is not working properly.ie.,i can not open new tabs in firefox.

    Uninstall the Ask toolbar and it should work again. There is a compatibility issue with the Ask toolbar and Firefox that prevents new tabs from being opened.

  • New tab (+) is not working after upgrading forefox to v 23.0.1

    I had firfox version 22 i guess...Now today morning, I upgraded it to v 23. It displayed a message that one of the plug-in is not compatible with it and so wud be disabled. now later on I again downloaded the plug in to check whether its working or not but neither it worked (as I had already guessed) nor its showing in the add-ons or plug-ins.
    Now I am not getting why the new tab is not working. Not at all. Its so very annoying. I have googled the question and tried resetting firefox and new tab setting in about:config. But nothing helped.
    I think its because of that plug-in as I read somewhere that settings may be getting overridden by one of the faulty add-ons.
    Please help.

    Thanks
    But the problem is still there when I run firefox in safe mode...

  • Select * from tab is not working in oracle 10g

    select * from tab is not working in oracle 10g. But at the same time,
    select * from <<table>> is working.
    Please advise me.

    This works for me in 10.2.0.2
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bit Production
    With the Partitioning, OLAP and Data Mining options
    SQL> select * from tab;
    TNAME                          TABTYPE            CLUSTERID
    LOAN_DETAIL                    TABLE
    PLAN_TABLE                     TABLE
    ...

  • Firefox 12 doesn't load bookmarks in sidebar, home pages don't open, undo closed tab won't work.

    Firefox 11 worked fine. Firefox 12 seemed to install too fast. Now, when opening Firefox, bookmarks don't load in sidebar, even though the top of the sidebar says "bookmarks." Home pages won't load on opening Firefox---only a new tab. Clicking on the little house icon opens the home pages. Display closed tabs icon is dark and Undo closed tabs won't work. Sometimes the toolbar with File, Edit, View etc goes so dark it virtually disappears. I have Vista OS. Reinstalling Firefox 12 didn't help. Is there a fix, or can I go back to Firefox 11?

    Do a clean (re)install and delete the Firefox program folder (C:\Program Files\Mozilla Firefox\).
    Download a fresh Firefox copy and save the file to the desktop.
    *Firefox 12.0.x: http://www.mozilla.org/en-US/firefox/all.html
    Uninstall your current Firefox version, if possible.
    *Do NOT remove personal data when you uninstall your current Firefox version, because all profile folders will be removed and you will also lose your personal data like bookmarks and passwords from profiles of other Firefox versions.
    Remove the Firefox program folder before installing that newly downloaded copy of the Firefox installer.
    *It is important to delete the Firefox program folder to remove all the files and make sure that there are no problems with files that were leftover after uninstalling.
    *http://kb.mozillazine.org/Uninstalling_Firefox
    Your bookmarks and other profile data are stored elsewhere in the Firefox Profile Folder and won't be affected by a reinstall, but make sure that you do not select to remove personal data if you uninstall Firefox.
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    *http://kb.mozillazine.org/Profile_backup
    *http://kb.mozillazine.org/Standard_diagnostic_-_Firefox#Clean_reinstall

  • I recently had my iphone 4s screen repaired because the screen was cracked. It was all ok and then a few weeks later something strange happened. My touchscreen works, but the screen doesnt show, you can see the light in the background but no picture?

    I recently had my iphone 4s screen repaired because the screen was cracked. It was all ok and then a few weeks later something strange happened. My touchscreen works, but the screen doesnt show, you can see the light in the background but no picture? has anyone got any ideas as to what the problem is, is it self-repairable or even repairable at al?

    The LCD Display connector has partially come loose from the logic board connector, and simply needs to be pressed back down into place. Or the front screen assembly is now faulty, and needs to be replaced again.

  • How do I get the tabs to start working after updating Firefox? It wont open new tabs for me now.

    I downloaded the recent update for Firefox and now the new tabs will not work, either by clicking on the "+" symbol or by going to file create a new tab. Ive tried rebooting firefox and have had no luck. Any one else having this issue and know how to fix it?

    If it works in Safe Mode and in normal mode with all extensions (Firefox/Tools > Add-ons > Extensions) disabled then try to find which extension is causing it by enabling one extension at a time until the problem reappears.
    Close and restart Firefox after each change via "Firefox > Exit" (Windows: Firefox/File > Exit; Mac: Firefox > Quit Firefox; Linux: Firefox/File > Quit)
    See also:
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes
    You can find the installation path of all plugins on the <b>about:plugins</b> page.
    *http://kb.mozillazine.org/Issues_related_to_plugins#Identifying_installed_plugins

Maybe you are looking for

  • Works fine in debug but not when published

    So I have simple navigation code setup to step through frames (I'm using Flash instead PowerPoint--too many pictures that are PSDs and illustrations that are AIs to do the conversions over to something PowerPoint understands). The code: stop(); stage

  • Error When trying to load master data 0material

    Hi, I got the following error when trying to laod 0MATERIAL master data "value '000000000004343434 ' for characteristic 0MATERIAL is in external format     " "0MATERIAL : Data record 1 ('000000000004343434 '): Version '000000000004343434 ' is not val

  • HT5699 How do I get back to my account settings in the app store

    How do I get back to my account settings in the app store

  • Delivery Split at 2 levels

    Hi Experts, My requirement is to split SO items into mutiple deliveries. An example as below. Sales Order Item     Material     Qty    Unit 1         A               1       PC 2         B               1       PC 3         C               3       PC

  • Trouble with Sleep

    My macbook won't come out of sleep properly -- if I put it to sleep and try to wake it up, it automatically causes the computer to pop on and then just shut down immediately, then I can't turn on the computer again without holding down the power butt