Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/clipboard/ClipboardExample.java4
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/BrowserTab.java6
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/dnd/DNDExample.java10
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaLineStyler.java4
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaViewer.java2
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/FillLayoutTab.java4
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/FormLayoutTab.java6
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/GridLayoutTab.java6
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/RowLayoutTab.java6
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/StackLayoutTab.java6
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/Tab.java18
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/TextEditor.java4
-rw-r--r--examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/text.txt14
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet133.java12
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet179.java6
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet196.java9
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet222.java4
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet307.java4
-rw-r--r--examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet338.java4
19 files changed, 65 insertions, 64 deletions
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/clipboard/ClipboardExample.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/clipboard/ClipboardExample.java
index a586739848..b3d29ba405 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/clipboard/ClipboardExample.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/clipboard/ClipboardExample.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -217,7 +217,7 @@ void createRTFTransfer(Composite copyParent, Composite pasteParent){
String textData = copyRtfText.getText();
if (textData.length() > 0) {
status.setText("");
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
buffer.append("{\\rtf1\\ansi\\uc1{\\colortbl;\\red255\\green0\\blue0;}\\uc1\\b\\i ");
for (int i = 0; i < textData.length(); i++) {
char ch = textData.charAt(i);
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/BrowserTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/BrowserTab.java
index 48819b9a4f..49d01d4ec2 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/BrowserTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/BrowserTab.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -111,7 +111,7 @@ class BrowserTab extends Tab {
} else if (lastText != null) {
browser.setText(lastText);
} else {
- StringBuffer sb= new StringBuffer(300);
+ StringBuilder sb= new StringBuilder(300);
try (InputStream htmlStream = ControlExample.class.getResourceAsStream("browser-content.html");
BufferedReader br = new BufferedReader(new InputStreamReader(htmlStream))) {
@@ -219,7 +219,7 @@ class BrowserTab extends Tab {
}
public static String getContents(InputStream in) throws IOException {
- StringBuffer sb= new StringBuffer(300);
+ StringBuilder sb= new StringBuilder(300);
try (BufferedReader br= new BufferedReader(new InputStreamReader(in))) {
int read= 0;
while ((read= br.read()) != -1)
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/dnd/DNDExample.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/dnd/DNDExample.java
index ae817df8ac..ccceae24dc 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/dnd/DNDExample.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/dnd/DNDExample.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -319,7 +319,7 @@ private void createDragSource() {
if (items.length == 0) {
event.doit = false;
} else {
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
for (int i = 0; i < items.length; i++) {
buffer.append(items[i].getText());
if (items.length > 1 && i < items.length - 1) {
@@ -346,7 +346,7 @@ private void createDragSource() {
if (items.length == 0) {
event.doit = false;
} else {
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
for (int i = 0; i < items.length; i++) {
buffer.append(items[i].getText());
if (items.length > 1 && i < items.length - 1) {
@@ -362,7 +362,7 @@ private void createDragSource() {
if (strings == null || strings.length == 0) {
event.doit = false;
} else {
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
for (int i = 0; i < strings.length; i++) {
buffer.append(strings[i]);
if (strings.length > 1 && i < strings.length - 1) {
@@ -389,7 +389,7 @@ private void createDragSource() {
if (selection.length == 0) {
event.doit = false;
} else {
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
for (int i = 0; i < selection.length; i++) {
buffer.append(selection[i]);
if (selection.length > 1 && i < selection.length - 1) {
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaLineStyler.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaLineStyler.java
index ff2546fff7..743e937655 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaLineStyler.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaLineStyler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2015 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -218,7 +218,7 @@ public void parseBlockComments(String text) {
public class JavaScanner {
protected Map<String, Integer> fgKeys= null;
- protected StringBuffer fBuffer= new StringBuffer();
+ protected StringBuilder fBuffer= new StringBuilder();
protected String fDoc;
protected int fPos;
protected int fEnd;
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaViewer.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaViewer.java
index 8a51718458..3cf299785c 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaViewer.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/javaviewer/JavaViewer.java
@@ -147,7 +147,7 @@ void open(String name) {
try (Reader in = new BufferedReader(new InputStreamReader(stream))) {
char[] readBuffer= new char[2048];
- StringBuffer buffer= new StringBuffer((int) file.length());
+ StringBuilder buffer= new StringBuilder((int) file.length());
int n;
while ((n = in.read(readBuffer)) > 0) {
buffer.append(readBuffer, 0, n);
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/FillLayoutTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/FillLayoutTab.java
index 4985353b7d..9a35bccbf8 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/FillLayoutTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/FillLayoutTab.java
@@ -146,8 +146,8 @@ class FillLayoutTab extends Tab {
* Generates code for the example layout.
*/
@Override
- StringBuffer generateLayoutCode () {
- StringBuffer code = new StringBuffer ();
+ StringBuilder generateLayoutCode () {
+ StringBuilder code = new StringBuilder ();
code.append ("\t\tFillLayout fillLayout = new FillLayout ();\n");
if (fillLayout.type == SWT.VERTICAL) {
code.append ("\t\tfillLayout.type = SWT.VERTICAL;\n");
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/FormLayoutTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/FormLayoutTab.java
index 908a2be7a9..202f7b79ab 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/FormLayoutTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/FormLayoutTab.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -325,8 +325,8 @@ class FormLayoutTab extends Tab {
* Generates code for the example layout.
*/
@Override
- StringBuffer generateLayoutCode () {
- StringBuffer code = new StringBuffer ();
+ StringBuilder generateLayoutCode () {
+ StringBuilder code = new StringBuilder ();
code.append ("\t\tFormLayout formLayout = new FormLayout ();\n");
if (formLayout.marginWidth != 0) {
code.append ("\t\tformLayout.marginWidth = " + formLayout.marginWidth + ";\n");
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/GridLayoutTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/GridLayoutTab.java
index 33e123e311..941287bd6c 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/GridLayoutTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/GridLayoutTab.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -369,8 +369,8 @@ class GridLayoutTab extends Tab {
* Generates code for the example layout.
*/
@Override
- StringBuffer generateLayoutCode () {
- StringBuffer code = new StringBuffer ();
+ StringBuilder generateLayoutCode () {
+ StringBuilder code = new StringBuilder ();
code.append ("\t\tGridLayout gridLayout = new GridLayout (");
if (gridLayout.numColumns != 1 || gridLayout.makeColumnsEqualWidth) {
code.append (gridLayout.numColumns + ", " + gridLayout.makeColumnsEqualWidth);
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/RowLayoutTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/RowLayoutTab.java
index 1f7422e8c8..52bdfd5275 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/RowLayoutTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/RowLayoutTab.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -250,8 +250,8 @@ class RowLayoutTab extends Tab {
* Generates code for the example layout.
*/
@Override
- StringBuffer generateLayoutCode () {
- StringBuffer code = new StringBuffer ();
+ StringBuilder generateLayoutCode () {
+ StringBuilder code = new StringBuilder ();
code.append ("\t\tRowLayout rowLayout = new RowLayout ();\n");
if (rowLayout.type == SWT.VERTICAL) {
code.append ("\t\trowLayout.type = SWT.VERTICAL;\n");
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/StackLayoutTab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/StackLayoutTab.java
index 732ccc5295..9c23dfad4c 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/StackLayoutTab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/StackLayoutTab.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -157,8 +157,8 @@ class StackLayoutTab extends Tab {
* Generates code for the example layout.
*/
@Override
- StringBuffer generateLayoutCode() {
- StringBuffer code = new StringBuffer();
+ StringBuilder generateLayoutCode() {
+ StringBuilder code = new StringBuilder();
code.append("\t\tStackLayout stackLayout = new StackLayout ();\n");
if (stackLayout.marginWidth != 0) {
code.append("\t\tstackLayout.marginWidth = " + stackLayout.marginWidth + ";\n");
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/Tab.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/Tab.java
index 20facd3e7b..93763fc39f 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/Tab.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/layoutexample/Tab.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -445,7 +445,7 @@ abstract class Tab {
/**
* Generates the code needed to produce the example layout.
*/
- StringBuffer generateCode () {
+ StringBuilder generateCode () {
/* Make sure all information being entered is stored in the table */
resetEditors ();
@@ -464,8 +464,8 @@ abstract class Tab {
}
}
- /* Create StringBuffer containing the code */
- StringBuffer code = new StringBuffer ();
+ /* Create StringBuilder containing the code */
+ StringBuilder code = new StringBuilder ();
code.append ("import org.eclipse.swt.*;\n");
code.append ("import org.eclipse.swt.layout.*;\n");
code.append ("import org.eclipse.swt.widgets.*;\n");
@@ -500,16 +500,16 @@ abstract class Tab {
* Generates layout specific code for the example layout.
* Subclasses override this method.
*/
- StringBuffer generateLayoutCode () {
- return new StringBuffer ();
+ StringBuilder generateLayoutCode () {
+ return new StringBuilder ();
}
/**
- * Returns the StringBuffer for the code which will
+ * Returns the StringBuilder for the code which will
* create a child control.
*/
- StringBuffer getChildCode (Control control, int i) {
- StringBuffer code = new StringBuffer ();
+ StringBuilder getChildCode (Control control, int i) {
+ StringBuilder code = new StringBuilder ();
/* Find the type of control */
String controlClass = control.getClass().toString ();
String controlType = controlClass.substring (controlClass.lastIndexOf ('.') + 1);
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/TextEditor.java b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/TextEditor.java
index 35e21efdcf..c10ee2a189 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/TextEditor.java
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/TextEditor.java
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -1164,7 +1164,7 @@ public class TextEditor {
String openFile(InputStream stream) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
- StringBuffer buffer = new StringBuffer();
+ StringBuilder buffer = new StringBuilder();
String line;
String lineDelimiter = styledText.getLineDelimiter();
while ((line = reader.readLine()) != null) {
diff --git a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/text.txt b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/text.txt
index ce595a2190..573bfae771 100644
--- a/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/text.txt
+++ b/examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/texteditor/text.txt
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -568,7 +568,7 @@ public class StyledText extends Canvas {
if (pageIndex != -1) {
final int PageTagLength = StyledTextPrintOptions.PAGE_TAG.length();
- StringBuffer buffer = new StringBuffer(segment.substring (0, pageIndex));
+ StringBuilder buffer = new StringBuilder(segment.substring (0, pageIndex));
buffer.append (page);
buffer.append (segment.substring(pageIndex + PageTagLength));
segment = buffer.toString();
@@ -785,7 +785,7 @@ public class StyledText extends Canvas {
* Writes the RTF header including font table and color table.
*/
void writeHeader() {
- StringBuffer header = new StringBuffer();
+ StringBuilder header = new StringBuilder();
FontData fontData = getFont().getFontData()[0];
header.append("{\\rtf1\\ansi");
// specify code page, necessary for copy to work in bidi
@@ -991,7 +991,7 @@ public class StyledText extends Canvas {
* has been called.
*/
class TextWriter {
- private StringBuffer buffer;
+ private StringBuilder buffer;
private int startOffset; // offset of first character that will be written
private int endOffset; // offset of last character that will be written.
// 0 based from the beginning of the widget text.
@@ -1006,7 +1006,7 @@ public class StyledText extends Canvas {
* @param length length of content to write
*/
public TextWriter(int start, int length) {
- buffer = new StringBuffer(length);
+ buffer = new StringBuilder(length);
startOffset = start;
endOffset = start + length;
}
@@ -2225,7 +2225,7 @@ public void copy(int clipboardType) {
* has the SWT.SINGLE style.
*/
String getModelDelimitedText(String text) {
- StringBuffer convertedText;
+ StringBuilder convertedText;
String delimiter = getLineDelimiter();
int length = text.length();
int crIndex = 0;
@@ -2235,7 +2235,7 @@ String getModelDelimitedText(String text) {
if (length == 0) {
return text;
}
- convertedText = new StringBuffer(length);
+ convertedText = new StringBuilder(length);
while (i < length) {
if (crIndex != -1) {
crIndex = text.indexOf(SWT.CR, i);
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet133.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet133.java
index 310eb1863e..e66f1163e0 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet133.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet133.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -48,7 +48,7 @@ public class Snippet133 {
int index, end;
String textToPrint;
String tabs;
- StringBuffer wordBuffer;
+ StringBuilder wordBuffer;
public static void main(String[] args) {
new Snippet133().open();
@@ -111,7 +111,7 @@ public class Snippet133 {
try (FileInputStream stream = new FileInputStream(file.getPath())) {
Reader in = new BufferedReader(new InputStreamReader(stream));
char[] readBuffer = new char[2048];
- StringBuffer buffer = new StringBuffer((int) file.length());
+ StringBuilder buffer = new StringBuilder((int) file.length());
int n;
while ((n = in.read(readBuffer)) > 0) {
buffer.append(readBuffer, 0, n);
@@ -206,7 +206,7 @@ public class Snippet133 {
/* Create a buffer for computing tab width. */
int tabSize = 4; // is tab width a user setting in your UI?
- StringBuffer tabBuffer = new StringBuffer(tabSize);
+ StringBuilder tabBuffer = new StringBuilder(tabSize);
for (int i = 0; i < tabSize; i++) tabBuffer.append(' ');
tabs = tabBuffer.toString();
@@ -236,7 +236,7 @@ public class Snippet133 {
void printText() {
printer.startPage();
- wordBuffer = new StringBuffer();
+ wordBuffer = new StringBuilder();
x = leftMargin;
y = topMargin;
index = 0;
@@ -279,7 +279,7 @@ public class Snippet133 {
}
gc.drawString(word, x, y, false);
x += wordWidth;
- wordBuffer = new StringBuffer();
+ wordBuffer = new StringBuilder();
}
}
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet179.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet179.java
index 8eae55f7b2..44825eeea3 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet179.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet179.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -37,7 +37,7 @@ public static void main(String[] args) {
public void handleEvent(Event e) {
if (ignore) return;
e.doit = false;
- StringBuffer buffer = new StringBuffer(e.text);
+ StringBuilder buffer = new StringBuilder(e.text);
char[] chars = new char[buffer.length()];
buffer.getChars(0, chars.length, chars, 0);
if (e.character == '\b') {
@@ -91,7 +91,7 @@ public static void main(String[] args) {
}
String newText = buffer.toString();
int length = newText.length();
- StringBuffer date = new StringBuffer(text.getText());
+ StringBuilder date = new StringBuilder(text.getText());
date.replace(e.start, e.start + length, newText);
calendar.set(Calendar.YEAR, 1901);
calendar.set(Calendar.MONTH, Calendar.JANUARY);
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet196.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet196.java
index d318e23a4c..a859a3730d 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet196.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet196.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2013 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -18,9 +18,10 @@ package org.eclipse.swt.snippets;
* http://www.eclipse.org/swt/snippets/
*/
import java.util.regex.*;
+import java.util.regex.Pattern;
import org.eclipse.swt.*;
-import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
@@ -52,7 +53,7 @@ public static void main(String[] args) {
if (ignore) return;
e.doit = false;
if (e.start > 13 || e.end > 14) return;
- StringBuffer buffer = new StringBuffer(e.text);
+ StringBuilder buffer = new StringBuilder(e.text);
//handle backspace
if (e.character == '\b') {
@@ -95,7 +96,7 @@ public static void main(String[] args) {
return;
}
- StringBuffer newText = new StringBuffer(defaultText);
+ StringBuilder newText = new StringBuilder(defaultText);
char[] chars = e.text.toCharArray();
int index = e.start - 1;
for (int i = 0; i < e.text.length(); i++) {
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet222.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet222.java
index 2f4423eb78..15159eb17d 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet222.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet222.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -32,7 +32,7 @@ public static void main(String[] args) {
shell.setText("StyledText Bullet Example");
shell.setLayout(new FillLayout());
final StyledText styledText = new StyledText (shell, SWT.FULL_SELECTION | SWT.BORDER | SWT.WRAP | SWT.V_SCROLL);
- StringBuffer text = new StringBuffer();
+ StringBuilder text = new StringBuilder();
text.append("Here is StyledText with some bulleted lists:\n\n");
for (int i = 0; i < 4; i++) text.append("Red Bullet List Item " + i + "\n");
text.append("\n");
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet307.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet307.java
index 9a7d1c51e5..806c1aabd7 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet307.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet307.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -90,7 +90,7 @@ static class CustomFunction extends BrowserFunction {
}
static String createHTML () {
- StringBuffer buffer = new StringBuffer ();
+ StringBuilder buffer = new StringBuilder ();
buffer.append ("<html>\n");
buffer.append ("<head>\n");
buffer.append ("<script language=\"JavaScript\">\n");
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet338.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet338.java
index eba4f7f202..3d003ac15e 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet338.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet338.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2016 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -81,7 +81,7 @@ public static void main(String[] args) {
childShell.setDefaultButton(button);
Listener printTraverseListener = event -> {
- StringBuffer buffer = new StringBuffer("Traverse ");
+ StringBuilder buffer = new StringBuilder("Traverse ");
buffer.append(event.widget);
buffer.append(" type=");
switch (event.detail) {

Back to the top