How to display a frame at the upper left corner of each screen?

hi,
below are 2 ways to display a frame at the upper left corner of each screen (i have 2 monitors).
both work but the 2nd way is much slower. which, if any, of the 2 approaches is "more" correct?
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.DisplayMode;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import java.awt.GraphicsConfiguration;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.Toolkit;
import javax.swing.JFrame;
import javax.swing.JPanel;
// the thing that matters in here is setting the frame's location: xCoord
// is incremented in each iteration by the current screen's width and
// is used to set the frame's x-coordinate.
public static void main(String args[])
      GraphicsEnvironment gEnviron = GraphicsEnvironment.getLocalGraphicsEnvironment();
      GraphicsDevice[]    gDevices = gEnviron.getScreenDevices();
      Color colors[] = {Color.blue, Color.red};
      for(int i = 0, xCoord = 0; i < gDevices.length; i++)
         // set panel's size and frame's size to take up the whole screen
         DisplayMode didsplayMode = gDevices.getDisplayMode();
int screenWidth = didsplayMode.getWidth();
int screenHeight = didsplayMode.getHeight();
JPanel panel = new JPanel();
panel.setBackground(colors[i % colors.length]);
JFrame frame = new JFrame();
frame.setSize(new Dimension(screenWidth, screenHeight));
frame.setContentPane(panel);
frame.setUndecorated(true);
// set location of frame.
frame.setLocation(xCoord, 0);
xCoord += screenWidth;
frame.addMouseListener
new MouseAdapter()
public void mousePressed(MouseEvent event) {System.exit(1);}
frame.setVisible(true);
// this is a lot slower and may not be correct: it sets the frame's location by calling
// getConfigurations() on each screen device but using only the 1st configuration
// (it returns 6 on my computer) to get the bounds (for the frame's x-coord).
// a screen device has 1 or more configuration objects but do all the objects
// of the device report the same bounds? if the anwser is yes, then the code
// is correct, but i'm not sure.
public static void main1(String args[])
GraphicsEnvironment gEnviron = GraphicsEnvironment.getLocalGraphicsEnvironment();
GraphicsDevice[] gDevices = gEnviron.getScreenDevices();
Color colors[] = {Color.blue, Color.red};
for(int i = 0; i < gDevices.length; i++)
// set panel's size and frame's size to take up the whole screen
DisplayMode didsplayMode = gDevices[i].getDisplayMode();
int screenWidth = didsplayMode.getWidth();
int screenHeight = didsplayMode.getHeight();
JPanel panel = new JPanel();
panel.setBackground(colors[i % colors.length]);
JFrame frame = new JFrame();
frame.setSize(new Dimension(screenWidth, screenHeight));
frame.setContentPane(panel);
frame.setUndecorated(true);
// set location of frame: getConfigurations() is very time consuming
GraphicsConfiguration[] gConfig = gDevices[i].getConfigurations();
// on my computer: gConfig.length == 6. using the 1st from each set of configs
Rectangle gConfigBounds = gConfig[0].getBounds();
frame.setLocation(gConfigBounds.x, gConfigBounds.y);
frame.addMouseListener
new MouseAdapter()
public void mousePressed(MouseEvent event) {System.exit(1);}
frame.setVisible(true);
thank you.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Darryl.Burke wrote:
Blocked one abusive post.
@flounder
Please watch your language.
dbDude - I just looked at your profile. WTF are you doing in India??

Similar Messages

  • Youtube videos are imprinting in the upper left corner of my screen.

    When I have a youtube video playing in one tab, and I'm looking at another tab and bringing up a notepad text file or Spider Solitaire, the youtube video will imprint itself over the upper left corner of my screen and won't go away unless I refresh the desktop (solves it for a few seconds) or move the youtube tab away from the actively playing video.
    It doesn't happen with every video. Here's two where it affects me.
    http://www.youtube.com/watch?v=zBQVsJbM6e8
    http://www.youtube.com/watch?v=Ui0WU0QcE3M
    Does anyone know what's causing this?

    Ah, now I notice the Edit This Post function. -_-

  • When youtube is not my active tab, the video plays in the upper left corner of my screen.

    When I attempt to view a video on youtube, it takes several seconds to buffer. Leaving the video to run in the background I navigate to other tabs I have open and while the video buffers, nothing happens. When the video actually starts to play in the tab in the background, the video begins to play in the upper corner of my screen. The video does not to appear to be distorted at all, it's simply shifted from its location in the background tab to the upper left corner of my screen.

    Press F10 or press and hold the Alt key down to bring up the "Menu Bar" temporarily.
    * New Old Menu: https://addons.mozilla.org/firefox/addon/new-old-menu/
    * Personal Menu (Personal Firefox Button): https://addons.mozilla.org/firefox/addon/personal-menu/

  • How do remove that dot on the upper left corner

    Maybe a stupid question, but I am a starter.
    When I have published my site with iWeb, I see this stupid dot in the upper left corner, which I haven't been able te remove.
    See http://www.vanderveld.com
    Any solution for this?
    Thanks.
    John

    I don't see the dot. Try emptying your browser cache and then revisit the published site.
    Safari/Empty cache... or Option/Command/E

  • How to show the login user Id in the upper right corner of each page?

    Hi,
    I was wondering how to show the login user Id in the upper right corner of each page?
    thanks so much!
    cchu

    Cchu,
    The easy question first: applying a style to the welcome message. If you look at the page source, you'll see that #WELCOME_USER# is expanded to <div class="app-user">Welcome: DEMO</div> So to change the style of the message, you need to tweak the style of the app-user div in your CSS, or override it in a style block in your HTML header.
    Now, the tougher question: why the text is wrapping for you. And, really, without seeing your entire page, I can't give a full answer. But I'd suggest that what's most likely happening is that the table column you're putting it in is too narrow, so it's wrapping; try replacing the td tag with <td nowrap="nowrap"> This will force the column to be wide enough to display the full message, but might result in weird formatting elsewhere on the page (depending on what all is in your table).
    -David

  • GMAIL Appear in a small frame on the upper right corner

    When login into GMAIL it appear inside a small frame on the upper right corner
    I Tried to Disable all Addons and Plugins, I Tried to delete cookies and cache, I Tried to upgrade display driver, I tried changing resolution, nothing help.
    == URL of affected sites ==
    http://mail.google.com

    "Clear the Cache": Tools > Options > Advanced > Network > Offline Storage (Cache): "Clear Now"
    "Remove the Cookies" from sites that cause problems: Tools > Options > Privacy > Cookies: "Show Cookies"
    Start Firefox in [[Safe Mode]] to check if one of your add-ons is causing your problem (switch to the DEFAULT theme: Tools > Add-ons > Themes).
    See [[Troubleshooting extensions and themes]] and [[Troubleshooting plugins]]
    See also [[Websites look wrong]]

  • How do I get rid of yahoo toolbar and get back my orange firefox button in the upper left corner of screen so I can use my stuff again?

    Yahoo toolbar suddenly imposed itself as my log on screen whenever I booted up my computer and clicked on Firefox. Now I can't get to my bookmarks even though it told me that if I activated the new bookmark system it would transfer my old ones. It didn't happen. The toolbar has no bar for typing in a www.http address. I cannot use it and don't want it. I am using Explorer just so I can access my bookmark address, but don't like Explorer. I want my old Firefox screen back that has the little orange button in the upper left corner of the screen. How can I get there? My computer use has been highly curtailed by this unrequested invasion!

    Make sure that you do not run Firefox in full screen mode (press F11 or Fn + F11 to toggle; Mac: command+Shift+F).<br />
    If you are in full screen mode then hover the mouse to the top to make the Navigation Toolbar and Tab bar appear.<br />
    You can click the Maximize button at the top right to leave full screen mode or right click empty space on a toolbar and use "Exit Full Screen Mode" or press F11.<br />
    If the menu bar is hidden then press the F10 key or hold down the Alt key to make the menu bar appear.
    *https://support.mozilla.com/kb/Menu+bar+is+missing
    Make sure that toolbars like the "Navigation Toolbar" and the "Bookmarks Toolbar" are visible: "View > Toolbars"
    *Open the Customize window via "View > Toolbars > Customize"
    *Check that the "Bookmarks Toolbar items" is on the Bookmarks Toolbar
    *If the "Bookmarks Toolbar items" is not on the Bookmarks Toolbar then drag it back from the toolbar palette in the customize window to the Bookmarks Toolbar
    *If missing items are in the toolbar palette then drag them back from the Customize window on the toolbar
    *If you do not see an item on a toolbar and in the toolbar palette then click the "Restore Default Set" button to restore the default toolbar set up
    *http://kb.mozillazine.org/Toolbar_customization
    *https://support.mozilla.com/kb/Back+and+forward+or+other+toolbar+items+are+missing

  • How to replace the LabVIEW icon in the upper left corner of panels?

    Hi Gang,
    We're going to create an application that will go to customers.  We want to replace the LabVIEW icon in the upper left corner of panels with the company logo.  How do I replace that?
    All responses will be appreciated.
    Thanks in Advance,
    Roger
    Solved!
    Go to Solution.

    As rolfk said, edit the icon in the build specification.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Edit EXE Icon.png ‏36 KB

  • I have this question mark (?) in the upper left corner of my Finder windows. Anyone know what's up with that, what it might portend, and how to get rid of it?

    I have this question mark (?) in the upper left corner of my Finder windows. Anyone know what's up with that, what it might portend, and how to get rid of it?

    Are you sure you have a PowerMac? They can't run Mac OS 10.6.8. Maybe a Mac Pro instead?
    Can you post a screen shot of that portion of the screeen for us to review? Does the question mark replace the Apple that's at the left end of the menubar?

  • The red, green and yellow buttons in the upper left corner of the screen disappear whenever I open Safari.  I cannot minimize the Safari window which I often need to do if I am coordinating multiple windows.  Does anyone know how to get those buttons back

    The red, green and yellow buttons in the upper left corner of the screen disappear whenever I open Safari.  I cannot minimize the Safari window which I often need to do if I am coordinating multiple windows between different applications.  Does anyone know how to get those buttons back?  I guess I could just switch betwen appliations, but I am used to doing it the other way.

    You're welcome 
    You had Safari in full screen mode.

  • One website appears small and in the upper left corner of the screen - how do I fix

    A website that used to appear normal on my screen now has shrunk and is at the upper left corner of the screen. It is too small for me to use. How do I get the website to appear normal size again? I already tried "Full Screen" option and that does not fix the problem. I am using Firefox 16.0.2 and Windows 7.

    @jack, resetting the zoom level is already covered in the help article ;-)

  • I forgot how to use the setting, move the mouse to the upper left corner and the windows become smaller for an overview?

    i forgot how to use the setting, move the mouse to the upper left corner and the windows become smaller for an overview?

    I'm not quite sure what you want - if you want an overview of all open windows, use the F key.. Otherwise please post back and be more specific.

  • How do I add Show Fonts in the upper left corner of the viewer in iMovie if it is not there

    How do I add Show fonts in the upper left corner of the viewer if they do not exist?

    Hi
    You must have a Text inserted one way or the other.
    then click on the Text clip box
    and now it's there.
    You have Advance tools turned on ?
    Yours Bengt W

  • Hp 310-1020 gets a very hot screen on the upper left corner. Can this be fixed? If so, how?

    The screen on my HP touch screen model 310-1020 gets very hot , especially in the upper left corner.  Can this be fixed?  If so, how?  Please help.  Thanks,  Wayne

    Hello @wallen,
    Welcome to the HP Forums, I hope you enjoy your experience! To help you get the most out of the HP Forums I would like to direct your attention to the HP Forums Guide First Time Here? Learn How to Post and More.
    I have read your post on how the screen of your Touch Smart computer begins to heat up in a specific corner, and I would be happy to assist you in this matter!
    To reduce the heat being produced by your computer, I recommend following this resource on Reducing heat inside the PC to prevent overheating.
    If the issue persists, please call our technical support at 800-474-6836. If you live outside the US/Canada Region, please click the link below to get the support number for your region.
    http://www8.hp.com/us/en/contact-hp/ww-phone-assist.html
    I hope this helps!
    Regards
    MechPilot
    I work on behalf of HP
    Please click “Accept as Solution ” if you feel my post solved your issue, it will help others find the solution.
    Click the “Kudos, Thumbs Up" on the right to say “Thanks” for helping!

  • On the most upper left of the Title Bar (the part where the x box is on the right side) where the Firefox icon should be (on the upper left corner) I have a printer icon instead. Why did that happen and how do I change it? Thanks for any help.

    On the most upper left of the Title Bar (the part where the x box is on the right side) where the Firefox icon should be (on the upper left corner) I have a printer icon instead. Why did that happen and how do I change it? Thanks for any help.

    I don't actually have an answer for you, but ditto on changing things that aren't broken. Drives me crazy!!

Maybe you are looking for