Skip to content

Commit 1fe4b1d

Browse files
Merge branch 'master' of [email protected]:Theo-Dann-Muirhead-Renesas/eclipse.platform.swt.git
2 parents 0427e10 + d441b93 commit 1fe4b1d

File tree

2 files changed

+8
-24
lines changed

2 files changed

+8
-24
lines changed

examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/BrowserTab.java

Lines changed: 5 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2018 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -16,10 +16,9 @@
1616

1717
import static org.eclipse.swt.events.SelectionListener.widgetSelectedAdapter;
1818

19-
import java.io.BufferedReader;
2019
import java.io.IOException;
2120
import java.io.InputStream;
22-
import java.io.InputStreamReader;
21+
import java.nio.charset.StandardCharsets;
2322

2423
import org.eclipse.swt.SWT;
2524
import org.eclipse.swt.SWTError;
@@ -118,18 +117,12 @@ void createExampleWidgets () {
118117
} else if (lastText != null) {
119118
browser.setText(lastText);
120119
} else {
121-
StringBuilder sb= new StringBuilder(300);
122-
123-
try (InputStream htmlStream = ControlExample.class.getResourceAsStream("browser-content.html");
124-
BufferedReader br = new BufferedReader(new InputStreamReader(htmlStream))) {
125-
int read = 0;
126-
while ((read = br.read()) != -1)
127-
sb.append((char) read);
120+
try (InputStream htmlStream = ControlExample.class.getResourceAsStream("browser-content.html")) {
121+
browser.setText( new String (htmlStream.readAllBytes(), StandardCharsets.UTF_8));
128122
} catch (IOException e) {
129123
log(e.getMessage());
124+
browser.setText("Loading failed, see log for details!");
130125
}
131-
String text= sb.toString();
132-
browser.setText(text);
133126
}
134127
lastText = lastUrl = null;
135128
}
@@ -229,16 +222,6 @@ void disposeExampleWidgets () {
229222
super.disposeExampleWidgets();
230223
}
231224

232-
public static String getContents(InputStream in) throws IOException {
233-
StringBuilder sb= new StringBuilder(300);
234-
try (BufferedReader br= new BufferedReader(new InputStreamReader(in))) {
235-
int read= 0;
236-
while ((read= br.read()) != -1)
237-
sb.append((char) read);
238-
}
239-
return sb.toString();
240-
}
241-
242225
/**
243226
* Gets the list of custom event names.
244227
*

examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/browser-content.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
<!DOCTYPE html>
12
<html>
23
<head>
34
<title>SWT Browser</title>
45
</head>
56

67
<h3>About SWT Browser</h3>
7-
<p>You are looking at HTML content in a <b>Browser</b> widget.
8+
<p>You are looking at HTML content in a <b>Browser</b> widget.</p>
89
<ul>
910
<li>For a definition of the Browser widget, see:
1011
<a href="http://www.eclipse.org/swt/faq.php#whatisbrowser">http://www.eclipse.org/swt/faq.php#whatisbrowser</a></li>
@@ -14,7 +15,7 @@ <h3>About SWT Browser</h3>
1415
<a href="http://www.eclipse.org/swt/faq.php#howusewebkit">http://www.eclipse.org/swt/faq.php#howusewebkit</a></li>
1516
<li>For more examples that use a Browser widget, see BrowserExample, BrowserDemo, and WebBrowser:
1617
<a href="http://www.eclipse.org/swt/examples.php">http://www.eclipse.org/swt/examples.php</a></li>
17-
</ul></p>
18+
</ul>
1819

1920
<h3>About SWT</h3>
2021
<p>For more information on SWT, including the Widget Gallery, Snippets, Examples, FAQ, Tools, Documentation

0 commit comments

Comments
 (0)