SWING / CATATAN</>↗Swing01 Okt 2008
This code snippet gives an example on how to get the JFrame of a component. In this example we try to get the JFrame from a button action listener event. To get the JFrame we utilize the SwingUtilities.getRoot() method and this will return the root component of the component tree in out small program below […]
SWING / CATATAN</>↗Swing30 Sep 2008
To disable the close operation on a JFrame, when user click the close icon on the JFrame, we can set the value of the default close operation to WindowConstants.DO_NOTHING_ON_CLOSE. package org.kodejava.swing; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.SwingUtilities; import javax.swing.WindowConstants; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.HeadlessException; public class DisableCloseButtonDemo extends JFrame { p...
CORE API / CATATAN</>↗Core API28 Sep 2008
This examples shows how to get a path name or location from where our class is loaded. package org.kodejava.lang; public class CodeSourceLocation { public static void main(String[] args) { CodeSourceLocation csl = new CodeSourceLocation(); csl.getCodeSourceLocation(); } private void getCodeSourceLocation() { // The location from where the class is loaded. System.out.println("Code source location: " + getClass().getProtectionDomain().getCodeSource().getLocation()); […]
CORE API / CATATAN</>↗Core API25 Sep 2008
In this example we use the String‘s class matches() methods to match a string to be a valid email address based on the given regex. This example also demonstrate the power of regular expression to validate an email address. Using regular expression makes it easier to validate data such as email address. After the code […]
JSP / CATATAN</>↗JSP24 Sep 2008
In this example you can learn how to include a JSP fragment into another JSP page. This is a common practice when creating a web application where we usually have a navigation section, the main content and the footer of a web page. Using the include directive make it simpler to maintain the fragment of […]
SERVLET / CATATAN</>↗Servlet22 Sep 2008
The configuration below gives us example how to define a welcome-files to our web application. The welcome file is default file to be loaded by a servlet container when we access a URL without telling which page to load. <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" version="4.0"> <welcome-file-list> <welcome-fi...