CORE API / CATATAN</>↗Core API22 Okt 2009
This example show you how to use the ListIterator interface to iterate elements of a LinkedList. package org.kodejava.util; import java.util.List; import java.util.LinkedList; import java.util.ListIterator; public class LinkedListListIterator { public static void main(String[] args) { List<String> grades = new LinkedList<>(); grades.add("A"); grades.add("B"); grades.add("C"); grades.add("D"); grades.add("E"); // Retrieves object from LinkedList using the ListIterator // inter...
CORE API / CATATAN</>↗Core API18 Okt 2009
This example show you how to use the Iterator interface to iterate elements of a LinkedList. package org.kodejava.util; import java.util.List; import java.util.LinkedList; import java.util.Iterator; public class LinkedListIterator { public static void main(String[] args) { List<String> grades = new LinkedList<>(); grades.add("A"); grades.add("B"); grades.add("C"); grades.add("D"); grades.add("E"); // Iterates elements in LinkedList using Iterator. Iterator<String> iterator =...
CORE API / CATATAN</>↗Core API14 Okt 2009
A linked list is a fundamental data structure in programming. It can store data and a references to the next and/or to the previous node. There can be a singly linked list, a doubly linked list and a circularly linked list. The code below show you how to use the java.util.LinkedList class to create a […]
SWING / CATATAN</>↗Swing11 Okt 2009
This example shows you how to use the TreeSelectionListener to add a tree selection listener to the JTree component. In the listener method below you can see how to get the selected path and print out the selected path to the console. package org.kodejava.swing; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreePath; import java.awt.*; public class JTreeSelectionListenerDemo […]
SWING / CATATAN</>↗Swing07 Okt 2009
This example show you how to change the color of the selected node of the JTree component. It shows you how to set the node background color, the font color and the selected node border color. To do this you need to obtain the DefaultTreeCellRenderer object from the JTree instance and modified the selection color […]
SWING / CATATAN</>↗Swing03 Okt 2009
The example introduce you how to use the JTree swing component to create a presentation of hierarchical data. The hierarchical data can be viewed in expand mode or collapse mode. To create an item of the tree we create an instance of DefaultMutableTreeNode which located in the javax.swing.tree package. This class implements the TreeNode and […]