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 […]
AWT / CATATAN</>↗AWT04 Feb 2008
In this example you’ll see how to create a screen capture / screenshot and save it as an image file such a PNG image. Some classes are use in this program including the java.awt.Robot, java.awt.image.BufferedImage and javax.imageio.ImageIO. package org.kodejava.awt; import javax.imageio.ImageIO; import java.awt.image.BufferedImage; import java.awt.AWTException; import java.awt.Dimension; import java.awt.Rectangle; import java.awt.Robot; import java.io.File; import java.io.IOE...
CORE API / CATATAN</>↗Core API04 Feb 2008
In this example you’ll see how we can convert a java.math.BigInteger number into another radix such as binary, octal and hexadecimal. package org.kodejava.math; import java.math.BigInteger; public class BigIntegerConversion { public static void main(String[] args) { BigInteger number = new BigInteger("2021"); System.out.println("Number = " + number); System.out.println("Binary = " + number.toString(2)); System.out.println("Octal = " + number.toString(8)); […]
CORE API / CATATAN</>↗Core API31 Jan 2008
package org.kodejava.math; import java.math.BigDecimal; import java.math.RoundingMode; public class BigDecimalOperation { public static void main(String[] args) { BigDecimal decimalA = new BigDecimal("98765432123456789"); BigDecimal decimalB = new BigDecimal("10"); decimalA = decimalA.add(decimalB); System.out.println("decimalA = " + decimalA); decimalA = decimalA.multiply(decimalB); System.out.println("decimalA = " + decimalA); decimalA = decimalA.subtract(decimalB); System....
CORE API / CATATAN</>↗Core API29 Jan 2008
package org.kodejava.math; import java.math.BigInteger; public class BigIntegerOperation { public static void main(String[] args) { BigInteger numberA = new BigInteger("98765432123456789"); BigInteger numberB = BigInteger.TEN; numberA = numberA.add(numberB); System.out.println("numberA = " + numberA); numberA = numberA.multiply(numberB); System.out.println("numberA = " + numberA); numberA = numberA.subtract(numberB); System.out.println("numberA = " + numberA); numberA = numbe...
CORE API / CATATAN</>↗Core API27 Jan 2008
package org.kodejava.lang; import java.util.Calendar; import java.math.BigDecimal; public class ClassName { public static void main(String[] args) { // Get the name of the classes below. Class<?> clazz = String.class; System.out.println("Class Name: " + clazz.getName()); clazz = Calendar.class; System.out.println("Class Name: " + clazz.getName()); clazz = BigDecimal.class; System.out.println("Class Name: " + clazz.getName()); } } The result of the […]