SWING / CATATAN</>↗Swing27 Okt 2010
To set and get the contents of a JTextArea you can use the setText(String text) and getText() methods. In the code below we create a JTextArea and sets its contents after we create a new instance of JTextArea. To get the contents we use the action on a button. When the button is pressed the […]
SWING / CATATAN</>↗Swing27 Okt 2010
In this example you will be shown how to set or change the tab size for the JTextArea component. You can use the setTabSize(int size) to define the tab size. For this demo we create a combo box that have some integer values which will be used to define the tab size. When you change […]
BASIC / CATATAN</>↗Basic26 Okt 2010
The || operator or conditional OR operator operates on two boolean expressions. This operator exhibit “short-circuiting” behavior, which means that the second operand is evaluated only if needed. The || operator evaluate only boolean values. For an OR (||) expression it will return true if either of the operand is true. If the first operand […]
BASIC / CATATAN</>↗Basic26 Okt 2010
The ! operator is a logical compliment operator. The operator inverts the value of a boolean expression. package org.kodejava.basic; public class NegationOperator { public static void main(String[] args) { // negate the result of boolean expressions boolean negate = !(2 < 3); boolean value = !false; System.out.println("result: " + negate); System.out.println("value : " + value); […]
SWING / CATATAN</>↗Swing26 Okt 2010
To wrap the lines of JTextArea we need to call the setLineWrap(boolean wrap) method and pass a true boolean value as the parameter. The setWrapStyleWord(boolean word) method wrap the lines at word boundaries when we set it to true. package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class TextAreaWrapDemo extends JPanel { public TextAreaWrapDemo() { initializeUI(); […]
REGEX / CATATAN</>↗Regex26 Okt 2010
Finding the next subsequence of the input sequence that matches the pattern while ignoring the case of the string in regular expression can simply apply by create a pattern using compile(String regex, int flags) method and specifies a second argument with PATTERN.CASE_INSENSITIVE constant. package org.kodejava.regex; import java.util.regex.Pattern; import java.util.regex.Matcher; public class RegexIgnoreCaseDemo { public static […]