Using a CN1 Eclipse project from another one?












1















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?










share|improve this question



























    1















    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?










    share|improve this question

























      1












      1








      1


      1






      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?










      share|improve this question














      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 21 '18 at 1:48









      maaartinusmaaartinus

      27k2195231




      27k2195231
























          1 Answer
          1






          active

          oldest

          votes


















          1














          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.






          share|improve this answer
























          • 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











          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
          });


          }
          });














          draft saved

          draft discarded


















          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









          1














          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.






          share|improve this answer
























          • 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
















          1














          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.






          share|improve this answer
























          • 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














          1












          1








          1







          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.






          share|improve this answer













          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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 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

















          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


















          draft saved

          draft discarded




















































          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.




          draft saved


          draft discarded














          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





















































          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







          Popular posts from this blog

          MongoDB - Not Authorized To Execute Command

          Npm cannot find a required file even through it is in the searched directory

          in spring boot 2.1 many test slices are not allowed anymore due to multiple @BootstrapWith