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.

REFLECTION / NOTES</>↗
Reflection13 Nov 2008

How do I get fields of a class object?

The example below using reflection to obtain the fields of a class object. We’ll get the field names and their corresponding type. There are three ways shown below which can be used to get an object fields: Class.getDeclaredFields() Class.getFields() Class.getField(String) package org.kodejava.lang.reflect; import java.util.Date; import java.lang.reflect.Field; public class GetFields { public Long id; protected String […]

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

How do I invoke a method using Method class?

This example demonstrate using reflection to invoke methods of a class object. Using reflection we can call method of an object using the given string name of the method. When using this method we need to catch for the NoSuchMethodException, IllegalAccessException and InvocationTargetException. package org.kodejava.lang.reflect; import java.lang.reflect.Method; import java.lang.reflect.InvocationTargetException; public class InvokingMethod { public static […]

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

How do I get the methods of a class object?

In this example we show you how to get the methods available in a class object. We show three ways to get the methods, they are: Class.getDeclaredMethods() Class.getMethods() Class.getMethod(String, Class<?>…) package org.kodejava.lang.reflect; import java.lang.reflect.Method; public class GetMethods { public static void main(String[] args) { GetMethods object = new GetMethods(); Class<? extends GetMethods> clazz = object.getClass(); […]

Wayan · 2 min read
SWING / NOTES</>↗
Swing05 Nov 2008

How do I associate JLabel component with a JTextField?

In this example we associate a JLabel component with JTextField and JPasswordField using the setLabelFor(). A mnemonic need to be set for the JLabel component and when we press the defined key (ALT + U or ALT + P) a text field will be gained focus. package org.kodejava.swing; import javax.swing.*; import java.awt.*; import java.awt.event.KeyEvent; public […]

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

How do I create JLabel with an image icon?

To create a JLabel with an image icon we can either pass an ImageIcon as a second parameter to the JLabel constructor or use the JLabel.setIcon() method to set the icon. package org.kodejava.swing; import javax.swing.*; import java.awt.*; import java.util.Objects; public class JLabelWithIcon extends JFrame { public JLabelWithIcon() throws HeadlessException { initialize(); } private void initialize() […]

Wayan · 1 min read
SWING / NOTES</>↗
Swing30 Oct 2008

How do I create JLabel component?

package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class JLabelDemo extends JFrame { public JLabelDemo() throws HeadlessException { initialize(); } private void initialize() { setSize(150, 300); setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); setLayout(new FlowLayout()); // Create some JLabel with Texts and define the horizontal alignment JLabel label1 = new JLabel("Username :", JLabel.RIGHT); JLabel label2 = new JLabel("Password :", JLabel.R...

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.