nnpa
February 25, 2023, 9:32pm
1
I learn this
i create desktop application and add next code
public static void main(String[] args) {
Tests app = new Tests();
app.setShowSettings(false); //Settings dialog not supported on mac
app.start();
}
@Override
public void simpleInitApp() {
final Tests app = this;
app.setPauseOnLostFocus(false);
app.setSettings(settings);
app.createCanvas();
app.startCanvas(true);
final JmeCanvasContext context = (JmeCanvasContext) app.getContext();
final Canvas canvas = context.getCanvas();
canvas.setSize(settings.getWidth(), settings.getHeight());
final JPanel container = new JPanel("Jme Window 1");
//control jme canvas through the parent (parent~Window control)
conatiner.setSize(canvas.getWidth(), canvas.getHeight());
conatiner.add(canvas);
jframe.getContentPane().add(conatiner);
but package JmeCanvasContext don’t exists
nnpa
February 25, 2023, 11:13pm
3
my gradle
plugins {
id 'application'
id 'java'
id "de.undercouch.download" version "5.1.0"
id 'idea'
id "io.github.0ffz.github-packages" version "1.2.1" // Plugin for anonymous inclusion of artifacts hosted in github package registry
}
description = 'Tests application'
java {
sourceCompatibility = '11'
targetCompatibility = '11'
}
ext.jmonkeyengineVersion = '3.5.2-stable'
mainClassName = 'tests.Tests'
if (!hasProperty('mainClass')) {
ext.mainClass = mainClassName
}
jar.manifest.attributes('Main-Class': mainClassName)
repositories {
mavenCentral()
mavenLocal()
}
dependencies {
// You can read more about how to add dependencies here:
// https://docs.gradle.org/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies
implementation 'org.jmonkeyengine:jme3-core:' + jmonkeyengineVersion
runtimeOnly 'org.jmonkeyengine:jme3-jogg:' + jmonkeyengineVersion
runtimeOnly 'org.jmonkeyengine:jme3-plugins:' + jmonkeyengineVersion
implementation 'org.jmonkeyengine:jme3-jbullet:' + jmonkeyengineVersion
runtimeOnly 'org.jmonkeyengine:jme3-lwjgl3:' + jmonkeyengineVersion
implementation files('lib/tonegodgui-0.1.7.jar')
}
distZip {
//having a degenerate folder within the dist zip complicates generating the other zips
eachFile { file ->
String path = file.relativePath
file.setPath(path.substring(path.indexOf("/") + 1, path.length()))
}
includeEmptyDirs(false)
}
//See https://api.adoptium.net/v3/assets/feature_releases/11/ga?image_type=jre for jre urls
def windowsJreUrl = "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15%2B10/OpenJDK11U-jre_x64_windows_hotspot_11.0.15_10.zip"
def linuxJreUrl = "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15%2B10/OpenJDK11U-jre_x64_linux_hotspot_11.0.15_10.tar.gz"
def macJreUrl = "https://github.com/adoptium/temurin11-binaries/releases/download/jdk-11.0.15%2B10/OpenJDK11U-jre_x64_mac_hotspot_11.0.15_10.tar.gz"
task downloadWindowsJre(type: Download) {
src windowsJreUrl
dest new File(buildDir, '/jres/windowsJre.zip')
overwrite false
}
task downloadAndUnzipWindowsJre(dependsOn: downloadWindowsJre, type: Copy) {
from zipTree(downloadWindowsJre.dest)
into "${buildDir}/jres/windowsJre/"
includeEmptyDirs(false)
filesMatching("**") {
it.path = it.path.replaceAll("^[a-zA-Z0-9.+-]*[/\\\\]", "jre/") //rename the top level to something standard so the rest of the script will be easier
}
}
task buildWindowsDistribution(dependsOn: [distZip, downloadAndUnzipWindowsJre], type: Copy)
{
group 'distribution'
from files("${projectDir}/scripts/desktopDeployment/Tests.bat"), zipTree(distZip.archiveFile), "${buildDir}/jres/windowsJre"
into new File(buildDir, 'distributions/Tests-windows')
includeEmptyDirs false
exclude 'bin/**' //we are adding our own run scripts, exclude the ones coming from distZip
}
task zipWindowsDistribution( dependsOn:buildWindowsDistribution, type: Zip) {
group 'distribution'
archiveFileName = "Tests-windows.zip"
destinationDirectory = file("$buildDir/distributions")
from "$buildDir/distributions/Tests-windows"
}
task downloadLinuxJre(type: Download) {
src linuxJreUrl
dest new File(buildDir, '/jres/linuxJre.tar.gz')
overwrite false
}
task downloadAndUnzipLinuxJre(dependsOn: downloadLinuxJre, type: Copy) {
from tarTree(downloadLinuxJre.dest)
into "${buildDir}/jres/linuxJre/"
includeEmptyDirs(false)
filesMatching("**") {
it.path = it.path.replaceAll("^[a-zA-Z0-9.+-]*[/\\\\]", "jre/") //rename the top level to something standard so the rest of the script will be easier
}
}
task buildLinuxDistribution(dependsOn: [distZip, downloadAndUnzipLinuxJre], type: Copy)
{
group 'distribution'
from files("${projectDir}/scripts/desktopDeployment/Tests.sh"){
fileMode 0755
}
from zipTree(distZip.archiveFile)
from "${buildDir}/jres/linuxJre"
into new File(buildDir, 'distributions/Tests-linux')
includeEmptyDirs false
exclude 'bin/**' //we are adding our own run scripts, exclude the ones coming from distZip
}
task zipLinuxDistribution( dependsOn:buildLinuxDistribution, type: Zip) {
group 'distribution'
archiveFileName = "Tests-linux.tar.gz"
destinationDirectory = file("$buildDir/distributions")
from ("$buildDir/distributions/Tests-linux"){
include('**.sh')
include('**/java')
fileMode 0755
}
from ("$buildDir/distributions/Tests-linux"){
exclude('**.sh')
exclude('**/java')
}
}
task downloadMacJre(type: Download) {
src macJreUrl
dest new File(buildDir, '/jres/macJre.tar.gz')
overwrite false
}
task downloadAndUnzipMacJre(dependsOn: downloadMacJre, type: Copy) {
from tarTree(downloadMacJre.dest)
into "${buildDir}/jres/macJre/"
includeEmptyDirs(false)
filesMatching("**") {
it.path = it.path.replaceAll("^[a-zA-Z0-9.+-]*[/\\\\]", "jre/") //rename the top level to something standard so the rest of the script will be easier
}
}
task buildMacDistribution(dependsOn: [distZip, downloadAndUnzipMacJre], type: Copy)
{
group 'distribution'
from files("${projectDir}/scripts/desktopDeployment/Tests.command"){
fileMode 0755
}
from zipTree(distZip.archiveFile)
from "${buildDir}/jres/macJre"
into new File(buildDir, 'distributions/Tests-mac')
includeEmptyDirs false
exclude 'bin/**' //we are adding our own run scripts, exclude the ones coming from distZip
}
task zipMacDistribution( dependsOn:buildMacDistribution, type: Zip) {
group 'distribution'
archiveFileName = "Tests-mac.tar.gz"
destinationDirectory = file("$buildDir/distributions")
from ("$buildDir/distributions/Tests-mac"){
include('**.command')
include('**/java')
fileMode 0755
}
from ("$buildDir/distributions/Tests-mac"){
exclude('**.command')
exclude('**/java')
}
}
task buildAllDistributions{
group 'distribution'
dependsOn 'zipWindowsDistribution'
dependsOn 'zipLinuxDistribution'
dependsOn 'zipMacDistribution'
}
// cleanup tasks
clean.dependsOn('cleanDLLs', 'cleanDyLibs', 'cleanLogs', 'cleanSOs')
task cleanDLLs(type: Delete) {
delete fileTree(dir: '.', include: '*.dll')
}
task cleanDyLibs(type: Delete) {
delete fileTree(dir: '.', include: '*.dylib')
}
task cleanLogs(type: Delete) {
delete fileTree(dir: '.', include: 'hs_err_pid*.log')
}
task cleanSOs(type: Delete) {
delete fileTree(dir: '.', include: '*.so')
}
task fund(){
doLast {
java.awt.Desktop.desktop.browse "https://start.jmonkeyengine.org/#!funding=JME_DESKTOP,JME_JBULLET".toURI()
}
}
is it not available by default?
Pavl_G
February 25, 2023, 11:20pm
4
Lwjgl-3 doesn’t support the JmeCanvasContext, if you want to render jme on a swing JFrame then use lwjgl-2 instead, btw the jme3-desktop dependency is also missing.
2 Likes
nnpa
February 25, 2023, 11:28pm
5
i create project with initializer
what dependencies i need add?
Pavl_G:
use lwjgl-2 instead,
it works with jme 3.5?
Ali_RS
February 26, 2023, 5:38am
6
I once reported this but seems still not fixed.
implementation 'org.jmonkeyengine:jme3-desktop:' + jmonkeyengineVersion
pspeed
February 26, 2023, 6:24am
7
Why are you trying to do this, though?
1 Like
nnpa
February 26, 2023, 12:14pm
8
Because lemur not working with andoid
tonegodgui gives an error message
nify i dont understand (
are there any other options?
Pavl_G
February 26, 2023, 3:20pm
9
The swing canvas will not work with android too.
1 Like
nnpa
February 26, 2023, 3:57pm
10
in the cross-platform application that you sent me, the standard android gui is used
I will try to use it
pspeed
February 26, 2023, 4:09pm
11
Lemur works fine with android. You just have to exclude the duplicate styles file and create your own style in code.
…as detailed in that other thread.