Using a CN1 Eclipse project from another one?











up vote
1
down vote

favorite
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


























    up vote
    1
    down vote

    favorite
    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
























      up vote
      1
      down vote

      favorite
      1









      up vote
      1
      down vote

      favorite
      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 at 1:48









      maaartinus

      26.5k2193221




      26.5k2193221
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










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








          up vote
          1
          down vote



          accepted










          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 at 16:31















          up vote
          1
          down vote



          accepted










          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 at 16:31













          up vote
          1
          down vote



          accepted







          up vote
          1
          down vote



          accepted






          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 at 5:08









          Shai Almog

          38.8k52553




          38.8k52553












          • 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 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 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 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 at 16:31


















           

          draft saved


          draft discarded



















































           


          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

          Berounka

          Sphinx de Gizeh

          Different font size/position of beamer's navigation symbols template's content depending on regular/plain...