Using a button and a textfield in the same cell of a table

I have been struggling with this problem for ages, please someone help...
I am trying to implement a table similar to NetBeans property sheet editor where you have a textfield and a button with "..." in the same table cell. The button is used to invoke a custom editor.
I have most things working, custom renderers, custom editors and such.
However, the focus interactions on the table seem completely screwed. Clicking in the editor causes the cell to switch to editing mode as expected. Pressing cursor down or tab, which should close the editor and move focus to the next cell down does not work - the editor closes but the focus disappears to a completely different component elsewhere on my GUI.
My textfield and button are on a JPanel, and I return that JPanel when getTableCellEditorComponent is called.
If I switch out the JPanel and instead return the textfield, the focus works as normal.
I've even looked at the NetBeans source but I can't work out what their trick is.
Any tips would be gratefully received.
TIA.

Thanks for your time, Jeanette...
Here is a bare-bones example of the problem I'm having. I'm running on JDK1.4 and JDK1.3.1_02.
I've tried some tricks (hacks) with getNextFocusableComponent and requestDefautFocus and such but with no success.
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
* This example shows a keyboard/focus navigation problem when using a JPanel
* as a table cell editor. The JPanel contains a textfield and a button.
* Click in the editor to invoke it, and tab-off (or press cursor down). The
* edit ends, but the focus disappears rather than moving to the next cell in
* the table.
* Change the line that returns the panel to return a text field instead, and
* all is well.
public class Test
  public static void main( String[] args )
    new Test();
  public Test()
    JFrame f = new JFrame();
    f.setContentPane( new TablePanel() );
    f.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    f.setSize( 800, 600 );
    f.setVisible( true );
  class TablePanel extends JPanel
    TablePanel()
      setLayout( new BorderLayout() );
      JTable table = new JTable();
      table.setDefaultEditor( Object.class, new MyEditor() );
      table.setModel(
        new DefaultTableModel(
          new Object[][]
            {null, null},
            {null, null},
            {null, null},
            {null, null}
          new String[] { "A", "B" } ) );
      add( table, BorderLayout.CENTER );
  class MyEditor extends AbstractCellEditor implements TableCellEditor
    private JComponent myEditorPanel;
    private JTextField myTextField;
    MyEditor()
      myEditorPanel = new MyEditorPanel();
      myTextField = new JTextField();
    public Object getCellEditorValue()
      return null;
    public Component getTableCellEditorComponent( JTable table, Object value,
                                                  boolean isSelected,
                                                  int row, int column )
      return myEditorPanel;   // Problems...
//      return myTextField;   // Keyboard and focus as expected
  class MyEditorPanel extends JPanel
    JTextField tf;
    MyEditorPanel()
      setLayout( new BorderLayout() );
      tf = new JTextField();
      add( tf, BorderLayout.CENTER );
      add( new JButton( "edit" ), BorderLayout.EAST );

Similar Messages

  • Can I use an iPad and a ipad2 with the same iTunes in my computer? I want to use both

    Can I use an iPad and a ipad2 with the same iTunes in my computer? I want to use both. Want to give one to wife.do I need to open a new iTunes account for her?

    bashepard wrote:
    Can I use an iPad and a ipad2 with the same iTunes in my computer? I want to use both.
    Yes, No problem at all.
    Want to give one to wife.do I need to open a new iTunes account for her?
    No - you can share the same iTunes account (my wife and I share the same account). But when you sync the iPads, just remember to select the correct content for her iPad and the correct content for your iPad.

  • My iPhone 4s will not sync a changed playlist from itunes unless i turn off music match. Shouldn't I be able to use a playlist and music match at the same time?

    my iPhone 4s will not sync a changed playlist from itunes unless i turn off music match. Shouldn't I be able to use a playlist and music match at the same time?

    It's not entirely impossible actually as someone has pointed out to me that I can turn on Call Forwarding and that stops any incoming calls. I've just forwarded it to my google voice number and then turned on "do not disturb" in google voice and whenever I get a call it goes straight to my google voice voicemail and my phone does nothing. The only thing now is I still get text messages but I think the phone calls bugged me more because they would make my music turn off for much longer.
    Even though this isn't a perfect solution it's something so far so maybe you shouldn't just come out and say there's NOTHING I can do because so far I've found part of a solution. If you don't have anyting productive to say then just don't reply and close the tab. Thanks.
    At this point I'm wondering if anyone knows of any Jailbreak tweaks that can enable what I want. Unless of course it's agaisnt the rules of this forum to mention jailbreak stuff...

  • How can i use both Windows and Mac os at the same time on my iMac

    How can i use both Windows and Mac os at the same time on my iMac

    You can use Parallels desktop or VM Fusion to run both operating systems at the same time. Both programs work well, but I personally perfer VM Fusion.

  • How to get 2 web items side by side in the same cell in a table

    Hi All,
    I want 2 radio buttons (in the same cell) in a table to be displayed side by side.  It defaults with a "carriage return" and has one on top of the other.
    How to accomplish this?
    Thanks.

    MC.
    Can you insert a two column one row table within the cell you are referring to? Then pop your radio buttons into each column. Should hold it's format then.
    Regards
    Gill

  • Is there a widget with I can open a text frame with a button and close it with the same botton?

    No lightbox, no rollover.
    Click on the same botton
    I need to use it in mobile version.
    I need add text information on the image of my project in the mobile website version.
    I tried here in the second image but I used 2 button; I can't hide the X button when it's closed. I don't like it.
    http://www.studioarcrea.com/phone/sanit%C3%A0.html

    Howdy,
    Your link doesn't work but perhaps the tooltip widget is what you are looking for?

  • Can i use both windows and OS X in the same hardisk

    I want to install windows 7 ultimate(64 bit) on imac but if i install it can i use both OS X and windows in the same hardisk or do i have to plug in an external hardisk and can i still use OS X or only apple??

    Welcome to Apple Support Communities
    Of course. You can install Windows and OS X in the same hard drive, because that's the purpose of Boot Camp.
    I see you are using OS X Mavericks, so you can install Windows 7 or 8 in Boot Camp > http://support.apple.com/kb/HT5634?viewlocale=en_US Then, follow these steps to install Windows > http://manuals.info.apple.com/MANUALS/1000/MA1636/en_US/boot_camp_install-setup_ 10.8.pdf
    After installing Windows, your Mac will start up in Windows by default. In order to choose in which operating system you want to start up, just hold the Option (Alt) key while your computer is starting up.
    If you do not want to do heavy tasks in Windows, another option you should consider is to install Windows in a virtual machine with the use of an app like VMware Fusion, VirtualBox or Parallels. This way is more secure and there's no risk to harm your Mac.

  • Using internal Speakers and optical Output at the same time ?

    Hello,
    is it now possible to use the internal Speakers and optical Output at the same time ?
    Is this a software or hardware limitation ?
    Every day im disconnecting the optical output. It can't be good for the contacts. I wont spend over 100 euros buying an external soundcard to solve this problem.
    Any Ideas ?
    Thanks ? best regards
    mc
    IMAC 24 Intel   Mac OS X (10.4.8)  

    New Discussions ReponsesThe new system for discussions asks that after you mark your question as Solved. You should take the time to mark any posts that have aided you with the tag and the post that provided your answer with the tag. This not only gives points to the posters, but points anyone searching for answers to similar problems to the proper posts.
    Alternatively, you can change the status to Answered.
    If we use the forums properly they will work well...

  • How to use Forms 5 and DevSuite 10g in the same machine

    Hello everybody,
    I have installed forms 5 and IDS 10g in one machine and both the versions of the forms were working simultaneously. Now I have un-installed both the versions of the forms and re-installed in the same machine. Installation was successful. but I am not able to connect to the database in forms 5. It shows TNS could not resolve service name. TNS is created in both the versions with same name as well as different name. The IDS is working fine. Please help.
    Thanks and regards
    Sukanta sarkar

    Sukanto,
    What error are you getting? One potential problem you will have with more than one version of Oracle Dev Suite installed is keeping the TNSNAMES.ORA synchronized. I've found the easiest solution to this problem is to add the TNS_ADMIN registry key to each Oracle Home so I can share a single copy of the TNSNAMES.ORA file. You can add this entry by starting the Window Registry editor (regedt32.exe or regedit.exe) and navigate to the following registry hive:
    HKEY_LOCAL_MACHINE => SOFTWARE => ORACLE => HOME? (where ? represents the number of the Oracle Home, eg., 0-9).
    In your example, Forms 5 should be in HOME0 and IDS 10g should be in HOME1. Open each home and add a new "String Value" and name it: TNS_ADMIN. After you have added the new String Value entry, edit the String Value and enter the path to the copy of your TNSNAMES.ORA that is working. Then do the same thing with HOME1 and exit the Registry. You should be able to connect to your database with Forms 5 and IDS 10g. Normally, changes to the registry do not require you to reboot your computer, but I have seen where this is necessary - though not very often.
    Note: Always ensure you have a BACKUP of the Windows Registry before you make any changes. If you uncomfortable modifying the Windows Regisitry, then I don't recommend you make this change.
    Hope this helps.
    Craig...

  • Border and font setting for the same cell

    I have writen a label in an excel cell using a font that I created (called "wf" - see code below).
    I also want to put a left thick border to the same cell.
    How can I do that?
    ps: I call this function from "main":
    private static void writeDataSheet(WritableSheet s)
    WritableFont wf = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD);
    WritableCellFormat cf = new WritableCellFormat(wf);
    Label l = new Label(1,0,"Last Name",cf);
    s.addCell(l);
    What code should I add to the upper function in order to set a left thick border to my cell?

    this issue has been solved

  • Can I use my ipod and an iphone on the same itunes library?

    Hi
    I want to buy an iphone but when I asked the sales assistant if I could use my ipod and iphone on the one itunes library she said she thought I should be able to but was not 100% sure. I want to be able to play my music, audio books etc on both.
    Thanks

    Hey deepseablue71
    here is the link "using multiple ipods with one computer" again, just tested, it works for me:
    http://support.apple.com/kb/HT1495?viewlocale=en_US
    How do you use the same itunes library for multipul ipods/iphones? >
    First of all, when it comes to music I create playlists. That makes it more easy to handle on different devices.
    When I plug in my iPhone I select the playlists, video or other data I want to have and sync. Same with my iPods. After that I have similar playlists and data on my iPhone and iPods, even calendar and adressbook are updated.
    Hope this helps,
    Cheers,
    Ingo2711

  • Can I use a usb and wireless keyboard at the same time on a mac pro

    I wish to use the Mac Pro USB keyboard for Logic shortcuts and the Mac Pro wireless keyboard for normal typing etc. Is this possible?

    Just as Matt has said, the Mac uses "all devices active" philosophy with keyboards and pointing devices. It does not automatically Switch to a later-installed device, it uses them ALL at the same time by default.

  • When I try to use TD Webbroker to open my Tax Documents in eServices they will not open and it hangs up my Firefox. I am using windows 7 and if I try the same procedure with Internet Explorer it will work. Any ideas?

    I am using Windows 7 and AVG

    But I can't... find... it... It's not there.
    Unless you're talking about the entire Mozilla Firefox folder (which isn't what the thing you copied says,) there is no installation folder.

  • Using currency conversion and text variable at the same time

    Hi all,
    In a 3.5 bex query, i am applying currency conversion on a key figure with a variable of 0currency.
    as i know, to be able to apply currency conversion, variable of currency should not be in Free characteristics or in Filter.
    it has to be selected only on the key figure.
    but now, i want to use text variable for selected currency (with type replacement path). But as i know, to be able to use text variable, variable of currency has to be
    in Free characteristics or in Filter.
    Can you please advise, how to both use currency conversion and text variable on currency?
    Thanks in advance.
    Sancho

    Sancho,
    I'm not 100% sure about this, but I'm thinking that if you are pulling the text variable from a selection in a structure, you should not need it in the free characteristic or filter. Try creating a structure, placing the currency in it as a selection, and creating a text variable as the title for the selection that is based on the currency. This may help.
    Cheers,
    Rusty

  • Using iphone 3GS and iphone 4 with the same account

    I have an iphone 3GS 32GB and yesterday i bought an iphone 4 32GB. I want to know how can i transfer everything from the "3GS" to "4" without loosing any data from applications i had already stored in "3GS". I also would like to know if it is ok to use the two phones with the same iTunes account and if it is possible to use applications i had purchased for the first phone to the second, or i need to buy the applications again.
    Thank you in advance

    Welcome to the discussions,
    After you set up your new phone, iTunes will ask you if you want to set it up "as new iphone" or restore it from an existing backup, which in your case would be the latest 3GS backup. So you can use this backup to restore all compatible settings and data to your new phone. See what's inside a backup here: http://support.apple.com/kb/HT1766
    You can use more than one device in iTunes with the same account, and iTunes will remember the settings for each of those. Applications can also be used on more than one devices, but you'll have to use the same iTunes account.

Maybe you are looking for