SWING / CATATAN</>↗Swing25 Okt 2010
To set the font and color of JTextArea we can use the setFont() and setForeground() methods of the JTextArea. To create a font we must define the font name, the font style and its size. For the colors we can uses the constant color values defined by the Color class. package org.kodejava.swing; import javax.swing.*; import […]
SWING / CATATAN</>↗Swing25 Okt 2010
The following example shows you how to set the property of the JTextArea so that it cannot be edited or modified. To make the JTextArea not editable call the setEditable() method and pass a false value as the parameter. package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class TextAreaNotEditable extends JPanel { public TextAreaNotEditable() { initializeUI(); […]
BASIC / CATATAN</>↗Basic25 Okt 2010
The only way you can access an object is through a reference variable. A reference variable is declared to be of a specific type and that type can never be changed. Reference variables can be declared as static variables, instance variables, method parameters, or local variables. A reference variable that is declared as final can’t […]
BASIC / CATATAN</>↗Basic25 Okt 2010
To check whether an object is of a particular type (class or interface type) you can use instanceof operator. The instanceof operator is used only for object reference variable. x instanceof y can be read as x is-a y. The instanceof returns true if the reference variable being tested is of the type being compared […]
SWING / CATATAN</>↗Swing25 Okt 2010
This example shows you how to create a simple JTextArea component in Java Swing application. First you’ll create an instance of JTextAread and passes the number of rows and columns. Next to add a scroll ability you can wrap the component inside a JScrollPane. package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class TextAreaDemo extends JPanel […]
BASIC / CATATAN</>↗Basic25 Okt 2010
Relational operators used to compare any combination of integers, floating-point numbers, or characters. The result of relational operators is always in a boolean value, true or false. It is mostly used in an if statement test. There are four relational operators in Java: > greater than >= greater than or equal to < less than […]