JDialog and request focus

Hi
I am designing an application that brings up a JDialog box. When a button is pressed on this JDialog box this triggers an action event and some code is executed.
When this button is pressed I dispose the dialog box and I want the focus to change to one of my components, I have been doing this with the requestFocus command. For some reason this focused event is not picked up by the focus handler. This only happens in this one place, if I move the requestFocus code to anywhere else in the program the focus event works fine. Does anyone have any ideas why.
Thanks

Without seeing any code, I would guess that disposing of a dialog causes focus changes to be requested internally. So if you put your focus change request after you dispose the dialog, that might help.

Similar Messages

  • Problem with requesting focus for a list

    Hi there !
    What would be the right way to request focus for a list component ?
    I can use select() method to select some item from a list, but the list itself still hasn't got a focus until I click it.
    What I'd like to do is to be able to highlight some item from the list by using up and down arrow keys only, without clicking the list first =)

    The list is visible, but still this doesn't work.
    I think that the reason for this may be that I'm running this app on Nokia 9210 Communicator emulator. The emulator itself has had some not-so-minor problems...

  • Effect of super() in JDialog constructor on focusability/modality

    Hello again,
    this is a JFrame which calls a JDialog which calls a JDialog.
    Using super(...) in the constructor of SecondDialog makes this dialog
    unfocusable as long as FirstDialog is shown. Without super(...) one can freely
    move between the dialogs.
    Can somebody exlain what "super" does to produce this difference?
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class SuperConstructor extends JFrame {
      public SuperConstructor() {
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
        setSize(300,300);
        setTitle("Super constructor");
        Container cp= getContentPane();
        JButton b= new JButton("Show dialog");
        b.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent evt) {
         new FirstDialog(SuperConstructor.this);
        cp.add(b, BorderLayout.SOUTH);
        setVisible(true);
      public static void main(String args[]) {
        EventQueue.invokeLater(new Runnable() {
          public void run() {
         new SuperConstructor();
      class FirstDialog extends JDialog {
        public FirstDialog(final Frame parent) {
          super(parent, "FirstDialog");
          setSize(200,200);
          setLocationRelativeTo(parent);
          setModalityType(Dialog.ModalityType.DOCUMENT_MODAL);
          JButton bNext= new JButton("Show next dialog");
          bNext.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           new SecondDialog(parent, false);
          add(bNext, BorderLayout.SOUTH);
          setVisible(true);
      int i;
      class SecondDialog extends JDialog {
        public SecondDialog(Frame parent, boolean modal) {
          super(parent); // Makes this dialog unfocusable as long as FirstDialog is 
    shown
          setSize(200,200);
          setLocation(300,50);
          setModal(modal);
          setTitle("SecondDialog "+(++i));
          JButton bClose= new JButton("Close");
          bClose.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent evt) {
           dispose();
          add(bClose, BorderLayout.SOUTH);
          setVisible(true);
    }

    nice day,
    there are three areas of get potential problem
    1/ FirstDialog helt pernament MODALITY, SecondDialog to have to same ...
    2/ there isn't something about change Window focus (if Parent inside of EDT, then you alyway lost focus, meaning SecondDialog)
    3/ constructor super inside class doesn't works, block move focus to the SecondDialog (and nonModal)
    ... but
    4/ here is second coins_side [http://forums.sun.com/thread.jspa?messageID=11020377#11020377]
    5/ in this form is my example returns similair result, isn't possible setWindow focus for visible JDialog (sure, remove Extend JDialog and create separate constuctor for JDialog, solve that)
    6/ maybe I'm wrong
    package JDialog;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    * Parent Modal Dialog. When in modal mode, this dialog
    * will block inputs to the "parent Window" but will
    * allow events to other components
    * @see javax.swing.JDialog
    public class PMDialog extends JDialog {
        private static final long serialVersionUID = 1L;
        private boolean modal = false;
        private WindowAdapter parentWindowListener;
        private Window owner;
        private JFrame blockedFrame = new JFrame("No blocked frame");
        private JFrame noBlockedFrame = new JFrame("Blocked Frame");
        public PMDialog() {
            noBlockedFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            noBlockedFrame.getContentPane().add(new JButton(new AbstractAction("Test button") {
                private static final long serialVersionUID = 1L;
                @Override
                public void actionPerformed(ActionEvent evt) {
                    System.out.println("Non blocked button pushed");
                    /*if (blockedFrame.isVisible()) {
                        noBlockedFrame.setVisible(false);
                    } else {
                        blockedFrame.setVisible(true);
                    noBlockedFrame.setVisible(true);
                    blockedFrame.setVisible(true);
            noBlockedFrame.setSize(200, 200);
            noBlockedFrame.setVisible(true);
            blockedFrame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
            blockedFrame.getContentPane().add(new JButton(new AbstractAction("Test Button") {
                private static final long serialVersionUID = 1L;
                @Override
                public void actionPerformed(ActionEvent evt) {
                    final PMDialog pmd = new PMDialog(blockedFrame, "Partial Modal Dialog", true);
                    pmd.setSize(200, 100);
                    pmd.setLocationRelativeTo(blockedFrame);
                    pmd.getContentPane().add(new JButton(new AbstractAction("Test button") {
                        private static final long serialVersionUID = 1L;
                        @Override
                        public void actionPerformed(ActionEvent evt) {
                            System.out.println("Blocked button pushed");
                            pmd.setVisible(false);
                            blockedFrame.setVisible(false);
                            noBlockedFrame.setVisible(true);
                    pmd.setDefaultCloseOperation(PMDialog.DISPOSE_ON_CLOSE);
                    pmd.setVisible(true);
                    System.out.println("Returned from Dialog");
            blockedFrame.setSize(200, 200);
            blockedFrame.setLocation(300, 0);
            blockedFrame.setVisible(false);
        public PMDialog(JDialog parent, String title, boolean isModal) {
            super(parent, title, false);
            initDialog(parent, title, isModal);
        public PMDialog(JFrame parent, String title, boolean isModal) {
            super(parent, title, false);
            initDialog(parent, title, isModal);
        private void initDialog(Window parent, String title, boolean isModal) {
            owner = parent;
            modal = isModal;
            parentWindowListener = new WindowAdapter() {
                @Override
                public void windowActivated(WindowEvent e) {
                    if (isVisible()) {
                        System.out.println("Dialog.getFocusBack()");
                        getFocusBack();
        private void getFocusBack() {
            Toolkit.getDefaultToolkit().beep();
            super.setVisible(false);
            super.pack();
            super.setLocationRelativeTo(owner);
            super.setVisible(true);
            //super.toFront();
        @Override
        public void dispose() {
            owner.setEnabled(true);
            owner.setFocusableWindowState(true);
            super.dispose();
        @Override
        @SuppressWarnings("deprecation")
        public void hide() {
            owner.setEnabled(true);
            owner.setFocusableWindowState(true);
            super.hide();
        @Override
        public void setVisible(boolean visible) {
            boolean blockParent = (visible && modal);
            owner.setEnabled(!blockParent);
            owner.setFocusableWindowState(!blockParent);
            super.setVisible(visible);
            if (blockParent) {
                System.out.println("Adding listener to parent ...");
                owner.addWindowListener(parentWindowListener);
                try {
                    if (SwingUtilities.isEventDispatchThread()) {
                        System.out.println("EventDispatchThread");
                        EventQueue theQueue = getToolkit().getSystemEventQueue();
                        while (isVisible()) {
                            AWTEvent event = theQueue.getNextEvent();
                            Object src = event.getSource();
                            if (event instanceof ActiveEvent) {
                                ((ActiveEvent) event).dispatch();
                            } else if (src instanceof Component) {
                                ((Component) src).dispatchEvent(event);
                    } else {
                        System.out.println("OUTSIDE EventDispatchThread");
                        synchronized (getTreeLock()) {
                            while (isVisible()) {
                                try {
                                    getTreeLock().wait();
                                } catch (InterruptedException e) {
                                    break;
                } catch (Exception ex) {
                    ex.printStackTrace();
                    System.out.println("Error from EDT ... : " + ex);
            } else {
                System.out.println("Removing listener from parent ...");
                owner.removeWindowListener(parentWindowListener);
                owner.setEnabled(true);
                owner.setFocusableWindowState(true);
        @Override
        public void setModal(boolean modal) {
            this.modal = modal;
        public static void main(String args[]) {
            PMDialog pMDialog = new PMDialog();
    }

  • Requesting focus for JTextField inside JPanel

    I have an application with following containment hierarchy.
    JFrame --> JSplitPane --> JPanel.
    JPanel is itself a seperate class in a seperate file. I want to give focus to one of the JTextfields in JPanel, when the JPanel is intially loaded in the JFrame. I believe that I cannot request focus until the JPanel is constructed. I can set the focus from JFrame (which loads JPanel) but I want to do this from JPanel. Is there any technique to request focus from the JPanel itself (preferably during JPanel construction).
    regards,
    Nirvan.

    I believe that I cannot request focus until the JPanel is constructedYou can't request focus until the frame containing the panel is visible. You can use a WindowListener and handle the windowOpened event.

  • Request focus for message area

    Dear All,
    As my screen is long hence if an error comes we will require to scroll down so I have added a message area UI element and in do modify method of the view i have request focus to my message area but it is not working.  Below is the code which I have written:
    try{
              IWDMessageArea msgarea=(MessageArea)view.getElement("MessageArea");
            msgarea.requestFocus();
            catch(Exception e)
    Is there any other property or changes need to be made.
    Thankyou.
    Regards,
    Santosh

    Hi,
    In would say, create an input field at the top left corner of the screen. Set its width to zero and bind it to a context attribute say Va_ShowMesg of type string. Now insert a MessageArea UI element just below the inputfield to display all the erro message at the top left.
    Now if you request focus for the input field using the following code, the focus will automatically come to the Message Area as well.
    wdThis.wdGetAPI().requestFocus(wdContext.currentContextElement(),wdContext.getNodeInfo().getAttribute(
              wdContext.currentContextElement().VA__SHOW_MESG));
    You can call this code whenever you need to display message to user in the message area and shift focus of the screen to the message displayed.
    Regards,
    Tushar Sinha

  • Problem with JDialogs and Threads

    Hi. I'm new to this forum and I hope I'm not asking a repeat question. I didn't find what I needed after a quick search of existing topics.
    I have this problem with creating a new JDialog from within a thread. I have a class which extends JDialog and within it I'm running a thread which calls up another JDialog. My problem is that the JDialog created by the Thread does not seem to function. Everything is unclickable except for the buttons in the titlebar. Is there something that I'm missing out on?

    yeah, bad idea, don't do that.

  • Something keeps trying to download on my mac and I don't know what it is. It is not in the apple store and just comes out nowhere and request for my password to download something and I don't know what it is. How to make this stop?

    Something keeps trying to download on my mac and I don't know what it is. It is not in the apple store and just comes out nowhere and request for my password to download something and I don't know what it is. How to make this stop? It pops up every single day.

    Erica,
         I can, with 99.99% certainty, tell you that you are absolutely right in not wanting to download or install this "Helper," whatever it is (but we can be equally certain it would not "help" anything).
         I cannot comment as to Oglethorpe's recommendation of 'adwaremedic'; I am unfamiliar with it.  His links to the Apple discussion and support pages warrant your time and attention.
         It might be really simple -- Trying looking in your Downloads folder, trash anything that you don't know with certainty is something you want to keep, and then Secure Empty your Trash. Then remove the AdBlock extension, LastPass, and Web of Trust extensions to Safari and re-boot. If the issue goes away, still be extraordinarily careful in the future.
         Unfortunately, it's probably not going to be that simple to get rid of, in which case I'd then try the line by line editing in HT203987. 
         I have no further suggestions (other than a complete wipe and re-install...but that's a pain because trying to restore from Time Machine would simply ... restore the Mal).
       For the rest of us, please post when you find a solution.
         Best.
         BPW
      (Also, try to edit your second post -- black out your last name on the screenshot and re-post it for others)

  • A report for 'Responsible CCtr' and 'Requesting CCtr' in Internal Orders

    Hi All,
    displaing the master data of an Internal Order, in the tab 'assignment' I can see the fields 'Responsible CCtr'
    and 'Requesting CCtr'.
    I wonder, is ther a report in which these field are recalled?
    Thanks

    Hi,
    T-code KOK5.
    Define a sel. variant, run KOK4 with this variant to create an order group, view this order group in KOK5 and in the layout choose the fields you need.
    best regards, Christian

  • Difference between booked items and requested items

    Hi Gurus,
    I wanted to understand the difference between
    Booking History - booked items – booked date
    Booking History – requested items –booked date
    The Series definition has the same definition given in the hint. I checked one of the below links for the same topic but couldn't get a full view.
    Which series go to Actual_quantity in Standrad collections
    Can any one let me know what the difference between booked items and requested items is? As I understand in OM, we have no differentiation. Do let me know
    Thanks
    DNP

    Hi
    In normal circumstances, there is no difference between requested item vs. booked item. But if you're using Item Substitution, these could be different. For example, a customer may call to request item A but for multiple reasons it may be substituted by a different item (usually an upgrade with similar form, function etc).
    Oracle APS supports this functionality out of box in order promising and ASCP where it can be done based on a pre-defined relationship based on availability etc.
    Hope this answers your question, please feel free to let me know if I may help calrify further
    Navneet Goel
    Inspirage
    [email protected]

  • Do you have an option for block all incoming message and request EXCEPTED messages from my contacts?

    Please help!!To whom it may concernDear Madam/Sir who works for Skype & Microsoft  Dear all who can really help,  Do you have an option for block all incoming message and request EXCEPTED messages from my contacts? or Do you have any solution to solve my problem from begin to now in present time?  Even though, I set the Privacy settings: - Allow calls from... "people in my Contact list only"- Automatically received video and share screens with "people in my Contact list only"- Allow IMs from "people in my Contact list only"  I still received unknow users sent me messages in every day, contact requests etc. And they're all clearly spammings and identity thefts.  I only wanna contact with my family and my freinds here with Skype via my Windows device and my mobile phone (w/Android OS).  And this is the only way to contact with them, because they could use Skype only in overseas.  BUT I don't need new friend from other unknow Skype member.   I keep blocked all unknow spammers in every day.  However in this morning, I feel so scared with Skype on my mobile, I looked at my mobile Skype, I saw it automatically showed me the list of all blocked members. BUT they were all unblocked (contact unblocked) by my mobile (Android version) Skype itself automatically, and listed them one by one on the screen, and about 30 seconds later, they all were disappeared suddenly.  I don't know what do to now, is it indicating my account was hacked?And how could I found out all those members again and block them again and delete all of them for ever?  I appreciate if you would improve the privacy protection. Thank you very very very much. 

    Hrm... that may be true and this may be a function of the phone email client that Apple just doesn't do.
    No, I can easily MANUALLY delete the messages. I would prefer if I didn't have to do it twice, tho. Once on the mail server and once on the phone.
    What I think the phone needs to do is, when it checks the POP, anything NOT there should be removed locally. I think you are correct on POP; the phone will poll the mx (mail exchanger) and the mx will pass off the messages to the phone. The phone then keeps ALL of that unitl you manually delete it.
    If, say, I remove a message from the mx, I would like the phone, when next polls, to see that that particular message isn't on the server anymore and remove it locally.
    Perhaps it's just me but if I delete the message on the mx itself, via my ISP's webmail interface, I really don't want to have to remove it again from my phone.
    thxs!
    cheers
    rOot

  • I have purchased a in app purchase of a 'gcsepod' for my little brother however the purchase does not come up in the app and requests me to buy another. How do i solve this? I have also got the receipt for this purchase.

    i have purchased a in app purchase of a 'gcsepod' for my little brother however the purchase does not come up in the app and requests me to buy another. How do i solve this? I have also got the receipt for this purchase.

    I'm not sure I can make sense of this but without asking too many questions, you can resolve your question by contacting iTunes direct.
    Apple - Support - iTunes - Contact Us
    But they will be wondering about the reference to hacking and you feeling bad about getting something for free.
    Best step in my view is to make sure you don't get similarly involved in future.  You must know roughly what you were doing.   Then writie it off to a not to be repeated experience.

  • Creation of new package and request number.

    Hi frndz,
    Hope everyone are doing fine. Coming to my query, its quite simple for you guys.
    But me being new to BW, I would like to know how to create a new package and request number.
    And I have a task to create a new IS and DS also. So do i need to create these new package and request number separately or at the time of creation of IS and DS.
    Please give me clear idea.
    Thanking you.
    regards
    Dubbu

    Hi Vinay,
                   I hope you are speaking about Package to collect Objects and collecting them in Transport Requests.
    Usually you use the same packages for all the objects. According to requirement if you want to create the Package you can goto SE80--> There you can create a New Package. Give Transport layer as SAP. and Activate it. Then you collect the package in a Transport Request. You can create the request by the create button on the screen when it ask for Transport Request.
    While creating the Infosource or other objects you mention the package which you have created while saving and you can use the existing TR or new TR for collecting them.
    You can use RSA1---> Transport Connection to collect the objects easily to TR's
    Regards
    Karthik

  • Every time my IMAC is unused for a period, then goes to sleep mode, it loses it's wireless connection and when I wake it up, it DOES NOT automatically reconnect. I have to go to systme preferences network and request that it reconnect.

    My iMac is set up wireless.  Everytime it's allowed to go in sleep mode, it loses wireless connectivity.  Then, when I wake it up,  I must go to System preferences,  Network,  and request it to reconnect to my home wireless network.   It always does this successfully, but it's quite annoying that it seems unable to achieve this on it's own.  My iPad 2 and kindle can do this,  why not my iMac?

    This appears to be a known issue, there are a couple of things both of you should do, first file a bug report in www.apple.com/feedback.
    The next thing is more a work around than a fix. Instead of putting your computer to sleep just put the display to sleep. You will find this in System Preferences - Energy Saver. Set the computer sleep to Never and then set the display sleep to what ever time you prefer.

  • How can I get the No. of package and requesting system name in user exit?

    Dear all,
    Is there anybody knowing how to obtain the extracting package number and requesting system name in the user exit "EXIT_SAPLRSAP_002" ? here is detail on my questions as below:
    For package number. If extracting 100,000 records of 0MATERIAL_TEXT , and the package size is 20,000, then there are 10 packages, when executing the user exit, how can I know which package I am extracting on?
    For requesting name, when executing the user exit, how can I know the logical system name from which the extraction request is sent?
    Thanks.
    best regards
    Patrick

    Hi Mansi,
    Thanks for your quick response.
    The background of this requirement is, in the datasource 0material_Plant_Att, we added two fields in the extraction structure, one is variable price, another is previous year's variable price, which need to be obtained by searching data KEKO & CKIS in the user exit, these tables have the huge data volume, in each data package, the user exit needs to be executed once, so the heavy searching needs to be done once, consequently, the total running time of this request including several data packages is very long. In order to improve the performance, we design the following logic:
    1. Create the temporary tables YCKIS & YKEKO in R/3.
    2. Run BW request in BIW.
    3. In R/3, If this is first data package of this request, delete all data in YCKIS & YKEKO, then search the data from CKIS & KEKO ( Average 20 million records), then insert these data into YCKIS & YKEKO ( Average 0.2 million records). 
    4. In R/3, if this is not first data package of this request, then search the data directly from YCKIS & YKEKO.
    You can see in the above, in the step 4, the data searching performance can be improved significantly due to reading data from temporary table, this is why I need to know the No. of data package. In addition, apparently, it can not be done in BIW side since the performance issue is in the user exit rather than in BIW. Also it is very difficult to setup one counter to deliver this since we do not know when to reset the counter. For example,
    - Assuming there are 3 data packages.
    - 1st day, we schedule one request from BIW, in R/3,
       -> At 1st package, counter = 0+1=1
       -> At  2nd package, counter =1+1= 2.
       -> At 3rd package, counter = 2+1= 3, then reset counter = 0 for next request.
    Question 1:  How can we know the 3rd package is last one?
    Question 2: If during the 2nd package, the extraction job is cancelled exceptionally, the counter value is 2 not 0, then for the next request, the data searching is not correct, right.
    Hope the above is clear, and apology this email is too long.
    Thanks.
    best regards
    Patrick

  • 508 accessibility and keyboard focus

    I'm using Captivate 4 and can't seem to get the keyboard accessibility to work properly. I want to be able to control the tab order and keyboard focus on each slide. For example, if the user keeps pressing tab they will eventually move from the .swf file and begin reading the address and menu bar in the browser window. Does anyone know how to ensure that the keyboard focus is provided only to active elements?

    Hi,
    I noticed your post while searching for the same answer with respect to Captivate 5.  So far, it is the closest I've seen to the problem I'm trying to resolve.  I see that you had no luck here, but was wondering if you found a solution elsewhere.  All help would be appreciated.

Maybe you are looking for