Page 1
Index
See this article in english  Ver este artículo en español 
Page 2
Convertir en palabras un número

Getting the screen size in Java

Alexander Hristov

The java.awt.Toolkit acts as a bridge between the OS and Java, centralizing all OS-dependant graphics operations, so that in the same runtime environment may coexist different implementations of the OS/Java boundary. The Toolkit class itself is abstract - the concrete descendents handle the implementation details. We can get the current Toolkit implementation using the getDefaultToolkit() static method

One of the method defined in the class is the getScreenSize() method, that allows us to retrieve the screen size.

 

Dimensiones.java
 
import java.awt.Toolkit;
import java.awt.Dimension;


public class Dimensiones {
  public static void main(String[] args) {
    Toolkit tk = Toolkit.getDefaultToolkit();
    Dimension tama?o = tk.getScreenSize();
    System.out.println("La pantalla es de " + tama?o.getWidth() + 
      " x " + tama?o.getHeight() );
  }
}
 


 

Comments

May 31, 2008 at 17:46 Sent by Carlos Ortega
todo ok esta muy buieno ............bye bye
Dec 05, 2007 at 03:12 Sent by anonymous
gracias papa!
Jul 10, 2007 at 12:44 Sent by May
muy muy util!! Gracias
Jun 07, 2007 at 19:16 Sent by William
muy util
Apr 20, 2007 at 10:14 Sent by anonymous
Excelente

 

Add a Comment

Name (optional)
EMail (optional, will not be displayed)

Text