SWING / CATATAN</>↗Swing12 Nov 2010
Selecting all text in the JTextArea component can be done by using the selectAll() method. In the example below we use a button action to do the selection. After select the text we transfer focus back to the JTextArea so that the highlighted text is shown. package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class TextAreaSelectAll […]
SWING / CATATAN</>↗Swing12 Nov 2010
To append text to the end of the JTextArea document we can use the append(String str) method. This method does nothing if the document is null or the string is null or empty. package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class TextAreaAppendText extends JPanel { public TextAreaAppendText() { initializeUI(); } public static void showFrame() { […]
SWING / CATATAN</>↗Swing12 Nov 2010
The insert(String str, int pos) of the JTextArea allows us to insert a text at the specified position. In the example below we insert brown and over words into the current JTextArea text. package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class TextAreaInsertText extends JPanel { public TextAreaInsertText() { initializeUI(); } public static void showFrame() { […]
SWING / CATATAN</>↗Swing12 Nov 2010
In this example you’ll see how to use the replaceRange(String str, int start, int end) method to replace a string in the JTextArea from the start position to the end position with the specified string. package org.kodejava.swing; import javax.swing.*; import java.awt.*; public class TextAreaReplaceText extends JPanel { public TextAreaReplaceText() { initializeUI(); } public static void […]
CORE API / CATATAN</>↗Core API07 Nov 2010
If you want a thread to work until another thread dies, you can join the thread onto the end of the another thread using the join() method. For example, you want thread B only work until thread A completes its work, then you want thread B to join thread A. package org.kodejava.example.lang; public class ThreadJoin […]
CORE API / CATATAN</>↗Core API07 Nov 2010
Threads always run with some priority, usually represented as a number between 1 and 10 (although in some cases the range is less than 10). A thread gets a default priority that is the priority of the thread of execution that creates it. But, you can also set a thread’s priority directly by calling the […]