Skip to content

Commit 3885410

Browse files
committed
Add the debug parameter.
1 parent 013541e commit 3885410

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

Example.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public class Example {
44

55
public static void main(String[] args) {
6-
Webview wv = new Webview(); // Can optionally be created with an AWT component to be painted on.
6+
Webview wv = new Webview(true); // Can optionally be created with an AWT component to be painted on.
77

88
// Calling `await echo(1,2,3)` will return `[1,2,3]`
99
wv.bind("echo", (arguments) -> {

SwingExample.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public static void main(String[] args) {
1717

1818
// Using createAWT allows you to defer the creation of the webview until the
1919
// canvas is fully renderable.
20-
Component component = Webview.createAWT((wv) -> {
20+
Component component = Webview.createAWT(true, (wv) -> {
2121
// Calling `await echo(1,2,3)` will return `[1,2,3]`
2222
wv.bind("echo", (arguments) -> {
2323
return arguments;

src/main/java/dev/webview/Webview.java

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class Webview implements Closeable, Runnable {
3838
@Deprecated
3939
public long $pointer;
4040

41-
public static Component createAWT(@NonNull Consumer<Webview> onCreate) {
41+
public static Component createAWT(boolean debug, @NonNull Consumer<Webview> onCreate) {
4242
return new Canvas() {
4343
private static final long serialVersionUID = 5199512256429931156L;
4444

@@ -63,7 +63,7 @@ public void paint(Graphics g) {
6363
this.initialized = true;
6464

6565
new Thread(() -> {
66-
this.webview = new Webview(this);
66+
this.webview = new Webview(debug, this);
6767

6868
this.updateSize();
6969

@@ -92,27 +92,31 @@ private void updateSize() {
9292

9393
/**
9494
* Creates a new Webview.
95+
*
96+
* @param debug Enables devtools/inspect element if true.
9597
*/
96-
public Webview() {
97-
this(NULL_PTR);
98+
public Webview(boolean debug) {
99+
this(debug, (PointerByReference) null);
98100
}
99101

100102
/**
101103
* Creates a new Webview.
102104
*
105+
* @param debug Enables devtools/inspect element if true.
106+
*
103107
* @param target The target awt component, such as a {@link java.awt.JFrame} or
104108
* {@link java.awt.Canvas}
105109
*/
106-
public Webview(@NonNull Component target) {
107-
this(new PointerByReference(Native.getComponentPointer(target)));
110+
public Webview(boolean debug, @NonNull Component target) {
111+
this(debug, new PointerByReference(Native.getComponentPointer(target)));
108112
}
109113

110114
/**
111115
* @deprecated Use this if you absolutely do know what you're doing.
112116
*/
113117
@Deprecated
114-
public Webview(@Nullable PointerByReference windowPointer) {
115-
$pointer = N.webview_create(false, windowPointer);
118+
public Webview(boolean debug, @Nullable PointerByReference windowPointer) {
119+
$pointer = N.webview_create(debug, windowPointer);
116120

117121
this.loadURL(null);
118122
this.setSize(800, 600);

0 commit comments

Comments
 (0)