• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

using an applet to open another window (JFrame)

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I created a regular Java application that you compile with javac and run with java at the command line. It opens a little frame where it asks for your name and choice of color, then uses those to open a large frame holding a game board and instantiates a game (you against other humans at the same terminal or AI opponents), hiding the little frame. Works fine.

I tried to turn it into an applet by taking the setup-frame class and superficially editing it to be a setup-applet on a webpage. That part seemed to work. However, when I use it and try to start the game, the new game window is tiny and (when expanded) still only holds one dot. The code for the applet is:



Forgive the sophomoric response to the lack of name.

The code for the frame containing the game is



I hesitate to post the code for the "JuroOneScreenPanel" class, since it's where much of the game running junk is handled, which would be long and unhelpful to anyone helping me.

Thanks in advance.
 
Ranch Hand
Posts: 77
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would be a better experience for the end user if the frame(s) were launched using Java Web Start.

And speaking of frames, it is generally only necessary to have one frame in an application. Other free floating UI elements might be shown in a JDialog or JOptionPane, or alternately included in the main UI using a CardLayout or any number of components (e.g. JSplitPane, JTabbedPane, JDesktopPane/JInternalFrame).
 
J R Hatch
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Andrew Thompson wrote:It would be a better experience for the end user if the frame(s) were launched using Java Web Start.



I don't say you're wrong, but why? As it runs (if I could get it to run), there would be an applet on the page where they type their name and pick a color, then launch a new frame for the game. With web start (jnlp), they would hit a button ("Launch") which would open a small frame to enter the name and pick a color, then launch the game frame. Unless that solves the network inaccessibility, I don't see why that's better.


And speaking of frames, it is generally only necessary to have one frame in an application. Other free floating UI elements might be shown in a JDialog or JOptionPane, or alternately included in the main UI using a CardLayout or any number of components (e.g. JSplitPane, JTabbedPane, JDesktopPane/JInternalFrame).



It's only necessary to have one, but is it that bad to have two? I use the name of the person starting the game in the constructor of the game frame, so I threw in a quick little setup frame/applet before opening the big one containing the game board. I do use dialogs and JOptionPanes for other things within the game.
 
Andrew Thompson
Ranch Hand
Posts: 77
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

J R Hatch wrote:

Andrew Thompson wrote:It would be a better experience for the end user if the frame(s) were launched using Java Web Start.


I don't say you're wrong, but why? As it runs (if I could get it to run), there would be an applet on the page ..



What page? Did the user click a link to get to the page? If so, change that 'link to applet page' to a 'link to JNLP' and the end user will have the same experience, except that.

  • The free floating 'name/choose a color' screen is either resizable (difficult in a web page) or the exact size it needs to be (even harder in a web page).
  • Neither the end user nor you have to deal with applet/JRE/browser interaction problems.
  • JWS can also perform desktop integration (desktop shortcut, start menu item), automatic updates or updates under programmatic control, sand-boxed access to the local file system, a built-in persistence service (to save high scores) ..and a dozen other nice little tweaks that I thought I took the time to mention in that page on JWS I linked to.

  • Did you actually read it?
     
    J R Hatch
    Greenhorn
    Posts: 26
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    Andrew Thompson wrote:

    J R Hatch wrote:

    Andrew Thompson wrote:It would be a better experience for the end user if the frame(s) were launched using Java Web Start.


    I don't say you're wrong, but why? As it runs (if I could get it to run), there would be an applet on the page ..



    What page? Did the user click a link to get to the page? If so, change that 'link to applet page' to a 'link to JNLP' and the end user will have the same experience, except that.

  • The free floating 'name/choose a color' screen is either resizable (difficult in a web page) or the exact size it needs to be (even harder in a web page).
  • Neither the end user nor you have to deal with applet/JRE/browser interaction problems.
  • JWS can also perform desktop integration (desktop shortcut, start menu item), automatic updates or updates under programmatic control, sand-boxed access to the local file system, a built-in persistence service (to save high scores) ..and a dozen other nice little tweaks that I thought I took the time to mention in that page on JWS I linked to.

  • Did you actually read it?



    No, because I know what a web start application is. The page containing the applet was to be a page with other things on it as well, I have the size I want, I don't need desktop integration, and etc.

    But fine, I'll figure out how to do that next. I've tried the basic setup from your link and the tutorials and I keep getting redirected from the launch button to the Java page to download and install the latest Java plugin which I've already installed, so I must be doing the jnlp file incorrectly. I'll figure out how to fix that, I promise. Meanwhile, can you or someone else answer my original question? For all I know, when I run the web start application it will also only open a single dot frame, too.
     
    Andrew Thompson
    Ranch Hand
    Posts: 77
    5
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator

    J R Hatch wrote:.. can you or someone else answer my original question? ..



    I had not looked closely at it thus far, wanted to explore the webstart option first.

    As to the problem with your current code, a glance at the original post suggests it has 2 or more source files, I might have time to look at it if you can post an SSCCE.
     
    Slime does not pay. Always keep your tiny ad dry.
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com
    reply
      Bookmark Topic Watch Topic
    • New Topic