Ruang penulis
SEBUAH JURNAL TENTANG TEKNOLOGI

Belajar hal baru.
Tulis. Bagikan.

Ruang untuk merangkai pengetahuan, satu baris kode setiap hari.
Temukan tutorial, ide, dan catatan dari perjalanan belajar.

1914 catatan & terus bertumbuh
PILIHAN EDITOR
Java

Memahami Java Stream: olah koleksi dengan lebih ringkas

Pelajari alur filter, map, dan collect untuk mengolah data Java dengan kode yang mudah dibaca.

D Tim Diary Coding · 1 menit baca
UNTUK RASA INGIN TAHUMU

Catatan terbaru.

SWING / CATATAN</>
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 menit baca
SWING / CATATAN</>
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 menit baca
SWING / CATATAN</>
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 menit baca
SWING / CATATAN</>
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 menit baca
CORE API / CATATAN</>
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 menit baca
CORE API / CATATAN</>
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 menit baca

Pengetahuan tumbuh ketika dibagikan.

Simpan rasa ingin tahu. Selalu ada hal baru untuk dipelajari.

Jelajahi catatan ↗
Putu Adi Guna Permana
TENTANG PENULIS

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

Penulis dan pendiri Diary Coding — berbagi catatan, tutorial, dan pengalaman seputar pemrograman untuk siapa pun yang ingin terus belajar.