Results 1 to 11 of 11
Like Tree2Likes
  • 1 Post By KevinWorkman
  • 1 Post By Norm

Thread: Too-tall form with its head in the clouds (plural, not "The Cloud")

  1. #1
    blackbird is offline Senior Member
    Join Date
    Jul 2011
    Posts
    100
    Rep Power
    0

    Default Too-tall form with its head in the clouds (plural, not "The Cloud")

    I have this code to center a form on the screen:

    Java Code:
    frame.setLocationRelativeTo(null);
    It works fine on my dev machine (XP), but on another (W2K), the top of the form is up out of sight, and I cannot reach the title bar to move it down or the close button to close it (Alt+F4 works, of course).

    What is my recourse? I don't want to reduce the height of the form...

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default

    Is the window taller than the resolution of the screen?

    You could get the resolution of the screen and set the location of the window based on that: Toolkit (Java Platform SE 6)

    Or you could get the center point and do something similar: GraphicsEnvironment (Java Platform SE 6)
    blackbird likes this.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    blackbird is offline Senior Member
    Join Date
    Jul 2011
    Posts
    100
    Rep Power
    0

    Default

    I installed the same runnable jar file on another machine and, when I tried to run it, got "Could not find the main class"

    What the deuce? These are all Windows machines; on one (the dev machine) it runs fine, on another it runs but also runs out of real estate, and on the third one it doesn't run at all. It reminds me of the problem Yogi Berra had with his catchers when he was managing the Yankees.

  4. #4
    blackbird is offline Senior Member
    Join Date
    Jul 2011
    Posts
    100
    Rep Power
    0

    Default

    Quote Originally Posted by KevinWorkman View Post
    Is the window taller than the resolution of the screen?

    You could get the resolution of the screen and set the location of the window based on that: Toolkit (Java Platform SE 6)

    Or you could get the center point and do something similar: GraphicsEnvironment (Java Platform SE 6)
    Changing the resolution fixed it; one would think that if a portion of a form gets "cut off" it would be the bottom, not the top.

    I'm still wondering why on the third machine it won't run at all. Maybe on out-dated version of the JVM is installed there? Would that [not] do it?

  5. #5
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,308
    Rep Power
    25

    Default

    won't run at all
    You need to see if there are error messages.
    Open a command prompt, change to the directory with the jar file and enter:
    java - jar THEJARFILENAME.jar

    To copy the contents of the command prompt window:
    Click on Icon in upper left corner
    Select Edit
    Select 'Select All' - The selection will show
    Click in upper left again
    Select Edit and click 'Copy'

    Paste here.
    blackbird likes this.

  6. #6
    blackbird is offline Senior Member
    Join Date
    Jul 2011
    Posts
    100
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    Paste here.
    Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.

    C:\Documents and Settings\JCP Associate>cd..

    C:\Documents and Settings>cd..

    C:\>cd misc

    C:\Misc>java -jar jawa.jar
    Exception in thread "main" java.lang.UnsupportedClassVersionError: com/jcp/tds/R
    T_TCP_JCP_TDS_OO_State_SortSim (Unsupported major.minor version 50.0)
    at java.lang.ClassLoader.defineClass0(Native Method)
    at java.lang.ClassLoader.defineClass(Unknown Source)
    at java.security.SecureClassLoader.defineClass(Unknow n Source)
    at java.net.URLClassLoader.defineClass(Unknown Source)
    at java.net.URLClassLoader.access$100(Unknown Source)
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    C:\Misc>

  7. #7
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    one would think that if a portion of a form gets "cut off" it would be the bottom, not the top.
    The documented behaviour of setLocaltionRelativeTo() is to center the window on the screen.

    Unsupported major.minor version 50.0
    You have compiled for 1.6 but are running with an older runtime. (You can check this with "java -version")

  8. #8
    blackbird is offline Senior Member
    Join Date
    Jul 2011
    Posts
    100
    Rep Power
    0

    Default

    Quote Originally Posted by pbrockway2 View Post
    The documented behaviour of setLocaltionRelativeTo() is to center the window on the screen.
    Yes, that's why I use it - I hate the default NW corner thing, as if the Java architects were chanting "Fifty-four Forty or Fight!" It makes me mad at the Brits all over again.

    Quote Originally Posted by pbrockway2 View Post
    You have compiled for 1.6 but are running with an older runtime. (You can check this with "java -version")
    That's what I sussed. What's the best place to download the latest runtime? Just Google "Java runtime"?

  9. #9
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,932
    Rep Power
    8

    Default

    Quote Originally Posted by blackbird View Post
    What's the best place to download the latest runtime? Just Google "Java runtime"?
    That'll probably work. What did you find when you tried it?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  10. #10
    blackbird is offline Senior Member
    Join Date
    Jul 2011
    Posts
    100
    Rep Power
    0

    Default

    Quote Originally Posted by KevinWorkman View Post
    That'll probably work. What did you find when you tried it?
    I haven't yet; I haven't even gone to that other machine today yet (but I will).

  11. #11
    blackbird is offline Senior Member
    Join Date
    Jul 2011
    Posts
    100
    Rep Power
    0

    Default

    Quote Originally Posted by blackbird View Post
    I haven't yet; I haven't even gone to that other machine today yet (but I will).
    It works now, after installing JRT 6.26 on that machine.

Similar Threads

  1. Replies: 5
    Last Post: 07-16-2011, 12:01 AM
  2. Replies: 5
    Last Post: 07-13-2011, 02:25 PM
  3. Help with "Head First Java" quiz
    By TheWhopper in forum New To Java
    Replies: 6
    Last Post: 06-04-2011, 06:09 AM
  4. Replies: 1
    Last Post: 01-21-2010, 09:20 AM
  5. Replies: 1
    Last Post: 10-20-2008, 07:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •