Article View: es.comp.lenguajes.java
Article #28717Re: Dimensiones de un frame
From: Jonathan Revusky
Date: Sun, 22 Mar 1998 00:00
Date: Sun, 22 Mar 1998 00:00
36 lines
1416 bytes
1416 bytes
Jose Alvarez wrote:
>
> Hola,
> ?como puedo averiguar el tamaοΏ½o adecuado de un frame para que se visualize sin
> que queden botones o textfields fuera de la pantalla?
Todo eso es la idea de los LayoutManger.
Si fijas un LayoutManager en un Frame, digamos, el FlowLayout
por ejemplo, haces algo como:
Frame frame = new Frame("Mi Frame");
frame.setLayout(new FlowLayout());
frame.add(new Button("Primer boton"));
frame.add(new Button("Segundo boton"));
frame.add(new TextField("Algun Texto"));
frame.pack(); <<-- Esto fija el frame a su preferredSize
basado en el Layout.
frame.setVisible(true);
De hecho frame.pack() hace lo mismo
que
frame.setSize(frame.getPreferredSize());
seguido por
frame.validate();
Asi es imposible que algun boton o textfield quede fuera...
Espero que eso ayude.
Jonathan Revusky
Technical Details
Message-ID:
<35145300.F196DCFC@jet.es>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<6euv36$jdi$1@diana.bcn.ibernet.es>Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII X-Google-Thread: 1116f3,309c115a4e23a574 X-Google-Attributes: gid1116f3,public From: Jonathan Revusky <jrevusky@jet.es> Subject: Re: Dimensiones de un frame Date: 1998/03/22 Message-ID: <35145300.F196DCFC@jet.es> X-Deja-AN: 336392071 Content-Transfer-Encoding: 8bit References: <6euv36$jdi$1@diana.bcn.ibernet.es> Content-Type: text/plain; charset=iso-8859-1 Organization: Unisource Espana NEWS SERVER Mime-Version: 1.0 Reply-To: jrevusky@bigfoot.com Newsgroups: es.comp.lenguajes.java