AWT / NOTES</>↗AWT11 May 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 MouseNumberOfButtons { public static void main(String[] args) { // Get the number of buttons on the mouse. On systems without a // mouse, returns -1. HeadlessException if // GraphicsEnvironment.isHeadless() […]
AWT / NOTES</>↗AWT09 May 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 […]
CORE API / NOTES</>↗Core API09 May 2009
package org.kodejava.lang; public class GetCurrentMethodName { public static void main(String[] args) { // Get the current executing method name String methodName = Thread.currentThread().getStackTrace()[1].getMethodName(); System.out.println("methodName = " + methodName); GetCurrentMethodName obj = new GetCurrentMethodName(); obj.executeAMethod(); } private void executeAMethod() { // Get the current executing method name String methodName = Thread.currentThread().getStackTra...
JDBC / NOTES</>↗JDBC05 May 2009
package org.kodejava.jdbc; import java.util.Date; public class UtilDateToSqlDate { public static void main(String[] args) { // Create a new instance of java.util.Date Date date = new Date(); // To covert java.util.Date to java.sql.Date we need to // create an instance of java.sql.Date and pass the long // value of java.util.Date as the parameter. java.sql.Date sqlDate = […]
JDOM / NOTES</>↗JDOM04 May 2009
The following example shows you how to remove attributes from an XML element. We will remove attribute named userid from the <row> element. To remove an attribute you can call the removeAttribute(String name) method of the Element object. package org.kodejava.jdom; import org.jdom2.Document; import org.jdom2.Element; import org.jdom2.input.SAXBuilder; import org.jdom2.output.Format; import org.jdom2.output.XMLOutputter; import java.io.File; public class JDOMRemoveAttribute […...
JDOM / NOTES</>↗JDOM03 May 2009
This example show you how to remove an element from XML document. In the code snippet below we start by loading an XML document and display its original contents. After that we find the element <row>, and remove the <address> element from it. To get the first child we are using the getChild() method from […]