🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.swing
Article #11480

Re: Centering JFrame

#11480
From: Sjaak Wolfert
Date: Tue, 25 May 1999 00:00
25 lines
1303 bytes
Maybe this will work:

  Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
  Dimension frameSize = frame.getSize();
  if (frameSize.height > screenSize.height)
   frameSize.height = screenSize.height;
  if (frameSize.width > screenSize.width)
    frameSize.width = screenSize.width;
  frame.setLocation((screenSize.width - frameSize.width) / 2,
(screenSize.height - frameSize.height) / 2);
  frame.setVisible(true);

Sjaak Wolfert

Heiko Nolte wrote in message <7idgtk$s2j3@forums.borland.com>...
>I want to open a JFrame from an applet. Is it possible to center this frame
>relative to the absolute screen? The readeble location of the frame is
>unfortunately relative to it's parent container.
>
>If you know an answer, please help me,
>
>thanks,
>Heiko
>
>
Technical Details
Message-ID: <7ie5g2$sjn10@forums.borland.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <7idgtk$s2j3@forums.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 111d45,deac5b3d9b250652
X-Google-Attributes: gid111d45,public
From: "Sjaak Wolfert" <sjaak.wolfert@users.info.wau.nl>
Subject: Re: Centering JFrame
Date: 1999/05/25
Message-ID: <7ie5g2$sjn10@forums.borland.com>
X-Deja-AN: 481877270
References: <7idgtk$s2j3@forums.borland.com>
Organization: Another Netscape Collabra Server User
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3155.0
Newsgroups: borland.public.jbuilder.java.swing