How can I stop a JFrame from taking the focus?

Hi,
Please see my original post in the Java Event Handling forum:
http://forum.java.sun.com/thread.jsp?forum=424&thread=565034&tstart=0&trange=15
Sorry, for cross-posting but its been nearly a week and I have had no replies. This forum looks a bit more active.
- David

try this...
JFrame frame = new JFrame();
frame.setFocusableWindowState(false);setFocusableWindowState
public void setFocusableWindowState(boolean focusableWindowState)Sets whether this Window can become the focused Window if it meets the other requirements outlined in isFocusableWindow. If this Window's focusable Window state is set to false, then isFocusableWindow will return false. If this Window's focusable Window state is set to true, then isFocusableWindow may return true or false depending upon the other requirements which must be met in order for a Window to be focusable.
Setting a Window's focusability state to false is the standard mechanism for an application to identify to the AWT a Window which will be used as a floating palette or toolbar, and thus should be a non-focusable Window.
Parameters:
focusableWindowState - whether this Window can be the focused Window

Similar Messages

  • How can I stop a JFrame from closing when clicking the close button.

    I need to display a dialog when a user attempts to close my app, giving them the option to close, minimize or cancel. How can I stop the form from closing after the user makes his selection? I have the folllowing code, but my form still closes after selecting an option:
    private void formWindowClosing(java.awt.event.WindowEvent evt) {                                  
            //An array of Strings to be used a buttons in a JOptionDialog
            String[] options = {"Close", "Minimize", "Cancel"};
            //Determines what the user wants to do
            int result = JOptionPane.showOptionDialog(null, "What to you want to do?  Close the application, minimize or cancel?", "Please select an option...", 0, JOptionPane.QUESTION_MESSAGE, null, options, options[0]);
           //Determines what to do, depending on the user's choice
            if (result == 0) {
                //Close the application
                System.exit(0);
            } else if (result == 1) {
                //Minimize the application
                this.setState(Frame.ICONIFIED);
        }Any help would be much appreciated!

    import java.awt.event.*;
    import javax.swing.*;
    public class test extends JFrame {
         public static void main( String[] args ) {
              new test();
         public test() {
              setSize( 200, 200 );
              //the next line makes the JFrame not close
              setDefaultCloseOperation( JFrame.DO_NOTHING_ON_CLOSE );
              //now add a listener that does the trick
              addWindowListener( new WindowAdapter() {
                        public void windowClosing( WindowEvent e ) {
                             //ask the user and do whatever you wish
              setVisible( true );
    }

  • How can I stop Firefox 4 from displaying "The document cannot change while Printing or in Print Preview" from appearing every time I click on File/Page Preview?

    Clicking on File/Page Preview in Firefox 4 brings up a warning dialog "The document cannot change while Printing or in Print Preview" every time. How can I stop this from happening? It is very annoying, and it is necessary to click "OK" on this dialog twice before it will go away. Thank you.

    Does it behave that way in [[Safe Mode]] ?
    If it doesn't, then one of your add-ons in the culprit.

  • How can I stop my camera from taking pictures every 15 seconds?

    I am so frustrated!  I have a Droid X which has worked well for about a year.  Just today It has just gone crazy taking pictures.  One picture after another.  Every fifteen seconds or so, regardless of what I am trying to do---work on the internet, dial my phone, etc.  I can barely shut down.  I've taken out the card and the battery and have tried to change any camera and general settings that I can find.  Do you have any idea how I can get my Droid to stop?  Any suggestions at all would be appreciated.  THANKS.

    You can't. What kind of USB device is that ?

  • How can I stop a JFrame from painting it's background on setVisible?

    When a JFrame is set visible it will paint its background before it paints whatever is in the contentPane. This gives an ugly gray flash before the content pane is painted. I can't use the solution of setting the JFrame's background color because the content pane is displaying an image, not a simple color. I need the image to be the first thing displayed when the frame is set visible. Seems related to doublebuffering some how, but I'm not sure what to do. The same problem presents itself with a JWindow IF it has a parent JFrame. Below is code that will demonstrate this problem.
    import java.awt.Color;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    public class Test extends JFrame{
    JPanel panel = new JPanel();
    public static void main(String[] args) {
    new Test().setVisible(true);
    private Test(){      
    getContentPane().add(panel);
    // setBackground(Color.white); // <-- uncomment this to remove flash.
    panel.setBackground(Color.white);
    setSize(640, 480);
    super.setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    I can't use the solution of setting the JFrame's background color because the content pane is displaying an image, not a simple colorMy question to you is what difference does it make?. Like it or not, JFrame is either going to set the background with the LAF control color or the color you specified. Take a look at the source code and you will see that JFrame calls a protected frameinit method where it gets and sets the backgroud color. The only feasible solution is shown below:
    import java.awt.Color;
    import javax.swing.*;
    public class Test extends JFrame {
       JPanel panel = new JPanel();
       public static void main(String[] args) {
          UIManager.put("control",Color.white);  // added by V.V.
          new Test().setVisible(true);
       private Test() {
          getContentPane().add(panel);
          panel.setBackground(Color.white);
          setSize(640, 480);
          super.setDefaultCloseOperation(EXIT_ON_CLOSE);
    };o)
    V.V.

  • How can I stop my boss from taking away my Mac?

    Dear Apple community, 
    My name is Khilila and my boss wants our creative office to switch to PCs for our next upgrade. I'm been a graphic designer for close to 10 years and I am completely heartbroken.  Is there anyone out there that's experienced the same thing?  I'd like to create a manifesto of sorts but I'd love to hear from some fellow Apple professionals so I know I'm not crazy.
    Thank you,
    Khilila
    Canada

    What are you using now? an iMac has limited upgrade options and shorter shelf life.
    You can run Windows 7 on any PC and have your picks of graphic setups, SLI, CF, higher clocked RAM and cpu.
    A boss gets to decide. And for same $3,000 per seat plus software, cross-platform license....
    You can run Windows on your Mac but... there is total lack of real fan + thermal control so that does not work well in long run.
    And your boss probably doesn't want to wait on Apple or buy into higher cost proprietary technology or 3 yr old design.
    Haswell PCs? Unlikely they want Xeons.
    Software? good use of cores? probably Windows.
    Best Windows laptop: MacBook Pro 13" (but heat again is the Achilles heel)
    Security: Mac
    Hardware support and reliablity: Mac
    Dealing with firmware updates: Apple tends to issue very few, usually one more after a model ships, PC: tend to see much more that you need to deal with and can be PITA and necessary, esp. with motherboard and processor support with new line.
    Make a spreadsheet and list all the things you can come up with and see for yourself.
    I don't think you'll win over your boss and how does it make you look? team player? reliable? dispensable?

  • How can I stop my dock from rearranging the apps by itself?

    I just received my iMac from FedEx today and got it all set up, but whenever I try to rearrange the icons on my dock, about 5-10 seconds later they just rearrange themselves randomly or sometimes go back to their previous location before I moved them myself.
    I never had these problems with Snow Leopard on my last mac so I'm just wondering if this is a bug or if anybody has a fix for it. I found a suggestion to go to ~Library/Preferences and delete 'com.apple.preferences.plist' but I couldn't find it in that folder or anywhere on my local HD for that matter.
    If anyone has any other suggestions it would be greatly appreciated, thanks!

    Lion hides your Library folder.  You can get to it via the Finder Go menu, Go To Folder, and entering ~/Library or ~/Library/Preferences depending on where you want to go.
    As for the dock thing, I realize you have a new system, but have you installed any third party additions at this point?  Or is this still a "pristine", as-shipped version of Lion?
    The plist you may want to remove is,
    ~/Library/Preferences/com.apple.dock.plist
    i.e., that plist in your home directory Preferences.  Log out and back in after you remove that plist.

  • How can i stop my computer from losing the wi-fi link

    My computer keeps "losing" the wi-fi in my home and making me sign in over and over.  It recognizes the network and doesn't require me to give the password for the network, but it asks me for the password required to make network changes.  It has done this for a couple of years now.  It is inconsistent.  About half the time, it works fine, but then it will say your preferred network is not available.  Then it will show that network as the only one available and require the password for making network changes again.  I have gone into the network utility and "locked" it after making the changes, but it doesn't make any difference.

    If it's happening after a period of shutdown and a startup, then try only sleeping the Mac Mini instead of shutting it down. (Besides, sleeping a Mac is easier on the hardware and perfered over shutting down)
    For example: my Mac's only get shut down when I go away for more than a couple of days and can sleep for weeks without any problems.

  • All my contact are being copied to my friend's iphone and i also am getting his contacts on my phone,when i delete a contact it also deletes it from his phone,we are sharing the same apple ID. How can i stop our contacts from being shared between us

    All my contact are being copied to my friend's iphone and i also am getting his contacts on my phone,when i delete a contact it also deletes it from his phone,we are sharing the same apple ID. How can i stop our contacts from being shared between us

    Everything that you have checked in your icloud settings will be shared between devices using the same Apple ID.  If you don't want icloud to share that information, then simply turn off that process under settings > icloud

  • How can I stop my iPhone from synching my contacts and groups lists twice?

    How can I stop my iPhone from synching my contacts and groups lists twice....I am using iCloud but am not sure how correct this duplication.

    Go into Settings>Mail, Contacts, Calendars. Is this happening at the bottom in the signature section, or in the header of the mail where your email address is? If it is the signature, then go to the Signature area of the Mail settings. If this is in the header, then go to the account in question and edit your account information to include your name instead of Johnny.

  • How can i stop my phone from vibrating in my ear when i am on the call?

    How can i stop my phone from vibrating in my ear when i am on the call? I usually keeps my phone on vibration mode so i get notified when there is a new mail or message? However, when i am on the call, then also, it vibrates in my ear everytime a mail comes. Very irritating. I use my business phone and mails keep coming every 2-5 mins.
    Please help.

    very impractical . specially when you call A LOT and receive notifications constantly!

  • How can i stop internet media from flooding elements 6?

    how can I stop elements 6 from constantly importing internet photos and flooding my memory?

    PSE isn't importing photos off the internet, but it could be importing photos from your hard drive that are being placed there as you browse the internet.
    It's likely that you've told PSE to import all new photos on your hard drive using the Watched Folders mechanism.
    In the Organizer, go to File > Watch Folders...
    See the list of folders PSE is currently watching.
    Check the setting near the bottom of the dialog as to what PSE should do when it finds new images in the folders it is watching.
    Make any necessary changes to have it do what you want it to do.
    Cheers
    Bob

  • Hi, how can I stop my screen from freezing up.Its acts like a scratch card, I use the mouse cursor to rub away to find the password box?

    HI,how can I stop my screen from freezing, It acts like a scratch card,I run over it with the mouse to scratch away at the grey screen to find the password box
    underneath?

    OS X: Login window partially appears, cursor movement redraws screen

  • How can i stop an email from being sent?  i cannot find an outbox in outlook

    How can I stop an email from being sent.  I cannot find an outbox in Outlook

    Outlook is a Microsoft product, I'd suggest posting on the Office for Mac Product Forums.

  • How can I stop iPhone 5s from blinking apple logo

    how can I stop iPhone 5s from blinking apple logo

    Hello tigersrock,
    Thank you for using Apple Support Communities.
    For more information, take a look at:
    iOS: Not responding or does not turn on
    http://support.apple.com/kb/ts3281
    Have a nice day,
    Mario

Maybe you are looking for

  • Why does my iMac freeze so often?

    I got an iMac computer last May, and ever since then I have been having some issues that can be quite annoying. First of all, it freezes very often. I could be in the middle of reading an email and suddenly the rainbow spinning ball comes on and neve

  • Ipod Shuffle (2nd Gen) Does Not Recognize Songs

    My Ipod Shuffle (2nd Gen) does not recognize the songs that are loaded on it. When I turn it on after a full charge the green light stays on for about 5 seconds then turns off. When I press play, the colors flash orange and green indicating there are

  • A Link with parameters to another page in a report

    Hi, I need to pass a link to another page with parameter, all in a report - But I can't use the column link because I already use to another link. Help!!

  • Calling smartform from other system in ECC.

    Hi friends, I have a smart form in other system....In Ecc there is an alv report  where in when i click on any line item,it should fetch the information in terms of smart form from the other system.that is a smart form present in other system should

  • Re: Adobe AIR for iPhone

    Based on the announcement yesterday from Apple to let 3rd party code run on the iPhone, ie Adobe AIR files, does anyone know if there any plans to restart the Air SDK for the iPhone and make it like it is on Android?