Using a CN1 Eclipse project from another one?
In Eclipse, I created one CN1 project and one normal Java project, which depends on the former. The latter contains some utilities (e.g., source code generation) and some JUnit tests. I use the following simple hack:
CodenameOneImplementation impl = new JavaSEPort();
Util.setImplementation(impl);
Display.init(impl);
It works, but there's a fullscreen window shown and the program doesn't terminate when main
is done. I know, that it's the normal behavior for GUI applications, but I don't need any GUI as I only initialized Display
, in order for Display#getResource
to work.
- How can I get rid of the window (or at least make it small)?
- How can I terminate the program without having to call
System.exit
(i.e., something like running the event handling thread as daemon)? - Is there more to set up?
java codenameone
add a comment |
In Eclipse, I created one CN1 project and one normal Java project, which depends on the former. The latter contains some utilities (e.g., source code generation) and some JUnit tests. I use the following simple hack:
CodenameOneImplementation impl = new JavaSEPort();
Util.setImplementation(impl);
Display.init(impl);
It works, but there's a fullscreen window shown and the program doesn't terminate when main
is done. I know, that it's the normal behavior for GUI applications, but I don't need any GUI as I only initialized Display
, in order for Display#getResource
to work.
- How can I get rid of the window (or at least make it small)?
- How can I terminate the program without having to call
System.exit
(i.e., something like running the event handling thread as daemon)? - Is there more to set up?
java codenameone
add a comment |
In Eclipse, I created one CN1 project and one normal Java project, which depends on the former. The latter contains some utilities (e.g., source code generation) and some JUnit tests. I use the following simple hack:
CodenameOneImplementation impl = new JavaSEPort();
Util.setImplementation(impl);
Display.init(impl);
It works, but there's a fullscreen window shown and the program doesn't terminate when main
is done. I know, that it's the normal behavior for GUI applications, but I don't need any GUI as I only initialized Display
, in order for Display#getResource
to work.
- How can I get rid of the window (or at least make it small)?
- How can I terminate the program without having to call
System.exit
(i.e., something like running the event handling thread as daemon)? - Is there more to set up?
java codenameone
In Eclipse, I created one CN1 project and one normal Java project, which depends on the former. The latter contains some utilities (e.g., source code generation) and some JUnit tests. I use the following simple hack:
CodenameOneImplementation impl = new JavaSEPort();
Util.setImplementation(impl);
Display.init(impl);
It works, but there's a fullscreen window shown and the program doesn't terminate when main
is done. I know, that it's the normal behavior for GUI applications, but I don't need any GUI as I only initialized Display
, in order for Display#getResource
to work.
- How can I get rid of the window (or at least make it small)?
- How can I terminate the program without having to call
System.exit
(i.e., something like running the event handling thread as daemon)? - Is there more to set up?
java codenameone
java codenameone
asked Nov 21 '18 at 1:48
maaartinusmaaartinus
27k2195231
27k2195231
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Use something like this:
JavaSEPort.setDefaultInitTarget(new JPanel());
This would draw the UI of the display into the blank JPanel
.
About exiting the app you would need to use System.exit(0)
as the EDT loop and native GUI loop are running. You can stop the EDT but that might not work well for the desktop port so just using exit is easy and common practice.
This didn't work, but brought me to the relevant code and withDisplay.init(new JPanel())
, the windows is gone.System.exit
is something, I can live with.
– maaartinus
Nov 21 '18 at 16:31
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404222%2fusing-a-cn1-eclipse-project-from-another-one%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use something like this:
JavaSEPort.setDefaultInitTarget(new JPanel());
This would draw the UI of the display into the blank JPanel
.
About exiting the app you would need to use System.exit(0)
as the EDT loop and native GUI loop are running. You can stop the EDT but that might not work well for the desktop port so just using exit is easy and common practice.
This didn't work, but brought me to the relevant code and withDisplay.init(new JPanel())
, the windows is gone.System.exit
is something, I can live with.
– maaartinus
Nov 21 '18 at 16:31
add a comment |
Use something like this:
JavaSEPort.setDefaultInitTarget(new JPanel());
This would draw the UI of the display into the blank JPanel
.
About exiting the app you would need to use System.exit(0)
as the EDT loop and native GUI loop are running. You can stop the EDT but that might not work well for the desktop port so just using exit is easy and common practice.
This didn't work, but brought me to the relevant code and withDisplay.init(new JPanel())
, the windows is gone.System.exit
is something, I can live with.
– maaartinus
Nov 21 '18 at 16:31
add a comment |
Use something like this:
JavaSEPort.setDefaultInitTarget(new JPanel());
This would draw the UI of the display into the blank JPanel
.
About exiting the app you would need to use System.exit(0)
as the EDT loop and native GUI loop are running. You can stop the EDT but that might not work well for the desktop port so just using exit is easy and common practice.
Use something like this:
JavaSEPort.setDefaultInitTarget(new JPanel());
This would draw the UI of the display into the blank JPanel
.
About exiting the app you would need to use System.exit(0)
as the EDT loop and native GUI loop are running. You can stop the EDT but that might not work well for the desktop port so just using exit is easy and common practice.
answered Nov 21 '18 at 5:08


Shai AlmogShai Almog
40.4k52555
40.4k52555
This didn't work, but brought me to the relevant code and withDisplay.init(new JPanel())
, the windows is gone.System.exit
is something, I can live with.
– maaartinus
Nov 21 '18 at 16:31
add a comment |
This didn't work, but brought me to the relevant code and withDisplay.init(new JPanel())
, the windows is gone.System.exit
is something, I can live with.
– maaartinus
Nov 21 '18 at 16:31
This didn't work, but brought me to the relevant code and with
Display.init(new JPanel())
, the windows is gone. System.exit
is something, I can live with.– maaartinus
Nov 21 '18 at 16:31
This didn't work, but brought me to the relevant code and with
Display.init(new JPanel())
, the windows is gone. System.exit
is something, I can live with.– maaartinus
Nov 21 '18 at 16:31
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53404222%2fusing-a-cn1-eclipse-project-from-another-one%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown