CORE API / CATATAN</>↗Core API25 Apr 2007
package org.kodejava.util; import java.util.LinkedList; import java.util.Queue; public class QueueDemo { public static void main(String[] args) { // Create an instance of a queue, ere we use the LinkedList class which // implements the Queue interface. Add some elements to the queue using // the offer method. Queue<String> queue = new LinkedList<>(); queue.offer("First visitor"); queue.offer("Second visitor"); […]
SWING / CATATAN</>↗Swing21 Apr 2007
Here you will see how to handle the window closing event of a JFrame. What you need to do is to implement a java.awt.event.WindowListener interface and call the frame addWindowListener() method to add the listener to the frame instance. To handle the closing event implements the windowClosing() method of the interface. Instead of implementing the […]
SWING / CATATAN</>↗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 / CATATAN</>↗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 / CATATAN</>↗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 / CATATAN</>↗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...