Skip to content

Commit

Permalink
Merge pull request #181 from leaningtech/tutorials
Browse files Browse the repository at this point in the history
tutorials
  • Loading branch information
GabrielaReyna authored Jan 30, 2024
2 parents 6c45939 + b4ae2b1 commit 127629c
Show file tree
Hide file tree
Showing 28 changed files with 223 additions and 0 deletions.
Binary file added examples/FoilSim-Applet/FoilSim.jar
Binary file not shown.
9 changes: 9 additions & 0 deletions examples/FoilSim-Applet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CheerpJ example: FoilSim Applet

This example shows how to use CheerpJ to run a Java applet in the browser.

Find the step-by-step on our [documentation website](https://labs.leaningtech.com/cheerpj3/examples/applet).


## Credits
The applet used for this tutorial belongs to the NASA's [Beginner's Guide to Aeronautics](https://www.grc.nasa.gov/WWW/K-12/airplane/) and it is available at their [GitHub repository](https://github.com/nasa/BGA/tree/main).
44 changes: 44 additions & 0 deletions examples/FoilSim-Applet/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8" />
<title>FoilSim applet (CheerpJ)</title>
<script src="https://cjrtnc.leaningtech.com/3.0rc2/cj3loader.js"></script>
</head>
<style>
div {
max-width: 1000px;
margin: auto;
text-align: center;
}
h1 {
margin-bottom: 50px;
}
h5 {
margin-top: 20px;
}
</style>

<body>
<div>
<h1>Applet example with CheerpJ</h1>
<div>
<cheerpj-applet archive="FoilSim.jar" code="Foil.class" height="450" width="950">
Your browser cannot handle the applet tag!
</cheerpj-applet>
</div>
<h5>
The applet shown in this example belongs to the NASA's <a
href="https://www.grc.nasa.gov/WWW/K-12/airplane/">Beginner's Guide to Aeronautics</a> and it is available at
their <a href="https://github.com/nasa/BGA/tree/main">GitHub repository</a>.
</h5>
<h5>Applet is running with <a href="https://labs.leaningtech.com/cheerpj3">CheerpJ</a> by <a
href="https://leaningtech.com/">©Leaning Technologies</a></h5>
</div>
<script type="module">
await cheerpjInit();
</script>
</body>

</html>
Binary file added examples/Pitch-Applet/Pitch.jar
Binary file not shown.
10 changes: 10 additions & 0 deletions examples/Pitch-Applet/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# CheerpJ example: Pitch Applet

This example shows how to use CheerpJ to run a Java applet in the browser.

Find the step-by-step on our [documentation website](https://labs.leaningtech.com/cheerpj3/examples/applet).

The JNLP version of this tutorial is [available here](https://labs.leaningtech.com/cheerpj3/examples/jnlp#jnlp-applet-pitch).

## Credits
The applet used for this tutorial belongs to the NASA's [Beginner's Guide to Aeronautics](https://www.grc.nasa.gov/WWW/K-12/airplane/) and it is available at their [GitHub repository](https://github.com/nasa/BGA/tree/main).
44 changes: 44 additions & 0 deletions examples/Pitch-Applet/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<!doctype html>
<html lang="en">

<head>
<meta charset="utf-8" />
<title>Pitch applet (CheerpJ)</title>
<script src="https://cjrtnc.leaningtech.com/3.0rc1/cj3loader.js"></script>
</head>
<style>
div {
max-width: 500px;
margin: auto;
text-align: center;
}
h1 {
margin-bottom: 50px;
}
h5 {
margin-top: 20px;
}
</style>

<body>
<div>
<h1>Applet example with CheerpJ</h1>
<div>
<cheerpj-applet archive="Pitch.jar" code="Pitchview" height="300" width="500">
Your browser cannot handle the applet tag!
</cheerpj-applet>
</div>
<h5>
The applet shown in this example belongs to the NASA's <a
href="https://www.grc.nasa.gov/WWW/K-12/airplane/">Beginner's Guide to Aeronautics</a> and it is available at
their <a href="https://github.com/nasa/BGA/tree/main">GitHub repository</a>.
</h5>
<h5>Applet is running with <a href="https://labs.leaningtech.com/cheerpj3">CheerpJ</a> by <a
href="https://leaningtech.com/">©Leaning Technologies</a></h5>
</div>
<script type="module">
await cheerpjInit();
</script>
</body>

</html>
15 changes: 15 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# CheerpJ tutorials

This repository holds a collection of the CheerpJ examples available on [our documentation website](https://labs.leaningtech.com/cheerpj3/examples). These examples will help you to put hands-on simple projects with CheerpJ and run a variety of Java applets and applications in the browser, including those that require networking.



| Tutorial | Description |
| ----------- | ----------- |
| [FoilSim Applet](https://labs.leaningtech.com/cheerpj3/examples/applet) | How to run a Java applet in the browser. |
| [Pitch Applet](https://labs.leaningtech.com/cheerpj3/examples/jnlp#jnlp-applet-pitch) | How to run a JNLP applet in the browser. |
| [Server-Client](https://labs.leaningtech.com/cheerpj3/examples/serverclient) | How to run two Java applications that communicate with each other (tab-to-tab).|
| [Swing-Browser](https://labs.leaningtech.com/cheerpj3/examples/java-browser) | How to run a Java application in the browser with an internet connection. |
| [SwingSet3](https://labs.leaningtech.com/cheerpj3/examples/swingset3) | How to run a Swing application in the browser. |

We have a vibrant [Discord community](https://discord.com/invite/qBMHpK9Kqv) where you can ask questions, share your projects, and get community support.
Binary file added examples/Server-Client/Client/Client.jar
Binary file not shown.
26 changes: 26 additions & 0 deletions examples/Server-Client/Client/client.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Client</title>
<script src="https://cjrtnc.leaningtech.com/3.0rc2/cj3loader.js"></script>
</head>
<body>
<input type="text" id="ip"></input>
<script>
async function start(ip) {
await cheerpjInit({
tailscaleAuthKey: "PasteYourKeyHere",
});
cheerpjCreateDisplay(800, 600);
await cheerpjRunJar("/app/Client.jar", ip);
};
let el = document.querySelector("#ip");
el.addEventListener("keydown", (e) => {
if (e.key == "Enter") {
start(el.value);
}
});
</script>
</body>
</html>
8 changes: 8 additions & 0 deletions examples/Server-Client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# CheerpJ networking example: Server-Client communication

This example shows how to use CheerpJ to run two Java applications that communicate with each other.

Find the step-by-step tutorial on our [documentation website](https://labs.leaningtech.com/cheerpj3/examples/serverclient).

## Credits
The Java applications used in this networking tutorial belong to [TechVidvan](https://techvidvan.com/tutorials/). You can find their tutorial with the source code [here](https://techvidvan.com/tutorials/java-chat-application/). Some minor edits have been made to adapt to this tutorial.
Binary file added examples/Server-Client/Server/.DS_Store
Binary file not shown.
Binary file added examples/Server-Client/Server/Server.jar
Binary file not shown.
24 changes: 24 additions & 0 deletions examples/Server-Client/Server/server.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Server</title>
<script src="https://cjrtnc.leaningtech.com/3.0rc2/cj3loader.js"></script>
</head>
<body>
<input type="text" id="ip"></input>
<script>
(async function () {
await cheerpjInit({
tailscaleAuthKey: "PasteYourKeyHere",
tailscaleIpCb: (ip) => {
let el = document.querySelector("#ip");
el.value = ip;
},
});
cheerpjCreateDisplay(800, 600);
await cheerpjRunJar("/app/Server.jar");
})();
</script>
</body>
</html>
5 changes: 5 additions & 0 deletions examples/Swing-Browser/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# CheerpJ networking example: Swing Browser

This example shows how to use CheerpJ to run a Java application in the browser with an internet connection.

Find the step-by-step tutorial on our [documentation website](https://labs.leaningtech.com/cheerpj3/examples/java-browser).
Binary file added examples/Swing-Browser/SwingHTMLBrowser.jar
Binary file not shown.
20 changes: 20 additions & 0 deletions examples/Swing-Browser/browser.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>Browser</title>
<script src="https://cjrtnc.leaningtech.com/3.0rc2/cj3loader.js"></script>
</head>
<body>
<script>
(async function () {
await cheerpjInit({
tailscaleAuthKey:"PasteYourKeyHere",

});
cheerpjCreateDisplay(800, 600);
await cheerpjRunJar("/app/SwingHTMLBrowser.jar");
})();
</script>
</body>
</html>
9 changes: 9 additions & 0 deletions examples/SwingSet3/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CheerpJ example: SwingSet3

This example shows how to use CheerpJ to run a Swing application in the browser.

You can find the full tutorial on our [documentation page](/cheerpj3/examples/swingset3).

The JNLP version of this tutorial is [available here](https://labs.leaningtech.com/cheerpj3/examples/jnlp#jnlp-application-swingset3).


Binary file added examples/SwingSet3/SwingSet3.jar
Binary file not shown.
9 changes: 9 additions & 0 deletions examples/SwingSet3/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
</head>
<body>
</body>
</html>
Binary file added examples/SwingSet3/lib/AnimatedTransitions.jar
Binary file not shown.
Binary file added examples/SwingSet3/lib/AppFramework.jar
Binary file not shown.
Empty file.
Empty file.
Binary file added examples/SwingSet3/lib/TimingFramework.jar
Binary file not shown.
Binary file added examples/SwingSet3/lib/javaws.jar
Binary file not shown.
Empty file.
Binary file added examples/SwingSet3/lib/swing-worker.jar
Binary file not shown.
Binary file added examples/SwingSet3/lib/swingx.jar
Binary file not shown.

0 comments on commit 127629c

Please sign in to comment.