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.

SPRING JDBC / NOTES</>↗
Spring JDBC15 Dec 2009

How do I create a Data Source object for JdbcTemplate?

In this example you will learn how to create and configure a DriverManagerDataSource object that will be used by the JdbcTemplate object. There are some information required when creating a DataSource including the JDBC driver class, the JDBC Url of the target database, the username and password for connecting to database server. package org.kodejava.spring.jdbc; import […]

Wayan · 2 min read
APACHE COMMONS / NOTES</>↗
Apache Commons11 Dec 2009

How do I read a file into byte array using Apache Commons IO?

The following example shows you how to read file contents into byte array. We use the IOUtils class of the Apache Commons IO library. package org.kodejava.commons.io; import org.apache.commons.io.IOUtils; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; public class FileToByteArray { public static void main(String[] args) { File file = new File("README.md"); try { InputStream is […]

Wayan · 1 min read
SWING / NOTES</>↗
Swing07 Dec 2009

How do I create JTree with different icons for each node?

The example below demonstrates you how to create a JTree that have a different icons for each node of the tree. package org.kodejava.swing; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreeCellRenderer; import java.awt.*; import java.net.URL; public class JTreeDifferentNodeIcon extends JFrame { public JTreeDifferentNodeIcon() throws HeadlessException { initializeUI(); } public static void main(String[] args) { SwingUtilities.in...

Wayan · 3 min read
SWING / NOTES</>↗
Swing04 Dec 2009

How do I expand or collapse all JTree nodes?

This example demonstrates how to use the expand-all and / or collapse-all features in the java.swing.JTree swing component. package org.kodejava.swing; import javax.swing.*; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.tree.TreePath; import javax.swing.tree.TreeNode; import java.awt.*; import java.util.Enumeration; public class JTreeNodeAutoExpandCollapse extends JFrame { public JTreeNodeAutoExpandCollapse() throws HeadlessException { initializeUI(); } p...

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

How do I remove a node from JTree?

The code below demonstrates how to delete a node from a JTree component. package org.kodejava.swing; import javax.swing.*; import javax.swing.tree.*; import java.awt.*; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; public class JTreeRemoveNode extends JFrame { public JTreeRemoveNode() throws HeadlessException { initializeUI(); } public static void main(String[] args) { SwingUtilities.invokeLater(() -> new JTreeRemoveNode().setVisible(true)); } priva...

Wayan · 1 min read
SWING / NOTES</>↗
Swing25 Nov 2009

How do I get the selected nodes of a JTree?

The following example show how to use the JTree.getSelectionPaths() method to get the selected node of a JTree component. This method returns an array of TreePath objects. In the case to get the last node in the path we can call the TreePath.getLastPathComponent(). In the code below when you pressed the button the listener gets […]

Wayan · 2 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.