本文整理匯總了Java中org.eclipse.swt.custom.StyledText.getText方法的典型用法代碼示例。如果您正苦於以下問題:Java StyledText.getText方法的具體用法?Java StyledText.getText怎麽用?Java StyledText.getText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.swt.custom.StyledText
的用法示例。
在下文中一共展示了StyledText.getText方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: calculateStyleRanges
import org.eclipse.swt.custom.StyledText; //導入方法依賴的package包/類
/**
* From the given Vector of words calculate all StyleRanges using the Color and Font Style that is given.
*
* @param textField Textfield where the text is in
* @param words Words to be highlighted
* @param foreground Color of the text-foreground
* @param background Color of the text-background
* @param fontstyle Fontstyle for the highlighted words
* @param caseSensitive FALSE if the case of the word to highlight should be ignored
* @return Vector A Vector containing all calculated StyleRanges
*/
public static Vector calculateStyleRanges(StyledText textField, Vector words, Color foreground, Color background, int fontstyle, boolean caseSensitive) {
/* Use Vector for the StyleRanges */
Vector styleRanges = new Vector();
/* Text with words to style */
String text = textField.getText();
/* Regard case sensitivity */
if (!caseSensitive)
text = textField.getText().toLowerCase();
/* Foreach word to style */
for (Object word : words) {
int start = 0;
String curWord = (String) word;
/* ToLowerCase if case is regarded */
if (!caseSensitive)
curWord = curWord.toLowerCase();
/* Save current position */
int pos;
/* For each occurance of the word in the text */
while ((pos = text.indexOf(curWord, start)) > -1) {
/* New stylerange for the word */
StyleRange styleRange = new StyleRange();
styleRange.start = pos;
styleRange.length = (curWord.length());
styleRange.fontStyle = fontstyle;
styleRange.foreground = foreground;
styleRange.background = background;
styleRanges.add(styleRange);
/* Goto next words */
start = styleRange.start + styleRange.length;
}
}
return styleRanges;
}