REGEX / NOTES</>↗Regex31 Oct 2010
You can use subtraction to negate one or more nested character classes. This example creates a single character class that matches everything from a to z, except the vowels (‘a’, ‘i’, ‘u’, ‘e’, ‘o’). This can be written in a subtraction pattern as [a-z&&[^aiueo]]. package org.kodejava.regex; import java.util.regex.Matcher; import java.util.regex.Pattern; public class CharacterClassSubtractionDemo { public […]
REGEX / NOTES</>↗Regex30 Oct 2010
A character class in the context of regular expression is a set of characters enclosed within a square brackets "[]". It specifies the characters that will successfully match a single character from the given input. A simple class, the most basic form of character class, is formed simply by placing a set of characters side-by-side […]
REGEX / NOTES</>↗Regex30 Oct 2010
A negation class is a character class that begins with a ^ metacharacter which will exclude a set of defined characters within a square brackets. For example the negation class h[^ao]t in the example below match only the word hit and exclude the words hat and hot. package org.kodejava.regex; import java.util.regex.Matcher; import java.util.regex.Pattern; public class […]
REGEX / NOTES</>↗Regex30 Oct 2010
To define a character class that includes a range of values, put – metacharacter between the first and last character to be matched. For example [a-e]. You can also specify multiple ranges like this [a-zA-Z]. This will match any letter of the alphabet from a to z (lowercase) or A to Z (uppercase). In the […]
SWING / NOTES</>↗Swing27 Oct 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 / NOTES</>↗Swing27 Oct 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 […]