CORE API / NOTES</>↗Core API14 Oct 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 / NOTES</>↗Swing11 Oct 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 / NOTES</>↗Swing07 Oct 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 / NOTES</>↗Swing03 Oct 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 […]
BASIC / NOTES</>↗Basic29 Sep 2009
The remainder or modulus operator (%) let you get the remainder of a division of two numbers. This operator can be used to obtain a reminder of an integer or floating point types. package org.kodejava.basic; public class RemainderOperatorDemo { public static void main(String[] args) { int a = 10; double b = 49; // The […]
BASIC / NOTES</>↗Basic26 Sep 2009
The ternary operator or conditional operator can be use as a short version of the if-then-else statement. When you have a simple if-then-else statement in your code that return a value you might use the ternary operator, it can make your code easier to read. The ternary operator is written using the symbol of ?: […]