FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
webview_java/SwingExample.java at main · faveoled/webview_java · GitHub
faveoled
/
webview_java
Public
forked from
webview/webview_java
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
webview_java
/
SwingExample.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
49 lines (36 loc) · 1.37 KB
Breadcrumbs
webview_java
/
SwingExample.java
Copy path
File metadata and controls
49 lines (36 loc) · 1.37 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package
dev
.
webview
;
import
java
.
awt
.
BorderLayout
;
import
java
.
awt
.
Component
;
import
java
.
awt
.
event
.
WindowAdapter
;
import
java
.
awt
.
event
.
WindowEvent
;
import
javax
.
swing
.
JFrame
;
public
class
SwingExample
{
public
static
void
main
(
String
[]
args
) {
JFrame
frame
=
new
JFrame
();
frame
.
setDefaultCloseOperation
(
JFrame
.
DO_NOTHING_ON_CLOSE
);
frame
.
setLayout
(
new
BorderLayout
());
// Using createAWT allows you to defer the creation of the webview until the
// canvas is fully renderable.
Component
component
=
Webview
.
createAWT
(
true
, (
wv
) -> {
// Calling `await echo(1,2,3)` will return `[1,2,3]`
wv
.
bind
(
"echo"
, (
arguments
) -> {
return
arguments
;
});
wv
.
loadURL
(
"https://google.com"
);
frame
.
addWindowListener
(
new
WindowAdapter
() {
@
Override
public
void
windowClosing
(
WindowEvent
e
) {
wv
.
close
();
frame
.
dispose
();
System
.
exit
(
0
);
}
});
// Run the webview event loop, the webview is fully disposed when this returns.
wv
.
run
();
});
frame
.
getContentPane
().
add
(
component
,
BorderLayout
.
CENTER
);
frame
.
setTitle
(
"My Webview App"
);
frame
.
setSize
(
800
,
600
);
frame
.
setVisible
(
true
);
}
}
Back
|
FazBrowse Home
|
New Git URL