JPanel to be displayed center of the screen - GlassPane and JFrame

Hi,
I have a JFrame whereby I display a JPanel which has two buttons. When the JPanel is displayed, focus must be on the JPanel and user must select something on the JPanel before focus goes back to the JFrame. I've used a glassPane to do
which works correctly however, my JPanel is coming up at the top of the JFrame rather than in the middle. I've tried panel.setLocation but this doesn't seem to be working.
Hope you can help,
Thanks
some of the code:
JFrame myFrame = new JFrame();
JPanel glassPanel = new JPanel();
glassPanel.setOpaque(false);
JPanel confirmPanel = createNewConfirmPanel();
glassPanel.add(confirmPanel);
myFrame.setGlassPane(myFrame);
glassPanel.setVisible(true);
in createNewConfrimPanel() I call setLocation(x,y)

Thanks db.
Just doing some more debugging and my problem is in this class -
public class RoundedPanel extends JPanel {
public RoundedPanel(){
super();
public boolean isOpaque() {
return false;
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D) g;
Shape rect = new RoundRectangle2D.Float(0,0,getWidth()-5,getHeight()-5, 50,50);
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Paint paint = new GradientPaint(0,0,Color.white, 0,getHeight(), Color.lightGray);
g2.setPaint(paint);
g2.fill(rect);
g2.setColor(Color.black);
g2.draw(rect);
My panel extends RoundedPanel above. My problem is in paintComponent..I can't see where it is setting location.
Thanks

Similar Messages

  • Display result on center of the screen. Possible ?

    Hello Experts,
    I have created some output of string which displays result at runtime.
    I want to dispaly this string in the center of the screen.
    screen may be changable so my result should be display in center.
    Is it possible ?
    Please give me some idea.
    Thanks in advance.
    -rohan

    hi,
    u can use system variables SY-CUCOL AND SY-CUROW . u can get the system variables in Standard database table SYST.
    SY-CUCOL = 35.
    SY-CUROW = 35.
    WRITE: 'STRING'.
    if helpful reward some points.
    with regards,
    Suresh Aluri

  • HT201177 MY MACBOOK PRO IS SHOWN GREEN LINE IN THE CENTER OF THE SCREEN

    MY MACBOOK PRO IS SHOWN GREEN LINE IN THE CENTER OF THE SCREEN

    It is probably a display or display connector issue. To check this, take a screenshot of the display by pressing Command, Shift and 3 keys. Then, open the screenshot created in Desktop, and see if the line appears. If not, it is a display issue.
    If you have not got a MacBook Pro with Retina display, you can repair this yourself. You just need to look for the display connector of your MacBook Pro model in the Internet and install it, and if this does not work, you have to replace the whole display.
    However, if you do not know a lot about computers or your Mac is in warranty, you should take the Mac to an Apple Store or reseller to get it repaired

  • L220x: dead reddish pixel in center of the screen

    I bought this and another L220x 4 months ago from a lenovo reseller. Now there has appeared a slightly red-tinted dead pixel to center of the screen.
    Do you know whether this display has a warranty that covers it or whether I can get that dead pixel working again. I'd prefer the latter because I love this display and can't think of being without it.
    It's just a single dead pixel in the center of the screen, so it's not exactly bothering me with 2 million working ones around it except when I happen to spot it.
    I guess it's going to be more common with always increasing pixels per inch -counts.
    Btw. Your forum registration prompt is an usability nightmare. Why request so strong passwords anyway?

    welcome to the forum!
    unfortunately one suck subpixel isn't enough for warranty.   the pixel replacement policy for thinkvision displays can be found here.
    regarding passwords, i understand your point.   perhaps this is something we can explore changing in the future.
    ThinkStation C20
    ThinkPad X1C · X220 · X60T · s30 · 600

  • Deskptop is compressed to a 6 inch strip in the center of the screen

    it is an Apple Studio Display 21" CRT
    everything was fine with the display, came in one day and brought the computer out of sleep mode and the display was messed up. the deskptop is compressed to a 6 inch strip in the center of the screen with black bars on the left and right.

    Mission Control? It isn't a little bar in the center of the screen but does display the running apps. You can access it via the Control+Up arrow key combination and there are preferences for it in System Preferences.

  • New to Macs just purchased a 27-inch: 2.7GHz mac when I open e.g my company website or facebook it only displays centre of the screen How do I set it up show full screeen also the bar at the top is hard to read as so small can this be increased, ??

    Hi I need some help please as above I have just purchased my first mac 27" and as much I love it as a newbie im having some teething troubles, when say Facebook or my company website is displayed it is only displayed in the centre of the screen I know I can zoom in and out but that doesnt look great and dont want to have to that on each page display, how do i fix this please.
    Also the toolbar at the top of the page is so small and hard to read is there a way to increase and fix the size
    Thanks for your help

    For the browser window, just drag it to the top left of the screen (click and hold on the top bar with the traffic lights to drag), then in the bottom right of the window you'll see a rectangle with diagonal hatching. Click and hold on that and drag the window to the size you want.
    Clicking on the green dot at top left will expand the window to fit the screen, clicking it again will shrink it back to where it was (this doesn't work in Finder windows quite the same).
    The menu bar size is set in the bowels of the OS, though there may be third-party applications which can alter it.
    As it's size is relative to the screen resolution, you could try reducing the resolution in System Preferences > Displays to see if that would suit you better.

  • My MacBookPro has a white screen with a grey file folder in the center of the screen with a white question mark blinking in it. What does this mean?  And how can I get my computer back up and running normal?

    My MacBookPro has a white screen with a grey file folder in the center of the screen with a white question mark blinking in it. What does this mean?  And how can I get my computer back up and running normal?

    Start up in Safe Mode.
    http://support.apple.com/kb/PH14204?viewlocale=en_US
    Repair Disk.
    http://support.apple.com/kb/PH5836
    Reset PRAM.
       http://support.apple.com/kb/PH14222

  • After what seems to be a normal upgrade to the new Lion OS. My computer counted down to restart and left a white screen with only a file folder in the center of the screen with a ? in it. How do I get my screen back to normal? Jim L.

    After what seems to be a normal upgrade to the new Mountain Lion OS X on my early 2008, 24" iMac. My iMac counted down to restart but did not turn all the way off. At the end of the count down the screen went white with a small file folder flashing on and off in the center of the screen. Also there is a ?, question mark in the miaale of the file folder. The screen responds to no keyboard or mouse commands. Request help.

    My computer was doing the same as yours hinikuru but now there is a change. I turned my iMac off by the button on the back and left it off for about an hour. When I just turned it on the center Apple logo was back and soon the  loading logo for the new Mountain Lion program came up. On the bottom of the logo there is a horizontal sliding bar that says the program will take 34 minutes to load. Time will tell. I have two iMacs and if this goes we'll I will install the new Mountain  Lion tomorrow. Hinikuru, I was about to follow the information in one of the side bar blocks titled "More like this" on the right side of this screen when my iMac seemed to fix itself! Good luck. I think not all is lost.

  • How do I get alerts to remain in the center of the screen after unlocking my iPhone in iOS 7?

    The whole point of alerts, according to Apple, is to let you know about important events by remaining in the center of the screen until you acknowledge them. So why, when my iPhone 4s is locked and I receive an alert, does absolutely nothing appear when I unlock my phone? I use OmniFocus2 for everything, but the app isn't useful to me without forcing me to acknowledge the alerts I've set up for my to-do's. I've messed with all the notification options (like removing from lock screen), but I simply cannot believe that the only way Apple would allow their alerts to work properly is by forcing me to keep my phone from auto-locking indefinitely.
    Can anyone help?
    Jackie

    I just came from using a BlackBerry Z10 and just got a iphone 5S. I have to say that this is the most ridiculous issue i am having to deal with as well. I use a password for my lock screen and if im not constantly on my phone i will miss a text msg. theres nothing from the lock screen to show you of a missed text or etc and also i dont care that i can look at notifications pull down. that is useless for the common person who doesn't live on the phone. There's no led to help this issue another major negative for me and this issue as well. So pretty much if i dont check my phone periodically i will miss something for sure. Cant believe this phone is considered the flagship of phones, there are SIMPLE issues with iphones that many other company's have fixed YEARS ago. Seriously would a LED light really hurt that bad to put on?! Get a clue apple!
    --sorry for the rant but i have been looking everywhere online and trying many issues to fix this with no luck.

  • Making a Form appear on the center on the screen

    Hi
    How can i make a form in java to appear at the center of the screen no matter what the resolution of the scrren is .
    Thanks

    I know of 2 ways:
    1. [The clean way]
    http://forum.java.sun.com/thread.jsp?forum=57&thread=537866 EvilEdna's post {most thorough}
    OR
    http://forum.java.sun.com/thread.jsp?forum=31&thread=552229 My post (reply #1) {less thorough but still good}
    2. [The dirty way]
    frame.setLocationRelativeTo(null); {dirty!}

  • My Iphone 5(purchased in Jan 2013) has suddenly developed a multicolored hue in the center of the **** screen. it looks pathetic and totally whacked out. Its rainy and humid where I stay this time of the year. Apple guys are you reading this?

    my Iphone 5(purchased in Jan 2013) has suddenly developed a multicolored hue in the center of the **** screen. it looks pathetic and totally whacked out. Its rainy and humid where I stay this time of the year. Apple guys are you reading this? does the management go through this website.? Hey Apple guys, can you replace my phone for me.Its so slippery and slides out very easily from my hands. I have owned smartphones before but yours is a real slimy slider. so while I was shooting pics in varanasi in march it fell out of my palm (it was drizzling) and the rear screen (the section next to the camera) kinda cracked real ugly and obviously due to this the camera is behaving kinda crazy too. can you guys help me out here.?

    If your phone is defective (aside from the accidental damage) Apple will fix or replace the phone. You saud you purchased the phone in January so it is still under warranty. 
    If you have an Apple Store in your area, make a Genius Bar appointment.
    If not, Contact Apple Service Center:
    http://support.apple.com/kb/index?page=servicefaq&product=iphone

  • How to place the JFrame in center of the screen

    Hi.. please any one tell me how to place the jframe in the center of the screen.. i am working on windows.
    setLocationByPlotform is not working...

    //GETS SCREEN SIZE
            Dimension screen_Dimension =Toolkit.getDefaultToolkit ().getScreenSize ();
            //GETS WINDOWS SIZE
            Dimension frame_Dimension = window.getSize ();
            //PUTS FRAME IN THE "MIDDLE" OF THE SCREEN
            window.setLocation ( new Point (
                    (screen_Dimension.width / 2-frame_Dimension.width / 2),
                    (screen_Dimension.height / 2-frame_Dimension.height/ 2)));Not sure if you want the raw version of it.......

  • TS3623 When I download certain movies I get a black rectangle in the bottom center of the screen. How do I get rid of this?

    When I download movies, I get a small, black rectangle in the bottom center of the screen. This is irritating! How do I get rid of it?

    Search the forum.  This has been reported a few times. I do not recall what the fix is, but it has already been posted.

  • A conversion error occurred while the program -- display data on the screen

    HI all,
    Iam getting a dump error described below:
    A conversion error occurred while the program was trying to
    display data on the screen.
    The ABAP output field and the screen field may not have the
    same format.
    Some field types require more characters on the screen than
    in the ABAP program. For example, a date field on a screen needs
    two characters more than it would in the program. When attempting to
    display the date on the screen, an error will occur that triggers the
    error message.
                  Screen name.............. " Ztable_MM_MRQ "
                  Screen number............ 0100
                  Screen field............. "WA_PO_ITEMS-MENGE"
                  Error text............... "FX015: Sign lost."
    Further data:
    Give us step by step procedure to rectify the same with T.codes
    Thanks
    Regards
    Siraj

    Raymond
    please give details in se51 where i have to put a "V"  to allow negative amounts
    whether it is in Text or I/O templates
    name                                     type of screen element         Text or I/O field
    WA_PO_ITEMS-MENGE     Text                           PO_quantity__     
    regards

  • How do I get a Dialog to appear in the center of the screen?

    How do I get a Dialog to appear in the center of the screen?

    You can get the screen size by using Dimension java.awt.Toolkit.getScreenSize().
    Once you get the Dimension, Before using API setVisible(true), You have to do the calculations to put your dialog in the center.

Maybe you are looking for