SWING / NOTES</>↗Swing21 Apr 2007
Closing a JFrame application can be done by setting the default close operation of the frame. There are some defined constants for the default operation. These constants defined in the javax.swing.WindowConstants interface include EXIT_ON_CLOSE, HIDE_ON_CLOSE, DO_NOTHING_ON_CLOSE and DISPOSE_ON_CLOSE. To exit an application we can set the default close operation to EXIT_ON_CLOSE, this option will call […]
CORE API / NOTES</>↗Core API16 Apr 2007
Varargs (variable arguments) is a new feature in Java 1.5 which allows us to pass multiple values in a single variable name when calling a method. Of course, it can be done easily using array but the varargs add another power to the language. The varargs can be created by using three periods (…) after […]
CORE API / NOTES</>↗Core API15 Apr 2007
Stack is an extension of the java.util.Vector class that provided a LIFO (last-in-first-out) data structure. This class provide the usual method such as push() and pop(). The peek method is used the get the top element of the stack without removing the item. package org.kodejava.util; import java.util.Stack; public class StackExample { public static void main(String[] […]
SERVLET / NOTES</>↗Servlet13 Apr 2007
package org.kodejava.servlet; import java.io.IOException; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @WebServlet(name = "CookieExpirationServlet", urlPatterns = "/cookie-expiration") public class CookieExpirationServlet extends HttpServlet { @Override protected void doGet(H...
CORE API / NOTES</>↗Core API11 Apr 2007
For instance, you have a collection of objects in an List object, and you want to do some logic based on the object’s class. This can easily be done using the instanceof operator. The operator returns true if an object is an instance of a specified class, if not it will return false. The instanceof […]
APPLET / NOTES</>↗Applet07 Apr 2007
By default, the applet will usually have a grey background when displayed in a web browser. If you want to change it then you can call the setBackground(java.awt.Color) method and choose the color you want. Defining the background color in the init() method will change the color as soon as the applet initialized. package org.kodejava.applet; […]