Trying to center frame, but affects my Robot method

Hi, I am using a robot to take a screen shot of the users screen, which will then display on top of the screen with a piece of text printed. This works fine, but when I try to center the frame that holds the information the background is replaced with a grey box (with my text in). Is there any way I could get around this at all? Here is the relevant code, all help is very much appreciated. Thank-you :)
    public void createPanel()
        JFrame frame = new JFrame();
        frame.setUndecorated(true);
        frame.setLayout(new BorderLayout());
        MyDisplay test = new MyDisplay(frame);
        test.setLayout(new BorderLayout());
        frame.add(test, BorderLayout.CENTER);
        JLabel label = new JLabel("This is just a test");
        test.add(label, BorderLayout.CENTER);
        frame.pack();
        frame.setSize(500, 200);
        // make sure you pack and/or set size first...
        Dimension dS = Toolkit.getDefaultToolkit().getScreenSize();
        Dimension dF = frame.getSize();
        // make sure it's not off screen
        int x = (dS.width/2)-(dF.width/2);
        int y = (dS.height/2)-(dF.height/2);
        if(x < 0) x = 0;
        if(y < 0) y = 0;
        frame.setLocation(x, y);
        frame.setVisible(true);
        startRobot();
    public void startRobot()
        try {
            robot = new Robot();
            Rectangle r = new Rectangle(500, 200);
            background = robot.createScreenCapture(r);
        catch (Exception e) {
    }

Swing related questions should be posted in the Swing
forum.
If it's swing you want to use,
I will kindly spread the news.
Camickr's the one to ask,
Ask him first, don't wait till last.
You must post in proper place,
or the egg is on your face.
Post where swing will be discussed,
don't be makin' such a fuss.
If gui is what you require,
'bout the swing you should inquire.
"New to Java" ain't for you,
Swing's what you should really do.

Similar Messages

  • Suddenly on sunday while i was working, my macbook Air stopped working, right after that i tried getting it on but nothing came other than a grey screen with a question mark right in the center could you please help me in rectifying the problem. Would th

    Suddenly on Sunday while i was working, my macbook Air which i bought last year in Spetember from Arkansas, Little Rock stopped working, right after that i tried getting it on but nothing came other than a grey screen with a question mark right in the center. Could someone please help me in rectifying the problem. Would thi issue also affect saved data. However, I have handed the notebook to Apple for reapirs and they will revert by Thursday 12/04/2012.

    I just received some horrifying news from Adobe about my production suite.  I just FINALLY learned today that what I've been trying to do for over a week now - CAN'T be done because of compatability issues involving updates of both Adobe & Microsucks Winders!!!  I sincerely hope this is not your problem.  Mine is ALMOST HOPELESS!!  Being in this HOPELESS Obamma economy,,,, leaves NO STIMULUS in which to currently upgrade everything that needs upgraded for me to fully use my INVESTMENT in Adobe Suite - sad, horrible and SICKENING!!!
    I just wanted to post this. And again, I truly hope you find a solution. Good Luck!

  • I am trying to get into my Game Center app but every time I tap on the app it opens too a blank white screen. I have tried several times to reset my phone but I get the same result.

    I am trying to get into my Game Center app but every time I tap on the app it opens too a blank white screen. I have tried several times to reset my phone but I get the same result.

    Hello there Sweebs44,
    It sounds like you are tapping the Game Center app to open it, but the screen is blank. I recommend signing out of your account:
    Go to Settings > Game Center, where you can:
    Sign out (tap your Apple ID)
    From: iPhone User Guide
              http://help.apple.com/iphone/7/#/iph6c493cac
    Then close all the running apps:
    iOS: Force an app to close
    http://support.apple.com/kb/ht5137
    Double-click the Home button.
    Swipe left or right until you have located the app you wish to close.
    Swipe the app up to close it.
    When you have done that restart the phone sign back into your account and try again:
    iOS: Turning off and on (restarting) and resetting
    http://support.apple.com/kb/ht1430
    Thank you for using Apple Support Communities.
    Take care,
    Sterling

  • I've problem with Game Center . I can't sign in Game Center on my iPad . I tap on the Game Center icon but the page is blank. I tried go to setting, my Apple ID appear but the page keep on loading and  nothing pop up. How to resolve this issue?

    I've problem with Game Center . I can't sign in Game Center on my iPad . I tap on the Game Center icon but the page is blank. I tried go to setting, my Apple ID appear but the page keep on loading and  nothing pop up. How to resolve this issue?

    Hi, bamboo64. 
    Try closing all open applications in multitasking and power cycling the device.  Once this is done test the results.  If the issue persists, I have included a couple troubleshooting articles that I would recommend going through. 
    iOS: Force an app to close
    http://support.apple.com/kb/ht5137
    Troubleshoot issues on an iPhone, iPad, or iPod touch
    If you haven't been able to connect to the iTunes Store:
    Make sure your date, time, and time zone are correct in Settings > General > Date & Time.
    Note: Time Zone may list another city in your time zone.
    Make sure that your iOS software is up to date by tapping Settings > General > Software Update (iOS 5 or later) or connecting your iOS device to iTunes and clicking Check for Update on your device's Summary page.
    Check and verify that you're in range of a Wi-Fi router or base station. If you're on a device with cellular service, make sure that cellular data is turned on from Settings > General > Cellular.
    Note: If connected to cellular data, larger items may not download. You may need to connect to Wi-Fi to download apps, videos, and podcasts.
    Make sure that you have an active Internet connection. You can check the user guide for your device for help with connecting to the Internet.
    Make sure that other devices (portable computers, for example) are able to connect to the Wi-Fi network and access the Internet.
    Try resetting (turning off and then on again) your Wi-Fi router.
    If the issue persists, try troubleshooting your Wi-Fi networks and connections.
    Can't connect to the iTunes Store
    http://support.apple.com/kb/ts1368
    Cheers,
    Jason H. 

  • Hello, i'm creating a very simple animation in ps cs5, but when I try to transform a smart object in a frame, all the frames are affected by it. What can I do ? Thanks, Ep

    Hello, i'm creating a very simple animation in ps cs5, but when I try to transform a smart object in a frame, all the frames are affected by it. What can I do ? Thanks, Ep

    Ok, you are in frame animation mode. I thought cs5 had a timeline mode, but now I think I was wrong.
    In frame animation mode what you do is in one frame you have the object rotated in one position, then select an other frame and rotate it. If it rotates the first frame, which I think it will. Create duplicate of the object in a new layer. Then rotate the second layer.
    At this point in my example you would have two layers, one of which has a rotated object.
    Clear the frames
    Convert the two layers to frames.
    You now have two frames, one for each layer.
    Select both frames then click the tween button.
    This will create the in between frames.
    In the tween dialog box the higher the number of frames set here, will create a smoother animation but will result in a longer time frame for the animation to play.
    Because Photoshop has no way of knowing which way the object should rotate, it is feasible for it to rotate the opposite direction or could look wonky. Just undo and add an in between layer showing how it should look in the middle, then continue on.
    So your layers should be the following, a frame that shows all objects in their rest state.
    All objects that remain in a rest state must be copied to the next layer (ctrl-j on Windows or cmd-j on Mac)
    All subsequent layers are then used for rotating a duplicate of the object. (Ctrl j or cmd j)
    You will find the commands to clear the frames, convert layers to frames and tweeting in the hidden menu found when you click the small icon in the upper right hand corner of the animation panel.

  • I am trying to center my content, but the Divs (which contain my spry menu and logo) will not center

    I have two Divs (there will be more in the future) that I am trying to center together on my page, but when I use the #wrapper code I have seen and a div tag, nothing changes.
    This is my HTML code
    <body>
    <div id="wrapper">
      <div id="Logo"><img src="Backgrounds/Color-War-Logowhite.png" width="250" height="250" alt="The Color War"></div>
      <div id="MenuBarDiv">
        <ul id="MenuBar1" class="MenuBarHorizontal">
          <li><a href="#">Home</a>    </li>
          <li><a href="#">About</a></li>
          <li><a href="#">FAQ</a>    </li>
          <li><a href="#">Registration</a></li>
          <li><a href="#">Contact</a></li>
        </ul>
      </div>
      <div id="Home-Splat"></div>
      <div id="About-splat"></div>
      <div id="FAQ-splat"></div>
      <div id="Registration-splat"></div>
      <div id="Contact-splat"></div>
      <p> </p>
    </div>
    <script type="text/javascript">
    var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
    </script>
    </body>
    and this is my CSS
    #wrapper {
              width: 960px;
              margin-right: auto;
              margin-left: auto;
    I am new to dreamweaver and webdesign and can't figure this out.
    Can anyone help me with this?

    You're welcome
    Find any hosting you can
    http://www.w3schools.com/css/

  • Help! I can't update itunes because I deleted quicktime then tried to reinstall quicktime but there are components that won't be uninstalled

    Ok. So a while ago quicktime got deleted (but only partially) which won't allow me to reinstall it to fix it. The error with quicktime affected my itunes which I can no longer open. I tried to reinstall everything but I get an error because 1) the older version of bonjour cannot be removed and 2) an older version of quicktime cannot be removed which then says that itunes can not be installed without quick time. But I also cannot delete everything to reinstall. Because when I try to delete either Bonjour or quicktime I get this message: the feature you are trying to use is on a network resource that is unavailable!
    I have performed a search on my hard drive to find all quicktime files to try to delete but it won't let me delete the last three files and gives me this message when I attempt to delete: Cannot delete file. Cannot read from the source file or disk. And the other two only allow me the option to open containing folder, copy or extract....
    I also made changes on the registry according to someone else' instructions to see if that would solve the problem, restarted the computer but that didn't help either.
    Nothing has allowed me to reinstall itunes back onto my computer and without itunes, I can not sync my iphone and get updated! I am using Windows XP by the way
    This is driving me crazy!
    Thanks for any help in advance,
    Tiffany

    I tried to reinstall everything but I get an error because 1) the older version of bonjour cannot be removed and 2) an older version of quicktime cannot be removed which then says that itunes can not be installed without quick time.
    Unfortunately, this sort of trouble has gotten more complicated to deal with ever since Microsoft pulled the Windows Installer CleanUp utility from their Download Center on June 25. First we have to find a copy of the utility.
    Let's try Googling. (Best not to use Bing, I think.) Look for a working download site for at least version 3.0 of the Windows Installer CleanUp utility. (The results from mydigitallife and Major Geeks are worth checking.)
    After downloading the utility installer file (msicuu2.exe), scan the file for malware, just in case. (I use the free version of Malwarebytes AntiMalware to do single-file scans for that.)
    If the file is clean, to install the utility, doubleclick the msicuu2.exe file you've downloaded.
    Now run the utility ("Start > All Programs > Windows Install Clean Up"). In the list of programs that appears in CleanUp, select any Bonjour and QuickTime entries and click "Remove".
    Quit out of CleanUp. Restart the PC, and try another iTunes install. Does it go through properly this time?

  • Center Frame & Lock in Minimum Size

    Before setting the main frame visible, many (if not most) Swing applications need to center the frame and lock in a minimum size. These are basic, fundamental steps, but currently they require writing a fair amount of tedious code. This situation could be improved with a couple of convenience methods.
    For example:   JFrame frame = new JFame();
       //add UI controls
       frame.pack();
       frame.center();
       frame.setMinimumSize(frame.getCurrentSize()); Any idea why these (or similar) methods are not included in Java? It sure would clean up the top level Swing class in many applications.
    - Dem

    This situation could be improved with a couple of convenience methods.So create a class called MyFrame and write your own. Everybody has there own idea of whats important and whats not. Thats why you have the ability to extend classes --- to add your own functionality.
    have you tried:
    frame.setLocationRelativeTo( null );
    If your looking for a way to control the minimum size then use add a ComponentListener to the frame. Examples have been posted in the forum.

  • HT1222 I just installed this update and now I cannot access "Mail" at all.  I tried reinstalling the program, but that does not work, either.  Help!!!!!!

    I just installed this update and now I cannot access "Mail" at all.  I tried reinstalling the program, but that does not work, either.  Help!

    Paldeng, thanks for the suggestion.  I've done all that.  I can connect to the server, but apparently they are not recognizing my ID and password.  I can use the server program if I don't go through Mail (using the same ID and password).  My mother in another state with another provider has had the same email issue, as also my husband on his laptop who uses the same internet connection I do.  His worked fine until we had it repaired at the Apple store and all the original programs reloaded (with the required updates, I assume).  We can receive email in Mail, we just cannot send.
    I contacted my service provider, and we went over my connections.  They said it was not their problem and connected me with Apple, resulting in a charge to me because my warranty is long expired.  Apple swears it is not their problem, it is the provider, so here I sit.  My son was able to fix my Mom's Mail (she's 97) and got my husband's working also, until mine went out, by tweaking connection descriptions and ports remotely.  The thing is, we had not messed with any of those settings, so what changed?  I just did not want to bother my son again, as he has many other demands on his time.
    Since this fiasco with the Mail v4.6 update, I'm wondering if something else was updated that works well with Lion and Mountain Lion, but does not work well with Snow Leopard and Leopard.  I think the problem I had with the Mail update was that my Mail program had been renamed to Mail (original), and therefore was not being recognized by the update.  Perhaps they had another tweak in there somewhere that is affecting outgoing mail connections?

  • Every time i connect my iphone to itunes and trying to do a backup or get the new update it says i have to restore my iphone. and then that doesnt work, i tried to reinstall itunes but it doesnt work. i get this all the time. fix it please.

    Every time i connect my iphone to itunes and trying to do a backup or get the new update it says i have to restore my iphone. and then that doesnt work, i tried to reinstall itunes but it doesnt work. i get this all the time. fix it please.

    iTunes states " There's a problem with your Iphone, please contact apple service center " Also i took my iphone to a local service man and he told me the IMEI code has been corrupted and there's nothing that can be done about it. Please help, if you have any solution.
    Thank you

  • Trying to center text in a text box

    I have just upgraded from InDesign CS2 to CS4. I am trying to center text vertically in a text box. I remember in CS2 that there were three different buttons, one that would center it at the top, one that would center the text in the middle and one on the bottom.
    If anyone knows where these buttons went, it is much appreciated.
    Thanks.

    Ah! There they are...on the control panel, (when the frame is selected with the pick tool...as opposed to having a live insertion point). They are pretty far to the right. If your display size is such that not all the features fit, they may be getting clipped.

  • My mini ipod appears off and not respond to any commands when pressed the buttons to reset, apple logo appeared and then the apple support site and it shuts down. already tried all the steps, but none worked, and when I plug it into my computer it does no

    My mini ipod appears off and not respond to any commands when pressed the buttons to reset, apple logo appeared and then the apple support site and it shuts down. already tried all the steps, but none worked, and when I plug it into my computer it does not appear in the iTunes bar. what do I do?

    If MacKeeper corrupted the Recovery partition then even I underestimated its potential for damage. Garbage "cleaning" apps will cause misery but I have not found that the Recovery partition to have been affected by using MacKeeper or anything like it. I doubt that it did so, but I have learned not to underestimate the potential for such things to result in system corruption.
    Before concluding your Mac has a hardware failure, try booting OS X Internet Recovery by holding command option r on startup (three fingers). That will force your iMac to bypass the Recovery partition altogether, and convey the ability to create a new one.
    An Internet connection will be required (wired or wireless).
    At the Mac OS X Utilities screen, select Disk Utility. Select your startup volume (usually named "Macintosh HD") and click the Repair Disk button. Describe any errors it reports in red. If Disk Utility reports "The volume Macintosh HD appears to be OK" in green then you can be reasonably (though not completely) assured your hard disk is in good working order.
    Assuming the HD remains usable you can then use Disk Utility to erase it. Reinstall OS X, restore your essential software and other files, and don't reinstall the junk.

  • Firefox will not open,tried running profile manager but I receive a small window with the word :dialog" in it.

    Firefox will not open.Tried uninstalling and reinstalling program without any success.
    Tried running profile manager,but a small screen shows up with the word "dialod" in it.
    Any assistance appreciated.
    == User Agent ==
    Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; GTB0.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2; .NET4.0C; Tablet PC 2.0)

    Can you provide us a screenshot?
    Vista/7
    Go to Start and type in Snipping Tool then provide a screenshot ,save it, and upload it to any of these file uploading websites.
    [http://www.imageshack.us ImageShack]
    [www.mediafire.com MediaFire]
    [www.kimag.es Kimages]
    XP
    Press '''FN + PRT SC''' on your keyboard to take a screenshot and Press '''CTRL + V''' in Paint to paste it and save it and upload it.

  • My iCloud keeps asking me for a password even when I enter it, it still keeps asking. I have tried turning it off but it doesn't work.

    My iCloud keeps asking me for a password even when I enter it, it still keeps asking. I have tried turning it off but it doesn't work. It is really annoying!!
    Please help me!! (The same thing happened on this device and when I reset it, it worked....why isn't my iPad 3rd gen. Working...?)

    Try reset iPad
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.

  • HT1527 I have windows 7 and have tried the troubleshooting steps but am still unable to connect to the itunes store yet my PC is connected to the internet, it just keeps looking like its trying to access the store

    I have windows 7 and have tried the troubleshooting steps but am still unable to connect to the itunes store yet my PC is connected to the internet, it just keeps looking like its trying to access the store

    I have the same problem but the solution Wendyz99 did has not been successful for me. Part of the itunes store loads on the right side where the tabs for Quick Links and Top Charts are but the center section of the page is white. Also if I click on a song that is in the top chart area it will take me to the page but I'm not able to purchase the song or preview the song.
    I feel I have tried all the solutions I can find on line and even had conversations with apple tech with no help.
    I have down loaded the Autoruns program and in the winstock providers I have Bonjour and Microsoft Windows Live ID Namespace Provider. I have removed Windows Live and this still does not resolve the problem. I am at a complete loss. I am running windows 7, 32bit. Someone please help!

Maybe you are looking for

  • PO: reverse the invoice receipt to the conditions

    Hello, I'm looking for a ABAP (function module) to get the values of a invoice receipt to the detail conditions. for excample: I have a invoice with 960 EUR. now I want the conditions: PB00: 1000EUR (gross price) SKTO: - 40EUR (cash discount) includi

  • Flash content on Safari

    Sorry if I am duplicate posting! When will Flash content be playable on IPT, getting a little bored of Lego Block. Does anyone know if there are plans to have permissions for alternative browsers installed (i.e Firefox) in the future?

  • Authentication Error code 201

    Newly configured agent getting authentication code 201 when trying to log into phone... EM enabled Using LDAP Can someone assist with this?...

  • How to see the underlying calendar for an event in Calendar app?

    The Calendar app on iPhone does not show the underlying calendar for a given event unless the event is edited, or at least I didn't find a way. My difficulty is that colour alone is not sufficient to tell events apart in all circumstances (9 active o

  • Wi-fi not working iphone 4s

    Iphone 4S wifi not working please help me