How can a JTextField in a Dialog gain focus while mainframe is clicked

Hi
I have been trying to develop a 3d application. I have some shapes on a Canvas3D laid on a JFrame.
I open a new shape dialog after pressing the appropriate button.
Once the dialog is open I need to select two shapes on canvas for reference hence there are two text fields to show the name of each.
when I select the first shape the corresponding textfield is being updated.
Now the Problem
I place the cursor in the second tex field and click on second shape on canvas.
I lose focus from text field to canvas.
Now I am unsure if the second textfield has the focus or is the focus with the first text field. Based on this focus info I can update the text fields.
I understand that only one field can have focus at a time.
My doubt is How can the JTextField retain its focus while the components on main window are being clicked.
The following code is enclosed in a listener that responds to picked shapes.
if(gooi.getSketchDialog() != null && gooi.getSketchDialog().isShowing()){
            gooi.getPick1().getCanvas().setFocusable(false);
            if(gooi.getSketchDialog().getSelectedPlaneTextField().isFocusOwner()){
                    if( pickResult != null)
                        gooi.getSketchDialog().getSelectedPlaneTextField().setText(pickResult.getNode(PickResult.SHAPE3D).getUserData().toString());
                    else if (pickResult == null){
                        gooi.getSketchDialog().getSelectedPlaneTextField().setText("");
        }Any help is appreciated.
Thanks in Advance
Venkat
Edited by: pushinglimits on Oct 31, 2008 6:52 AM

Michael
The text field still loses focus when its containing window is no longer focused.import java.awt.FlowLayout;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
public class NoFocusTransfer implements FocusListener {
   public static void main(String[] args) {
      SwingUtilities.invokeLater(new Runnable() {
         @Override
         public void run() {
            new NoFocusTransfer().makeUI();
   public void makeUI() {
      JTextField one = new JTextField(20);
      one.addFocusListener(this);
      JTextField two = new JTextField(20);
      two.addFocusListener(this);
      JFrame frameOne = new JFrame("");
      frameOne.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frameOne.setSize(400, 400);
      frameOne.setLocationRelativeTo(null);
      frameOne.setLayout(new FlowLayout());
      frameOne.add(one);
      frameOne.add(two);
      JButton button = new JButton("Click");
      button.setFocusable(false);
      JFrame frameTwo = new JFrame();
      frameTwo.add(button);
      frameTwo.pack();
      frameTwo.setFocusable(false);
      frameOne.setVisible(true);
      frameTwo.setVisible(true);
   public void focusGained(FocusEvent e) {
      try {
         System.out.println("Focus from: " +
                 e.getOppositeComponent().getClass().getName());
         System.out.println("Focus to: " +
                 e.getComponent().getClass().getName());
      } catch (NullPointerException npe) {
   public void focusLost(FocusEvent e) {
      try {
         System.out.println("Focus from: " +
                 e.getComponent().getClass().getName());
         System.out.println("Focus to: " +
                 e.getOppositeComponent().getClass().getName());
      } catch (NullPointerException npe) {
}db

Similar Messages

  • How can I automatically close a dialog box using Javascript after I click the OK button to submit it?

    How can I automatically close a dialog box using Javascript after I click the OK button to submit it? I don't want to have to X out of the dialog box after I am done.
    Thanks
    Linda

    JS can not interact with open dialogs in any way, unless it's a dialog
    created in JS using the Dialog object.
    On Thu, Jul 24, 2014 at 11:13 PM, lindaeliseruble <[email protected]>

  • How can I rename buttons in dialog popup ?

    Hello.
    I want rename buttons "OK", "Cancel" with my names in popups.
    I create new values in domen WDR_POPUP_BUTTON_KIND
    Next enhance interface IF_WD_WINDOW with new attributes:
    CO_BUTTON_CP type WDR_POPUP_BUTTON_KIND
    But i have problem in CL_WDR_INTERNAL_WINDOW->IF_WD_WINDOW~SET_BUTTON_KIND:
      case me->buttons-button_kind.
        when co_buttons_abortretryignore.
          wa_button-button      = co_button_abort.
          wa_button-button_text = cl_wdr_texts=>get_text( '201' ).
          wa_button-tooltip     = cl_wdr_texts=>get_text( '201' ).
          wa_button-is_enabled  = abap_true.
    This code show only predefined type of buttons can use. 
    How can I rename buttons in dialog popup ?

    When you subscribe to button event  you can rename the button
    * Popup
      DATA lo_window_manager TYPE REF TO if_wd_window_manager.
      DATA lo_api_component  TYPE REF TO if_wd_component.
      DATA lo_window         TYPE REF TO if_wd_window.
      lo_api_component  = wd_comp_controller->wd_get_api( ).
      lo_window_manager = lo_api_component->get_window_manager( ).
      lo_window         = lo_window_manager->create_window(
        window_name          = 'W_POPUP'
        message_display_mode = if_wd_window=>co_msg_display_mode_selected
        button_kind          = if_wd_window=>co_buttons_ok
        message_type         = if_wd_window=>co_msg_type_none
        default_button       = if_wd_window=>co_button_ok
      DATA:  l_api TYPE REF TO if_wd_view_controller.
      l_api = wd_this->wd_get_api( ).
    " subscribe to button event
      lo_window->subscribe_to_button_event(
                   button            = if_wd_window=>co_button_ok
                   BUTTON_TEXT       = u2018Approveu2019 " renaming the button text
                   action_name       = 'ON_OK_POPUP'
                   action_view       = l_api
                   is_default_button = abap_true ).
      lo_window->open( ).
    Radhika

  • How can you watch itunes purchased movies on apple tv. A click on to movies then into purchase thn a click on a movie i want to watch then my apple tv box light starts going on and off plus the screen is blank

    How can you watch itunes purchased movies on apple tv. A click on to movies then into purchase thn a click on a movie i want to watch then my apple tv box light starts going on and off plus the screen is blank

    JasonFromSK wrote:
    With the newest Airport firmware (7.6.1), it seems I should be able to do this.
    Really? I need to check that out!
    You should certainly be able to add content by reference to itunes from such a disk (even before the update) - so long as itunes knows the location of the file (set Preferences not to copy to local library when adding the media) it will stream it to AppleTV if the disk is available.
    I hope you're right, but I'd be surprised if current Extremes can be upgarded to provide a full Home Sharing service - marvellous if they can but I'd be surprised as i've long said we need an Apple media server either based on TC or AE to do this kind of thing.
    AC

  • How can I purchase products from the app store while travelling outside my country of residence?

    How can I purchase products from the app store while travelling outside my country of residence? We are from Canada, travelling in the USA and wish to buy a TV series but get a message to buy it from the Canadian store. When we tried to do this we got the same message.

    According to the terms of sale, you have to be in your country of residence in order to make a purchase. I've heard of people able to make purchases outside their country and also of people being unable to do so. It appears that Apple's enforcement is not 100%.
    In order to buy from the U.S. iTunes Store, you would need to have a valid billing address in the U.S., a credit card billed to that address or an iTunes Gift card purchased in the U.S. and be physically present in the U.S. at the time of purchase.
    International copyright law is currently very inconvenient for the consumer.
    Best of luck.

  • How can i remove secure files from the trash? I tried click away the secure notification in info, but still i cann't remove them. Is there a buttoncombination to use?

    How can i remove secure files from the trash? I tried click away the secure notification in info, but still i cann't remove them. Is there a buttoncombination to use?

    If you are unable to empty the trash, try holding the Option key while selecting Empty Trash.
    Otherwise, some steps in the following link may help you.
    http://support.apple.com/kb/ht1526

  • How can I continue listening to a YouTube video while using another app?

    How can I continue listening to a YouTube video while using another app?

    How can I continue listening to a YouTube video while using another app?

  • In disk utility, below Macintosh HD I have 4 trojan "decryptedFile.dmg (flash player)" and my computer is super slow, does erasing Macintosh HD will also erase these files?  If not how can I erase? (bear in mind computer so slow a click takes forever)

    in disk utility, below Macintosh HD I have 4 trojan "decryptedFile.dmg (flash player)" and my computer is super slow, does erasing Macintosh HD will also erase these files?  If not how can I erase? (bear in mind computer so slow a click takes forever)

    Thank you Thomas in fact I have seen your guide before  and had gone thru the steps including repair disk which didn´t work. I am erasing disk before checking hardware. I have posted a photo of the 4 decrypted files in the disk utility and also of the adobe icons in the dock and question marks. Some people say if the adobe appears in the dock is because it is the trojan flash player and they keep jumping in the dock.  If this is not malware it seems to be an incredible coincidence that when I start seeing these things in my dock and the decrypted files in my disk utility is when my computer goes so slow (I am typing this in my macbook air because to write this message in my imac would be about 6 hours, I am not kidding, it is completely useless at this point it took me 2 and half days too instal mac os x after disk repair, it took me 3 days to transfer just 100 gigabites and now is taking the whole day (and it says another day more) just to erase the disk. Despite all this the icon of adobe keeps jumping in the dock so, although I am no computer and mac expert, just an user, I am inclined to think that it is malware and it is a shame that mac doesnt´recognize it or have anything here to help me get rid of this.  I am not even sure if erasing the disk will work since repairing didn´t work... all advice is welcomed.

  • How can i do this in Captivate 7 "The idea when user click on "Correct answer" button, drag source m

    How can i do this in Captivate 7 "The idea when user click on "Correct answer" button, drag source move to drop target automatically".

    I suppose you are talking about the D&D interaction? Could you explain more? What is your level of expertise with advanced actions and Effects?

  • How can I open MWS (Maple) and WXM (wxMaxima) files directly by click on their links, without necessity to save them on my computer? Thanks in advance.

    How can I open MWS (Maple) and WXM (wxMaxima) files directly by click on their links, without necessity to save them on my computer? The links are present at a htm file.
    In the Internet Explorer it works. Mozilla isn't even able to recognize these applications to enable me to select a regime of their handling.

    hello TurZ, please set media.windows-media-foundation.enabled back to its default value and turn '''media.play-stand-alone''' to '''false '''instead.

  • How can transfer data from a dialog to another panel?

    Will anyone help me?Thanks.
    In our project,When the user need to fill some data into the textfield in a panel,he can simplify this action by click a button,when the button is clicked,then a dialog which contains a table of all the imformation of all customers will show,then the user can select one customer's information from the table,after click a button such as "OK",the selected information will show in corresponding textfiled in another panel.Because the dialog and the panel are two
    different object,so how can I transfer the data selected from the dialog to the panel and show the updated information timely??

    try this program. it exchanges some data between s adialog and a frame.
    akz
    * @version 1.20 01 Sep 1998
    * @author Cay Horstmann
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class DataExchangeTest extends JFrame
    implements ActionListener
    {  public DataExchangeTest()
    {  setTitle("DataExchangeTest");
    setSize(300, 300);
    JMenuBar mbar = new JMenuBar();
    setJMenuBar(mbar);
    JMenu fileMenu = new JMenu("File");
    mbar.add(fileMenu);
    connectItem = new JMenuItem("Connect");
    connectItem.addActionListener(this);
    fileMenu.add(connectItem);
    exitItem = new JMenuItem("Exit");
    exitItem.addActionListener(this);
    fileMenu.add(exitItem);
    public void actionPerformed(ActionEvent evt)
    {  Object source = evt.getSource();
    if (source == connectItem)
    {  ConnectInfo transfer= new ConnectInfo("yourname", "pw");
    if (dialog == null)
    dialog = new ConnectDialog(this);
    if (dialog.showDialog(transfer))
    {  String uname = transfer.username;
    String pwd = transfer.password;
    Container contentPane = getContentPane();
    contentPane.add(new JLabel("username=" + uname + ", password=" + pwd),"South");
    validate();
    else if(source == exitItem)
    System.exit(0);
    public static void main(String[] args)
    {  JFrame f = new DataExchangeTest();
    f.show();
    private ConnectDialog dialog = null;
    private JMenuItem connectItem;
    private JMenuItem exitItem;
    class ConnectInfo
    {  public String username;
    public String password;
    public ConnectInfo(String u, String p)
    { username = u; password = p; }
    class ConnectDialog extends JDialog implements ActionListener
    {  public ConnectDialog(JFrame parent)
    {  super(parent, "Connect", true);
    Container contentPane = getContentPane();
    JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(2, 2));
    p1.add(new JLabel("User name:"));
    p1.add(username = new JTextField(""));
    p1.add(new JLabel("Password:"));
    p1.add(password = new JPasswordField(""));
    contentPane.add("Center", p1);
    Panel p2 = new Panel();
    okButton = addButton(p2, "Ok");
    cancelButton = addButton(p2, "Cancel");
    contentPane.add("South", p2);
    setSize(240, 120);
         //custom method to create and buttons to a container
    JButton addButton(Container c, String name)
    {  JButton button = new JButton(name);
    button.addActionListener(this);
    c.add(button);
    return button;
    public void actionPerformed(ActionEvent evt)
    {  Object source = evt.getSource();
    if(source == okButton)
    {  ok = true;
    setVisible(false);
    else if (source == cancelButton)
    setVisible(false);
    public boolean showDialog(ConnectInfo transfer)
    {  username.setText(transfer.username);
    password.setText(transfer.password);
    ok = false;
    show();
    if (ok)
    {  transfer.username = username.getText();
    transfer.password = password.getText();
    return ok;
    private JTextField username;
    private JTextField password;
    private boolean ok;
    private JButton okButton;
    private JButton cancelButton;

  • How can I install QT without dialogs

    Tell me please, how can I install QT player 7 without dialogs.
    In QT6 use QuickTimeInstaller.ini (no_dialogs=true)
    Thanks for your help
      Windows XP Pro  

    Try using this software. No other downloadable QuickTime version will install on 10.6.
    (58653)

  • How can I disable "download error" dialog box when saving a complete web page?

    Sometimes, when I try to save a web page as type: "Web Page, complete", firefox displays download error dialog box stating a file "could not be saved, because the source file could not be read."
    I don't have a problem with firefox couldn't save that file, but I have a problem with firefox displaying that dialog box, because I have to click OK everytime.
    Is there a way to disable that annoying dialog box?

    I modified the host file mainly to block ads. But that's not the problem. It's OK for me for firefox to not saving some parts of a page (ads usually within a frame). It's my intention to NOT saving those files. I just want to save the main content of a webpage.
    But I'm having a problem with firefox displaying the dialog boxes.

  • How can I process a linearly converted raw file while preserving color?

    Hi,
    I want to convert my raw files in a linear format (to preserve all the dynamic range and detail and prevent unnecessary clipping). My question is "how can I modify the brightness or luminance while preserving the hue and saturation of every color?"
    As for applying the gamma curve, I guess the best and only way in Photoshop is to create a Levels adjustment and place a 2.2 in the middle (gray) input box. However, I read in http://www.luminous-landscape.com/tutorials/hybrid-conversion.shtml that a 4.75 value should be used... Why? Is the number placed there not correspond to the gamma being applied?
    Thanks in advance.
    Juan Dent
    P.S.: getting colorimetrically accurate color from the camera, through all the manipulations in Photoshop is for me crucial. Any pointers as to what to do and what to avoid?

    First of all, you should have used the Adobe DNG Converter 8.6, not an old, obsolete version.  Always use the very latest version.  8.3 was simply the first ACR version to support your camera model, that's all.
    Note that the DNG Converter works only on folders, not on individual raw files.  Put all your Sony raw files in a folder and run the Converter on that folder containing the raw files.
    I have absolutely no clue as to what on Earth you mean by : "upon reading the memory chip from Photoshop CS5".
    You also need to make sure that CS5 is fully updated.  You cannot rely on the highly and notoriously unreliable Adobe auto updater to tell whether you have the latest update installed or not.
    I still have no idea what platform you are on, Mac or Windows. Please read the following for next time:
    BOILERPLATE TEXT:
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them, etc.,
    someone may be able to help you (not necessarily this poster).
    A screen shot could be very helpful too.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • How can I open a .pdf file in a browser on a click on a push button

    I am using oracle 10g developer suit for form designing.
    There is a .pdf file in the application server.
    I want it to open it in a browser when a push button is clicked.
    Could you please tell me how can I do that?
    Regards

    hi
    u can use web.show_document() for that.
    but if you want to open pdf file only then use
    client_host()
    sarah

Maybe you are looking for

  • Error when installing Oracle 9i Database.

    Dear all experts! Today, when Oracle was creating database in the first time, errors occur. It's error: ******ora-01041: internal error. hostdef extension doesn't exist.****** Can you show me the way to correct this problem. I need urgent. Please sen

  • "1 item" and pointed finger inside message box. Is there a fix for this problem?

    When I'm in e-mail, I get a hand with the pointed finger and a message box saying "1 item". The hand and box follow my pointer around the screen but I can't open up any e-mails. The only way out of it is to go up to Hotmail on top, select it and them

  • Need Aperture help

    I am having a problem sending images to recently installed Photoshop 5.  If I export an image to my desktop, I can then open in PS with not problem.  The both work fine independently but not with each other.  I keep getting this error message. Editin

  • Buying Macbook pro with Premiere Pro CS5.5 Help needed DPU?

    I am gearing for film a video production. Buying the macbook pro  and I PP CS 5.5.  Current project I want to use PP CS5.5 rather than FCP. I am new to all this.  All I want to do now is cut and sound edit with some efx matting and titles etc.  Do I

  • Vanishing file on desktop

    I was moving a file (.jpg) on my desktop and it vanished. It's still there if I search for it with Spotlight, but not with Finder. Weird. Can anyone help please? Colin