Forcing JFrame to lose its focus programatically

Hello everyone,
I have a JFrame with a button over it. Now I wants that when I click on the button,
my JFrame should lose its focus.
Can anybody tell me whether it is possible in java or not?
Thanks in advance.

It depends upon the underlying OS
On Windows XP it goes to the last application which was in focus.
For eg- If I first open up a notepad and after that my java application the once my application loses its focus it should go to notepad.
But i think that will be handled by the OS itself because when you minimizes an application then the application which had the focus before this one will automatically get the focus.

Similar Messages

  • Forcing ComboBox to lose its focus when isPopupVisible()==false

    Hi,
    I'm in a situation where I need to force my comboBox to lose its focus, in a case when user clicks the comboBox to pull down the popup but does not click any value inside the comboBox popup. In such a situation I need to force the comboBox to lose its focus.
    I looked for some method like setFocus in comboBox api, but did not find anything such.
    appreciated..

    import javax.swing.*;
    import javax.swing.table.*;
    public class JTableComboSSCCE extends javax.swing.JFrame {
        JTable table;
        DefaultTableModel model;
        public JTableComboSSCCE() {
            initComponents();
            createTable();
        public void createTable() {
            model = new DefaultTableModel();
            model.addColumn("Name");
            model.addRow(new Object[]{"Julia"});
            model.addRow(new Object[]{"Sara"});
            model.addRow(new Object[]{"David"});
            model.addRow(new Object[]{"Mauricio"});
            model.addRow(new Object[]{"Tina"});
            table = new JTable(model);
            scrollPane.setViewportView(table);
            TableColumn firstColumn = table.getColumnModel().getColumn(0);
            JComboBox comboBox = new JComboBox();
            comboBox.addItem("Snowboarding");
            comboBox.addItem("Teaching high school");
            comboBox.addItem("None");
            firstColumn.setCellEditor(new DefaultCellEditor(comboBox));
        void updateTable() {
            model.removeRow(4);
        private void initComponents() {
            scrollPane = new javax.swing.JScrollPane();
            jButton1 = new javax.swing.JButton();
            jLabel1 = new javax.swing.JLabel();
            jLabel2 = new javax.swing.JLabel();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosed(java.awt.event.WindowEvent evt) {
                    formWindowClosed(evt);
            jButton1.setText("Update Table");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    jButton1ActionPerformed(evt);
            jLabel1.setText("1- Click the last row, but do not pick any value, then click outside the table");
            jLabel2.setText("2- Click Update Table button, then click any row to edit cell");
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 670, Short.MAX_VALUE)
                .addGroup(layout.createSequentialGroup()
                    .addGap(21, 21, 21)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 469, Short.MAX_VALUE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 52, Short.MAX_VALUE)
                    .addComponent(jButton1)
                    .addGap(29, 29, 29))
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(24, 24, 24)
                            .addComponent(jButton1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                            .addContainerGap(37, Short.MAX_VALUE)
                            .addComponent(jLabel1)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addComponent(jLabel2)
                    .addGap(15, 15, 15)
                    .addComponent(scrollPane, javax.swing.GroupLayout.PREFERRED_SIZE, 214, javax.swing.GroupLayout.PREFERRED_SIZE))
            pack();
        private void formWindowClosed(java.awt.event.WindowEvent evt) {
            this.dispose();
        private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
            updateTable();
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new JTableComboSSCCE().setVisible(true);
        private javax.swing.JButton jButton1;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JScrollPane scrollPane;
    }

  • UIX LOV loses modal focus

    Hi,
    I have written a LOV in UIX and call it with MarlinCore.js' openWindow function. It works fine. But... When it starts up it has "modal focus". I cannot set the focus back to the calling window, as expected. However when I refresh the LOV, or in fact submit any request from it (such as pressing a "query" button, wich would be quite basic functionality for a LOV), it loses the modal focus, meaning that the calling window can be made active while the LOV window is still visible. Has anybody got a working LOV that keeps its focus, even after firing requests from the LOV?
    I have noted that when I create a LOV with a faulty url and my webserver opens a LOV window and serves some 404-page I have defined in web.xml to it, this window will indeed keep its focus, even after a refresh. Very strange indeed.
    Am I missing some fundamental javascript knowledge here? Are
    Pls help.
    -Martijn

    Adam,
    Not really sure I understand your post, but in answer to your question, this is how I raise the LOV:
    From uix page:
      <image source="../images/lov.gif"
             onClick="javascript:   openWindow(top,
                                              ,'<someUrl>
                                              ,'lovWindow'
                                              ,{width:600,height:600}
                                              ,true
                                              ,'dialog'
             />As I wrote in an earlier post, the lov uix code reads:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <document xmlns="http://xmlns.oracle.com/uix/ui"
              xmlns:data="http://xmlns.oracle.com/uix/ui"
              xmlns:html="http://www.w3.org/TR/REC-html40"
              xmlns:cqj2ee="http://xmlns.cumquatit.com/uix/ui">
      <metaContainer>
        <head title="SomeTitle" >
          <contents>
            <script data:source="JS_LIB@cqj2ee:appInfo"/>
          </contents>
        </head>
      </metaContainer>
    <contents>
      <dataScope>
        <contents>
          <!-- IMPORTANT: DO NOT INCLUDE A BODY TAG HERE. THIS WILL LEAD TO MODALLES LOVs!
        Long postings are being truncated to ~1 kB at this time.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Firefox frequently loses window focus

    It seems that Firefox frequently loses window focus when I open a new page. It may be a bookmark, a link opened into a new tab via CTRL+Left-Click, or whatever. The following scenario always results in the window losing focus (for me).
    # Open Firefox.
    # [http://www.foxnews.com Open this link and bookmark it].
    # Close and reopen Firefox.
    # Open the page just bookmarked using the bookmark list and don't touch the window.
    I read this page daily, so when I start Firefox and open the page, I have to click in it so as to scroll, etc..
    Firefox 13, Windows 7 Home Premium 64-bit
    I wish this site had "Preview" for its posts. Geez Louise.

    Oh please fix this ******* issue, it is driving me mad.
    ''Edited by a moderator due to language. See the [http://support.mozilla.com/kb/Forum+and+chat+rules+and+guidelines Rules & Guidelines] .''

  • Camera Raw loses system focus and becomes inactive

    While working in ACR if I hover over any of the command buttons, Save Image,  Open Image, Cancel, or Done for a few seconds the "tool tip" for the button displays and as soon as I move the mouse again the whole Camera Raw windows loses system focus and becomes inactive (every tab, control, menu, etc., becomes greyed out).  To regain the system focus I must move the mouse to the windows 7 taskbar and then back into Camera Raw.  If the fullscreen checkbox in Camera Raw is active the only way to regain system focus is to press the Windows Key twice on the keyboard and move the mouse out of the taskbar tray.  This gets pretty frustrating.  Any clues?

    It doesn't normally do this, I can assure you.  Normally the tooltips just pop up and Camera Raw stays active.
    Do you have any desktop management software installed, besides what Windows provides?
    Are your video drivers up to date?
    -Noel

  • Lose of focus (mouse click/enter key)

    Hello,
    we have a problem customers are complaining about for quite a while now, but despite our efforts, we can not fix it or at least determine with certainty the problem cause.
    We have an application launching forms apps, and from time-to-time we completely lose the focus on this form (generally after typing ENTER in a filter), I mean by focus, we cannot click anymore (cursor seems to stay on a object), we cannot press enter anymore (we get a 'Not defined key function') and so on...
    I heard somewhere that it could be due to 'KEY-OTHERS' trigger not handling correctly the ENTER-KEY. But I need this trigger for my filters, or is there another way? KEY_ENTER does only navigate from field to another.
    I found something which was able to remove focus lost (kind of a hack while trying to fix this on an on), but the problem is I had to remove this, because it blocks the opening of new windows or popups. It was a mouse-click trigger on forms triggers level:
    Go_Record(:System.Mouse_record);
    Go_Item(:System.Mouse_Item);
    But this blocks any window opening, and it also blocks some other tools we have developed.
    Thanks,
    Best regards,
    G.
    EDIT: Forms 11g, and I am pretty sure we had not that much problems with 10g
    EDIT2: I read the same kind of topics in the forum, but no patch seems to help
    AND we use JRE 1.7....
    Edited by: lakers on Jan 14, 2013 11:56 PM
    Edited by: lakers on Jan 14, 2013 11:59 PM

    this problem occurs with some of versions of JRE. Try with JRE JInitiator 1.3.1.22. Also unstalled all others JRE if exists.
    A file called fmrpcweb.res has also been provided which gives the Microsoft Windows client/server keyboard mappings. To use this file, rename fmrpcweb.res to fmrweb_orig.res, and copy fmrpcweb.res to fmrweb.res. Alternatively, use the term parameter as described above.
    By default, whether deploying client/server or over the Web pressing the ENTER key takes the cursor to the next navigable item in the block. To override this default behavior it is necessary to modify the forms resource file to revise the key mapping details.
    Modify fmrweb.res and change the Forms Function Number (FFN) from 27 to 75 for the Return Key. The line should be changed to the following:
    10 : 0 : "Return" : 75 : "Return"
    By default, the line is displayed with an FFN of 27 and looks as follows:
    10 : 0 : "Return" : 27 : "Return"
    This line should NOT fire the Key-Enter trigger since the Return or Enter key is actually returning the Return function represented by the FFN of 27. The FFN of 75 represents the Enter function and fires the Key-Enter trigger.
    http://docs.oracle.com/cd/E24269_01/doc.11120/e24477/configure.htm#i1077054
    please mark correct/helpful if problem is solved..
    Edited by: Askdineshsinghminhas on Jan 15, 2013 5:28 AM

  • When placing a png in indesign the png changes/loses its orginal color.

    When placing a png in indesign the png changes/loses its original color. Ex. the very clear blue that I am using turns dark and "dirty". ( my RGB is : 5,125, 255  -  when I type this I get a " out of gamut warning" a little yellow icon. When I click on it indesign automatically changes the RGB into: 67, 117, 187)
    I have worked with indesign for 6 years and never experienced this before. I am guessing it has something to due with that the png is in RGB and indesign in cmyk, but I have no idea what to do about it?

    Out of Gamut means the color cannot be printed in your current workspaces using CMYK inks. You would see a preview of the converted color if you move into Overprint Preview, use Proof Colors, or there is transparency and the blend space is set to CMYK.
    If this is destined for screen use, then the color doesn't matter, but you should be sure the blend space is set to RGB.

  • Apple Mail 5.3 seems to corrupt/lose its place in message id sequence numbers

    OS/X 10.7/Apple mail 5.3 seems to corrupt (or at least lose its place in) the message id sequence number. Two days ago, around 2:0x mail stopped fetching email from a pop server that I own (all installed through WHM and CPanel at WestHost).  This happened again today sometime around 2:0y.
    Logging into webmail showed a number of emails pending.  Bouncing mail or restarting OS/X yielded no joy.
    When I delete the email account in Mail->Preferences->Accounts and then recreate it, it fetches all the mail as expected.
    Any ideas on how to figure out what is going on?
    Note that CPanel did undergo a big upgrade to 11.34 on Tuesday, so my initial thought was that was culprit, but since delete/recreate of the mail account fixes, I am not so sure.
    thanks in advance,
    Mike.

    Forgot to add, no one else using this pop server reported any problems (and I checked).
    Mike.

  • Applet looses its focus in IE

    Hello, all!
    I working with applet that will be used as a simple code editor with highlighting of different programming languages.
    This applet based on JTextPane wrapped in JScroll pane. When I test this applet with java applet viewer - all works fine, but now I embedded my applet into html page and try to test it in "live" conditions using IE browser.
    When I press TAB key inside of JTextPane the appled looses its focus instead of simply insert an indent as it should be.
    Interesting, that this problem reproduces only under IE (in Firefox it works properly).
    Maybe someone knows how to workaround this problem?
    I'll be very thankfull for answers!
    With best regards,
    Andrew.

    Thanks for all who participated in resolving of my problem. It's eventually has been resolved by myself.
    The solution was very complicated and looks like unskilful workaround, but it was one, which really helped.
    So now I just want to describe it, maybe someone else will faced the similar problem.
    First I added to main class of applet following public method (for manual handling of tab key):
    public void handleTab() throws Exception{
         textPane.grabFocus();
         Document doc = textPane.getDocument();
         doc.insertString(textPane.getCaretPosition(), "\t", null);
         textPane.setCaretPosition(textPane.getCaretPosition() + 1);
    }After that I simply can invoke this method from JScript. So my wrapping page can be like this:
    <HTML>
    <HEAD>
    <BODY>
    <APPLET CODEBASE="." ARCHIVE="editor.jar" CODE="editor.applet.EditorApplet.class" NAME="editor" WIDTH="640" HEIGHT="480" MAYSCRIPT >
    </APPLET>
    <INPUT name="stub1" type=text onfocus="editor.handleTab();" style="position:absolute; top:100; left:100;">
    <INPUT name="stub2" type=text onfocus="stub1.focus();" style="position:absolute; top:150; left:100;">
    </BODY>
    </HTML>I know, this looks little bit strange, so let me clearify some details and aspects of IE behavior.
    - When I press TAB, focus goes to "stub1" input box, which invokes 'editor.handleTab' immediately. But inspite of focus was grabbeg back by applet (invoking textPane.grabFocus()), it is ALSO REMAIS IN BROWSER in inputbox. So when I press TAB again, focus moves not to "stub1" again, but to the next flow control "stub2". So in this case "stub2" must return the focus to "stub1". It is like chain reaction ;-)
    - both input box stubs has an absolute positioning and simply hidden under the applet, so all these manipulations are invisible for end-user of applet and looks like 100%-natural behavior of any editable text area.

  • Urgent! DHCP service stop, server lose its IP...

    Hi all,
    I have a serious problem:
    My Macmini Server (late 2010) firstly suddened stop lease IPs event I restart Macmini, restart DHCP service... OK, I set clients (Mac, window) to use static IP, its work for a day and now the server even lose its IP. It is mean I can not ping to server, cannot have Internet, can not share file... just a nice, deadly box!
    At home I can still use SSH to connect to that server and when I use ipconfig:
    server-001:~ Xadmin$ ipconfig getifaddr en2
    get if addr en2 failed, (os/kern) failure
    server-001:~ Xadmin$ ipconfig getifaddr en0
    10.0.0.10
    server-001:~ Xadmin$ ipconfig getoption en0 2
    ipconfig_get_option failed, (os/kern) failure
    server-001:~ Xadmin$ ipconfig getoption en2 2
    ipconfig_get_option failed, (os/kern) failure
    server-001:~ Xadmin$ ipconfig getoption en2 3
    ipconfig_get_option failed, (os/kern) failure
    server-001:~ Xadmin$ ifconfig en2
    en2: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
              ether 10:9a:ad:41:c6:10
              media: autoselect (none)
              status: inactive
    server-001:~ vidagisadmin$ ifconfig en0
    en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
              ether c4:1c:03:4a:eb:d4
              inet6 fe80::c12c:1ff:fe3a:ebd4%en0 prefixlen 64 scopeid 0x8
              inet 10.0.0.10 netmask 0xffffff00 broadcast 10.0.0.255
              media: autoselect (100baseTX <full-duplex>)
              status: active
    Do you have this before?
    How can I active the en2 network interface?
    Any clue is very appriciate and this is very URGENT!!!!!
    Thanks for your time!
    Please note that:
    - I use Macmini server as a gateway, and use an USBEthernet (en2) to sharering that internet connection.
    - hostname appear is OK when I check it through ssh
    Please help!!!

    Hi Esther, I use DHCP for server.
    Actually I found that we have problem with the network cable only! Anyway thanks!
    If this forum have a moderator I hope, please delete this discussion, thanks!

  • HP widget loses its configuration and I can't set it bagk for my c7280

    HP widget loses its configuration and I can't set it bagk for my c7280

    if it keeps asking for the password again just write "0000", add the controller to your favorites, close bluetooth before asked for a password again, and the open bluetooth again

  • Photoshop CC is creating problematic JPEGs that make OSX Preview.app lose its mind

    I have a 2013 Retina MBP on Yosemite, with a licensed copy of Photoshop CC. My problem is, Preview cannot deal with JPEGs I am creating in Photoshop. Preview is really sluggish when it loads the images, and is unable to resize them. It appears to do so, but when the image is saved and closed, the resolution is not modified correctly and the file size stays oddly large.
    Here is one such image: https://drive.google.com/file/d/0B1-phaWAfkzjQUxMR3EydDJLM1k/view?usp=sharing
    (make sure you download the full 6.6 MB image, not the thumbnail)
    Something about these JPEGs is making Preview lose its mind, but I'm not sure what it is. Can anyone help? I have also posted to Apple support communities, but I figure that users here may be more knowledgeable about what could be wrong with the file format, etc.

    I see the issue already. You have a metric-ton of metadata you can see in File > Info under Raw data (or Advanced).
    More precisely several pages of this category, something I have never seen in a jpeg.
    <photoshop:DocumentAncestors>
                <rdf:Bag>
                   <rdf:li>0</rdf:li>
                   <rdf:li>000B84DD32F5ABCC8D7B5E8681465EE9</rdf:li>
                   <rdf:li>0013FA92942B6EC5451A4D9D4972AD7E</rdf:li>
    Quicklook is going crazy trying to parse all of this. I don't know where it came from or how important it is, but that's what is happening.
    Compare that against a normal loading jpeg.
    I had to try a Save for Web with the metadata removed (set to none) and it loads and previews normally in Preview.
    Gene

  • Why does my iphone lose its network connection

    Have a new iphone and a wireless network at home.  The phone connects to the network ok, but as I move around the house it loses its connection.  When attempts are made to reconnect the iphone replies "incorrect password", despite the fact that the password was stored from the previous connection.  Attempts to reenter the password do not help.  So far the only thing that allows a reconnect is to completely reset the network settings on the iphone, after which it connects once but then disconnects again later.  The issue may be related to the fact that there are two wireless routers in the house and the disconnections may be related to moving from the domain of one to another.

    Hi Frayyan,
    Welcome to the Support Communities!
    The article below will give you some insight about how to optimize your settings to improve the battery life on your iPhone:
    iPhone: Hardware troubleshooting  
    Battery life seems short
    Click ( www.apple.com/batteries/iphone.html) for tips on how to prolong iPhone's battery life.
    Try turning iPhone off and then on again.
    Connect iPhone to iTunes and restore iPhone.
    If the screen shows a low-battery image, the battery is low on power and needs to charge for up to ten minutes before you can use it.
    When charging iPhone, make sure to leave it charging until it is fully charged.
    Note: When charging using a computer, don't connect iPhone to a keyboard. Also, the computer must be turned on and not in sleep or standby mode. If iPhone is connected to a computer that's not turned on or is in sleep or standby mode, the iPhone battery may drain.
    I hope this information helps ....
    Have a great day!
    - Judy

  • My brand new iMac loses its WiFi connection when it goes to sleep, does anyone have a proven fix?.

    I have a MacBook that is about 4 years old and a brand new iMac both are running the most up to date version of Lion.  My old MacBook has no issues; however, my iMac loses its WiFi connection every time it goes to sleep.  There are some discussions about this already out there but does anyone have a proven fix.  This is very frustrating.

    I was having the same problem for a long time.  I tried everything but nothing seemed to make it stay connected.  It was very frustrating.  I just got a new Airport Extreme.....bang!.....all better.  Problem gone. 

  • My iPhone 4s won't go home, shut down, go to any other app bc its on twitter now frozen there and it won't reboot it wont let me force lock it and its frustrating. help!

    my iPhone 4s won't go home, shut down, go to any other app bc its on twitter now frozen there and it won't reboot it wont let me force lock it and its frustrating. help!

    Hi mltmj123,
    Welcome to the Support Communities!
    To address this issue, I would suggest you close all open apps, then restart and reset your iPhone.  Here's how:
    iOS: Force an app to close
    http://support.apple.com/kb/ht5137
    iPhone, iPad, iPod touch: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/ht1430
    Cheers,
    - Judy

Maybe you are looking for

  • Mail 4.2 Snow Leopard Exchange 2007 and Subfolders

    Hello, I am running Mail 4.2 on Snow Leopard connecting to Exchange 2007. My account seems to be working fine for my INBOX and for sending mail; however, although I am able to see my sub-folders (under my INBOX) none of the contents have been synchro

  • Creating links to files

    I want to create a local hyperlink, so to speak, to link scans of receipts to an accounting program - Money 2.5.4, by Jumpsoft. I've scanned the receipts in small .jpgs and would like to link each transaction to its receipt. Any ideas on how I might

  • Java sql quries help

    Hi I confuse on how to transform set difference query into java code to work in java program. how do you write a sql query in java that perform set difference. R - S R Except S (in oracle) I want to get all the elements in Set R that are not availabl

  • Xi integration testing

    Hi All, what are the main things we do in integartion testing... Can some one brief me...

  • If you upgrade to Yosemite keep in mind...

    I guess this is just a word of advice for those who like me tried to upgrade Mavericks to Yosemite. I don't know why but I seemed to have forgotten all sort of common sense practises that need to be carried out in preparation for an upgrade. Of cours