SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

SWING / NOTES</>↗
Swing23 Nov 2009

How do I change JTree default icons?

The program below demonstrate how to change the default icons of a JTree component. We can change tree icons of the component which are the closed icon, the open icon and the leaf icon. package org.kodejava.swing; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellRenderer; import java.awt.*; import java.util.Objects; public class JTreeChangeIcon extends JFrame { public JTreeChangeIcon() throws […]

Wayan · 2 min read
SWING / NOTES</>↗
Swing21 Nov 2009

How do I remove JTree default icons?

You can remove JTree default icons by modifying the tree cell renderer object. To get the cell renderer call the JTree.getCellRenderer() which will return a DefaultTreeCellRenderer object. Then you can remove the icon by setting a null value to the setLeafIcon(), setClosedIcon() and setOpenIcon(). package org.kodejava.swing; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.DefaultTreeCellRenderer; import java.awt.*; public […]

Wayan · 2 min read
CORE API / NOTES</>↗
Core API17 Nov 2009

How do I sort LinkedList elements?

To sort the elements of LinkedList we can use the Collections.sort(List<T> list) static methods. The default order of the sorting is a descending order. package org.kodejava.util; import java.util.LinkedList; import java.util.Collections; public class LinkedListSort { public static void main(String[] args) { LinkedList<String> grades = new LinkedList<>(); grades.add("E"); grades.add("C"); grades.add("A"); grades.add("F"); grades.add("B"); grades.add("D"); System.out.println("...

Wayan · 1 min read
CORE API / NOTES</>↗
Core API16 Nov 2009

How do I get the first and the last element of a LinkedList?

The get the first element we can use the LinkedList.getFirst() method and to get the last element we can use the LinkedList.getLast() method. package org.kodejava.util; import java.util.LinkedList; public class LinkedListGetFirstLast { public static void main(String[] args) { LinkedList<String> names = new LinkedList<>(); names.add("Alice"); names.add("Bob"); names.add("Carol"); names.add("Mallory"); // Get the first and the last element of […]

Wayan · 1 min read
CORE API / NOTES</>↗
Core API15 Nov 2009

How do I reverse the order of LinkedList elements?

To reverse the order of LinkedList elements we can use the reverse(List<?> list) static method of java.util.Collections class. Here is the example: package org.kodejava.util; import java.util.LinkedList; import java.util.Collections; public class LinkedListReverseOrder { public static void main(String[] args) { LinkedList<String> grades = new LinkedList<>(); grades.add("A"); grades.add("B"); grades.add("C"); grades.add("D"); grades.add("E"); grades.add("F"); System.out.printl...

Wayan · 1 min read
CORE API / NOTES</>↗
Core API11 Nov 2009

How do I remove an item from LinkedList?

This program shows you how to use the remove(int index) method of LinkedList class to remove an item at specified index from linked list object. package org.kodejava.util; import java.util.LinkedList; public class LinkedListRemove { public static void main(String[] args) { LinkedList<String> names = new LinkedList<>(); names.add("Alice"); names.add("Bob"); names.add("Carol"); names.add("Mallory"); System.out.println("Original values are:"); System.out.println("===============...

Wayan · 1 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.