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</>↗
Swing21 Nov 2008

How do I get or set the state of JCheckBox?

This simple example shows you how to get or set the state of a JCheckBox. The method to set the state is JCheckBox.setSelected(boolean) and the method for getting the state is JCheckBox.isSelected() which return a boolean value. package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class CheckBoxState extends JFrame { public CheckBoxState() throws HeadlessException { initialize(); […]

Wayan · 1 min read
SWING / NOTES</>↗
Swing19 Nov 2008

How do I create JCheckBox component?

This example demonstrate a various way to create JCheckBox component. Here you can also see how the handle an event when the checkbox is clicked by user. package org.kodejava.swing; import javax.swing.*; import java.awt.*; import java.util.Objects; public class CheckBoxDemoCreate extends JFrame { public CheckBoxDemoCreate() throws HeadlessException { initialize(); } private void initialize() { setSize(500, 500); setTitle("JCheckBox […]

Wayan · 2 min read
REFLECTION / NOTES</>↗
Reflection19 Nov 2008

How do I get modifiers of a class object?

package org.kodejava.lang.reflect; import java.lang.reflect.Modifier; public class ClassModifier { public static void main(String[] args) { getClassModifier(String.class); getClassModifier(TestA.class); getClassModifier(TestB.class); } private static void getClassModifier(Class<?> clazz) { int modifier = clazz.getModifiers(); // Return true if the integer argument includes the public modifier, // false otherwise. if (Modifier.isPublic(modifier)) { System.out.println(clazz.get...

Wayan · 2 min read
REFLECTION / NOTES</>↗
Reflection15 Nov 2008

How do I create object using Constructor object?

The example below using a constructor reflection to create a string object by calling String(String) and String(StringBuilder) constructors. package org.kodejava.lang.reflect; import java.lang.reflect.Constructor; import java.lang.reflect.InvocationTargetException; public class CreateObjectDemo { public static void main(String[] args) { Class<String> clazz = String.class; try { Constructor<String> constructor = clazz.getConstructor(String.class); String object = constructor.n...

Wayan · 1 min read
REFLECTION / NOTES</>↗
Reflection14 Nov 2008

How do I get constructors of a class object?

Below is an example that showing you how to get constructors of a class object. In the code below we get the constructors by calling the Class.getDeclaredConstructors() or the Class.getConstructor(Class[]) method. package org.kodejava.lang.reflect; import java.lang.reflect.Constructor; public class GetConstructors { public static void main(String[] args) { Class<String> clazz = String.class; // Get all declared constructors and […]

Wayan · 1 min read
REFLECTION / NOTES</>↗
Reflection13 Nov 2008

How do I get field of a class object and set or get its value?

A refection demo to get fields of a class’s object and set or get their values. package org.kodejava.lang.reflect; import java.util.Date; import java.lang.reflect.Field; public class GetSetFieldDemo { public static Date now; public Long id; public String name; public static void main(String[] args) { GetSetFieldDemo demo = new GetSetFieldDemo(); Class<? extends GetSetFieldDemo> clazz = demo.getClass(); try { […]

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.