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.......

Similar Messages

  • How do i redeem exactly 33 cents in the US itunes store?

    how do i redeem exactly 33 cents in the US itunes store?

    You don't.
    Contact itunes support and ask them to remove it

  • Place the JFrame on middle of the screen

    I want to place a JFrame on middle of the screen on any resolution. Using setBounds not work for all, I need a relative way to do this. What's the easiest way to do this?

    I've read the doc lol. But unable to find the best, that's why I ask here.
    setLocationRelativeTo() not set the frame in the middle of the screen, it's set the upper left corner of the frame into the middle.

  • Registering with the WebEx Data Center and the Cisco WebEx Node Management System

    Dear guys, ...
    Please help,
    i want to implement to webex node ASR1000, i have read in "Configuring the Cisco Webex Node for ASR 100.pdf", there is prerequisites to implement it, that is "Registering with the WebEx Data Center and the Cisco WebEx Node Management System"
    Can someone tell how to "Registering with the WebEx Data Center and the Cisco WebEx Node Management System"
    Are there any step by step documentation to "Registering with the WebEx Data Center and the Cisco WebEx Node Management System"?
    Thank you
    BR

    You should have received a PAK Key with your order.  Go to Cisco licensing and enter the PAK Key as this will start the process.  Once the PAK Key is validated a screen will be displayed to enter your request for ASR 100 integration.  It normally takes a few days to a couple of weeks to get the information back from WebEx needed to configure your ASR.
    If you did not get a PAK Key contact your WebEx rep to get the process started to integrate your ASR to your WebEx site.
    Hope this helps
    John

  • My mac book was refused by the apple service center as the mother board was crashed , pls help me what to do

    my mac book was refused by the apple service center as the mother board was crashed , pls help me what to do

    If you live in a big city, then I would recommend an independent computer store that fixes Macs. There are many mom and pop computer stores that fix your computer. Just Google it.

  • How to place a table of contents at the end of a document?

    I know how to design a table of contents at the beginning of a Pages document.
    I'd like to place a table of contents at the end of a long Pages book.
    Is there any simple trick to place a table of contents at the end of a Pages document?
    <pre>--------
    As long as you'll see students making graphics with pen on paper,
    you'll see the missing keystone of the software empire.
    dan</pre>

    fruhulda wrote:
    The Table of Contents (TOC) has to be in front of the Chapters it create a TOC from. There is a work around this, but do it first after you have finished the document because you'll loose the automatic update of the TOC.
    Thank you for your attempt to help.
    With TextEdit I loose the formatting of the TOC.
    I found another workaround, I made a printing of the TOC and saved it
    as PDF and included it within an empty page. But this method isn't
    really a simple workaround.
    The conclusion is that there isn't any easy way to place a TOC
    where you want.
    <pre>--------
    As long as you'll see students making graphics with pen on paper,
    you'll see the missing keystone of the software empire.
    dan</pre>

  • How to place a background image, so that the text layer, without having to use a text box

    Hello,
    I have a problem with the placement of the background image. When I normally formatted text on a page and add the image you want on the background of the text and the handle on the back is still image over text, just no longer responds to wrap text.
    The second problem is adding a new page to the document. I have unfinished document and I need to add a page before the current ... how?
    This is a new Pages.
    Thanks for the advice

    Helps to know exactly what version of Pages you are using.
    I assume Pages 5.1. But the last post makes me wonder.
    Text Wrap only works on text under an object. Either it is in front causing text wrap or it is in the background with none. It is unclear what you are trying to achieve.
    Click at the very beginning of your text:
    Insert > Section Break/Page Break
    Peter

  • How to unregister an unavailable control center in the design repository?

    We are using OWB 11.1. and we have 8 control centers which are registered in the design repository but these control centers have become unavailable. Is there any way to unregister control centers which are inaccessible?

    Thanks for the response.
    There is no problem to unregister locations which have become unavailable. We've used wb_env_util.unregister_location, which works quite well. By the way the script owb/misc/unregister_location.sql does not work any more if your using OWB 11.1. But our problem are the control centers which are pysically gone. We have unregistered all locations which were somehow associated with these control centers, but still we can't modify or delete them. For example if I try to rename one of these control centers using OMB I get the following error message: "OMB06316: Cannot modify any properties of a registered contol center except the password".

  • How to create a jframe which has only the close button

    hi
    i want to create a jframe which hold only the close button on the title bar. just like an JOptionPane.
    hussain52

    Well, if you are in a window's environment and using forte, you can go to sample forms, MDI, and then just highlight and delete what you don't want from the menubar.

  • Scroll to the right and center on the player

    I'm making a platform game. My game level is very large and I'd like to make the gameLevel scroll when the player is walking.
    So far it's scrolling, but the scrolling speed is not fast enough and when the player is walking to the right, he goes out of the screen.
    Do you know how I can speed up the scrolling in order to prevent the character to exceed the middle of the screen ?
    Here's my code for the scrolling screen :
    public function scrollWithHero() {
       var stagePosition:Number = gamelevel.x+hero.mc.x;
       var rightEdge:Number = 400-edgeDistance;
       var leftEdge:Number = edgeDistance;
       if (stagePosition > rightEdge) {
      gamelevel.x -= (stagePosition-rightEdge);
       if (gamelevel.x < -(gamelevel.width-stage.stageWidth)) gamelevel.x = -(gamelevel.width-stage.stageWidth);
       if (stagePosition < leftEdge) {
      gamelevel.x += (leftEdge-stagePosition);
       if (gamelevel.x > 0) gamelevel.x = 0;
    I could put something like this
    if (hero.mc.x > 300){
    //What should I put here ?
    (x=300 is the position of my player when he is in the center of the screen)
    Thank you for your help

    it looks like you want easing so scrolling slows as stagePosition nears an edge.  if so, you can use:
    var speed:Number = something between 0 and 1 (closer to 1 is slower, closer to 0 is faster)
    gamelevel.x = speed*gamelevel.x+(1-speed)*an edge;

  • How to place a "file save" icon in the tool bar?

    I have been using Pages for a while but I still find it hard to save a file without having to go to the File menu and saving it. Wouldnt it be nice if there was an icon to be clicked on to do that instead?

    Question already asked and answered several times.
    This feature is unavailable in version for 10.4.11, 10.5.8 and 10.6.8 so, happily, no hope to get it four 10.7.
    Under 10.7, the system AutoSave .
    If your document was just created from a template, you must start the process thru the 'universal' well known cmd + s command.
    Yvan KOENIG (VALLAURIS, France) mercredi 27 juillet 2011 15:05:15
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8 and 10.7.0
    Please :
    Search for questions similar to your own
    before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • Do you know how to place "enter by user name" to initial screen of fb03?

    Hello,
        When we enter fb03 display finance document, and click "header" button, I can see the "entery by username". But we want the "enter by name" display in the initial screen of fb03.
       Is anyone can suggest how to make it?
    Thanks,
    Li Jing

    Hi,
    In FB03, first you need to navigate to the Document list and from there you can choose the use name in the dynamic selection. The user name will not come in the initial screen of FB03.
    Alternatively, you can create a selection screen program which will have use name on the selection screen alongwith other fields and then pass on this selection details to the program RFBUEB00 selection data. Your ABAPer can do it for you.
    Regards,
    Gaurav

  • How to print the JFrame In The Center Of The Page?

    hi there in the following code iam trying to print a JFrame
    but the frame appear in the printed page at the top left
    and i want it to appear in the top center of the page
    how to do that?
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.awt.print.*;
    class PrintUIWindow implements Printable, ActionListener {
        JFrame frameToPrint;
        public int print(Graphics g, PageFormat pf, int page) throws
                                                            PrinterException {
            if (page > 0) {
                return NO_SUCH_PAGE;
            Graphics2D g2d = (Graphics2D)g;
            g2d.translate(pf.getImageableX(), pf.getImageableY()-55);
            frameToPrint.print(g);
            return PAGE_EXISTS;
        public void actionPerformed(ActionEvent e) {
             PrinterJob job = PrinterJob.getPrinterJob();
             job.setPrintable(this);
             boolean ok = job.printDialog();
             if (ok) {
                 try {
                      job.print();
                 } catch (PrinterException ex) {
        public PrintUIWindow(JFrame f) {
            frameToPrint = f;
        public static void main(String args[]) {
            UIManager.put("swing.boldMetal", Boolean.FALSE);
            JFrame f = new JFrame("Print UI Example");
            f.addWindowListener(new WindowAdapter() {
               public void windowClosing(WindowEvent e) {System.exit(0);}
            JLabel label1=new JLabel("Selling Bill",JLabel.CENTER);
            JLabel label2=new JLabel("Customer Name :Mahmoud Saleh       ",JLabel.LEFT);
            JLabel label3=new JLabel("Buying Date :29/8/2008             ",JLabel.LEFT);
            JLabel label4=new JLabel("Book Buyed :Java Printing          ",JLabel.LEFT);
            JLabel label5=new JLabel("Number : 6 Copies                  ",JLabel.LEFT);
            JLabel label6=new JLabel("Total Price :600 $                 ",JLabel.LEFT);
            label1.setFont(new Font("Courier New", Font.BOLD, 13));
            label2.setFont(new Font("Courier New", Font.BOLD, 13));
            label3.setFont(new Font("Courier New", Font.BOLD, 13));
            label4.setFont(new Font("Courier New", Font.BOLD, 13));
            label5.setFont(new Font("Courier New", Font.BOLD, 13));
            label6.setFont(new Font("Courier New", Font.BOLD, 13));
            JButton printButton = new JButton("Print This Window");
            printButton.addActionListener(new PrintUIWindow(f));               
            JPanel panel=new JPanel();
            panel.setLayout(new GridLayout(6,1));
            panel.add(label1);
            panel.add(label2);
            panel.add(label3);
            panel.add(label4);
            panel.add(label5);
            panel.add(label6);
            f.setSize(300,300);       
            f.setLocationRelativeTo(null);       
            f.add(panel,BorderLayout.CENTER);
            f.add(printButton,BorderLayout.SOUTH);
            panel.setBackground(Color.WHITE);
            f.setResizable(false);
            f.setVisible(true);
    }

    First_knight wrote:
    please tell me am i thinking right
    about this method: setImageableArea(.....)
    public void setImageableArea(double x, double y,  double width, double height);
    like I said, I've tried this method and it doesn't seem to do anything.
    the width=the JFrame Width,the height=the JFrame Height right?actually, when printing, 72 points (printing version of pixels) = 1 inch, so to do WYSIWYG, you need width = JFrameWidth * 72.0 / Toolkit.getToolkit().getScreenResolution. Ditto with height
    upper left beginningx(0)---------------------------200--------------------------------600-----------------------------------y(1000)upper right beginningyou need to do something like PageSetup.getImageableX and do Graphics.translate(x,y);
    also, if your page width = 720, that = 10 inches - that's a wide page (unless its in landscape)
    so if i want the JFrame To Be In The Center Of The Page I Would Choose From x=200 ,y=600 depending that frame width is 400Actually, it would be 300 - 700 in your example
    Because when i tried to use:setImageableArea(200, 600,  400, 200);like the above code
    no changes occurs in the printed paperYes. You need to offset the Graphics object

  • How to resize the components in a JFrame when the JFrame Resizes?

    Hi all,
    i have some problems with my app. I have set the JFrame resizable and that works fine for the JFrame but not for the components in the JFrame.
    So my question is how can i set the components in a JFrame to resize automatically when the JFrame resizes?
    Here are the important things from my code,...if you need more, just let me know, its my first post in a forum .
    Its a JFrame with a JTabbedPane and on the Tabs are Panels with buttons and Tables.
    Thank you in advance!
    public class MainMonitor extends JFrame {
    public MainMonitor() {
              super();
              initialize();
              setVisible(true);
         private void initialize() {
              this.setSize(1145, 785);
              this.setIconImage(Toolkit.getDefaultToolkit().getImage("Images/c.gif"));
              this.setContentPane(getJContentPane());
              this.setTitle("Company Manager");
              this.setResizable(true);
              this.setLocationRelativeTo(null);
         private JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new JPanel();
                   jContentPane.setLayout(null);
                   jContentPane.setOpaque(true);
                   jContentPane.add(getJTabbedPane(), null);
                   jContentPane.add(getJPanel11(), null);
              return jContentPane;
         private JTabbedPane getJTabbedPane() {
              if (jTabbedPane == null) {
                   jTabbedPane = new JTabbedPane();
                   jTabbedPane.setLocation(new Point(6, 69));
                   jTabbedPane.setSize(new Dimension(1120, 684));
                   jTabbedPane.addTab("P", null, getJPanel(), null);
                   jTabbedPane.addTab("K", null, getJPanel1(), null);
                   jTabbedPane.addTab("B", null, getJPanel2(), null);
              return jTabbedPane;
         

    Giasaste wrote:
    Thanks a lot, i didnt knew that the Layout Manager is a must.It's not a must, but it is the way to allow your app to be resized nicely and makes it much easier to maintain and enhance your program. Imagine creating a complex gui then later decide that you want another radiobutton and to remove a jlabel / jtextfield pair. with layout managers a chore becomes easy.

  • 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

Maybe you are looking for