AWT / CATATAN</>↗AWT09 Mei 2009
MouseInfo provides methods for getting information about the mouse, such as mouse pointer location and the number of mouse buttons. package org.kodejava.awt; import java.awt.*; public class MouseInfoDemo { public static void main(String[] args) { int i = 0; while (i < 10) { // Get the location of our mouse x and y coordinate using […]
AWT / CATATAN</>↗AWT17 Apr 2009
This example shows graphics devices display mode information such as the display width, height, refresh-rate and bit-depth. This information can be obtained from GraphicsDevice.getDisplayMode() method which return an instance of java.awt.DisplayMode. We can also get the size of a screen using the following example How do I get my screen size?, but this example can […]
AWT / CATATAN</>↗AWT14 Apr 2009
This code shows how to get number of available screen devices on the local machine or local graphics environment. We obtain the number of screens by getting the length of array returned by GraphicsEnvironment.getScreenDevices() method. This process can produce a HeadlessException to happen if we try to run this code on a machine that doesn’t […]
AWT / CATATAN</>↗AWT06 Feb 2008
In this example we are automating the process of creating mouse event using the java.awt.Robot class. package org.kodejava.awt; import java.awt.AWTException; import java.awt.Robot; import java.awt.event.InputEvent; public class MovingMouseDemo { public static void main(String[] args) { try { Robot robot = new Robot(); // Move mouse cursor to 200, 500 robot.mouseMove(200, 500); // Press the mouse button […]
AWT / CATATAN</>↗AWT05 Feb 2008
The example here show us how to get the color of a pixel in the screen. We use the Robot.getPixelColor(int x, int y) method to obtain the Color of the pixel. package org.kodejava.awt; import java.awt.Color; import java.awt.Robot; import java.awt.AWTException; public class ColorPickerDemo { public static void main(String[] args) { try { Robot robot = new […]
AWT / CATATAN</>↗AWT04 Feb 2008
In this example we use the java.awt.Robot class to generate a key press event. We can call the keyPress(int keyCode) method to produce this event. package org.kodejava.awt; import java.awt.AWTException; import java.awt.Robot; import java.awt.event.KeyEvent; public class CreatingKeyboardEvent { public static void main(String[] args) { try { Robot robot = new Robot(); // Create a three seconds […]