Tricks to getting Java Frames working on the OLPC

Jeffrey Kesselman jeffpk at gmail.com
Mon Dec 31 18:55:10 EST 2007


Its good you found an hack... but this is definitely a hack.  As it
stands Java wouldn't pass verification on the OLPC and thus cannot be
said to be "working" yet.

Does this throw some light on what might be wrong at the matchbook level?

JK

On Dec 31, 2007 1:00 PM, Steve Lewis <smlewis at lordjoe.com> wrote:
> The following code allows Java JFrames to work properly on the OLPC -
> it assumes - only one active frame and that the frame is full screen.
> You can add it to common applications = the active sections work only on
> the OLPC
> The trick is to use showFrame and hideFrame instead of setVisible -
> these cause the frame to become the graphic environments full screen
> window -
> With this I have menus forking. I have patched JEdit to use this and
> have that application fully functional
> on the OLPC - I also have a first cut at a Sugar jedit launcher -
> Write me for code - I will look for a good place to post this
>
>     // OLPC Patch Slewis  smlewis at lordjoe.com
>     /**
>      * true of the code is running on OLPC
>      *
>      * @return as above
>      */
>     public static boolean isOLPC() {
>         String s = System.getProperty("os.name");
>         if (!s.equalsIgnoreCase("Linux"))
>             return false;
>         s = System.getProperty("os.arch");
>         if (!s.equalsIgnoreCase("i386"))
>             return false;
>         s = System.getProperty("os.version");
>         if (!s.contains(".olpc."))
>             return false;
>         return true;
>     }
>
>     /**
>      * a simgle active frame
>      */
>     private static JFrame gActiveFrame;
>
>     /**
>      * retrieve the current active frame
>      * @return possibly null active frame
>      */
>     protected static JFrame getActiveFrame() {
>         return gActiveFrame;
>     }
>
>     /**
>      * set the active frame in effect setting is visible
>      * @param pActiveFrame possibly null frame - null hides
>      * @throws IllegalStateException if there is an active frame
> different from the argument
>      */
>     protected static void setActiveFrame(JFrame pActiveFrame) throws
> IllegalStateException
>     {
>         if(gActiveFrame != null)  {
>             if(gActiveFrame == pActiveFrame)
>                 return;  // nothing to do
>             if(pActiveFrame != null) {
>                 throw new IllegalStateException("Only one active frame
> allowed");
>             }
>             else {
>                 if(gActiveFrame != null)
>                     gActiveFrame.setVisible(false);  // is this needed???
>              }
>         }
>         GraphicsEnvironment env = GraphicsEnvironment.
>                 getLocalGraphicsEnvironment();
>         GraphicsDevice[] devices = env.getScreenDevices();
>         // REMIND : Multi-monitor full-screen mode not yet supported
>         GraphicsDevice dev = devices[0];
>         boolean isFullScreen = dev.isFullScreenSupported();  // always
> true on OLPC
>         dev.setFullScreenWindow(pActiveFrame);
>         if(pActiveFrame != null)
>             pActiveFrame.setVisible(true);  // is this needed???
>         gActiveFrame = pActiveFrame;
>     }
>
>     /**
>      * Use this code instead of frame.setVisible(true)
>      *
>      * @param frame non-null frame
>      */
>     public static void showFrame(JFrame frame) {
>         // OLPC Patch
>         if (isOLPC()) {
>             setActiveFrame(frame);
>         } else {
>             frame.setVisible(true);
>         }
>     }
>
>     /**
>      * Use this code instead of frame.setVisible(false)
>      *
>      * @param frame non-null frame
>      */
>     public static void hideFrame(JFrame frame) {
>         // OLPC Patch
>         if (isOLPC()) {
>             if(getActiveFrame() == frame)
>                 setActiveFrame(null);
>         } else {
>             frame.setVisible(false);
>         }
>     }
>
> --
> Steven M. Lewis PhD
> 4221 105th Ave NE
> Kirkland, WA 98033
> 425-889-2694
> 206-384-1340 (cell)
> Skype lordjoe_com
> AIM LordJoe2000
> ICQ 127138272
> email
> smlewis at lordjoe.com (permanent)
>
> _______________________________________________
> Devel mailing list
> Devel at lists.laptop.org
> http://lists.laptop.org/listinfo/devel
>



-- 
~~ Microsoft help desk says: reply hazy, ask again later. ~~



More information about the Devel mailing list