|
Author |
Topic: full-screen & setUndecorated (Read 558 times) |
|
der.clemens
|
full-screen & setUndecorated
« on: Jan 26th, 2005, 4:23pm » |
|
i'm having trouble with full-screen-mode and setUndecorated. i got this error message (processing 6 No method named "setUndecorated" was found in type "java.awt.Frame" here's the code: // full-screen main function edit by Tom Carden, // originally provided by michael05, // changed by Florian Jenett // // Os-X only, presentation mode, no java 1.4+, just a fix until processing implements it's own // // i had trouble with mouse and keyboard responses using the original code from Michael Zöllner and Tom Carden. // changed some parts (hiding dock, hiding menu, center on screen, applet-size) to fake a presentationmode on my // os-x 10.3.4. code originates from a snippet on the apple-java-list by Mark Brown. // http://lists.apple.com/archives/java-dev/2004/May/19/covereverythingincl uding.005.txt // // you might wanna check with this as well ... // http://java.sun.com/docs/books/tutorial/extra/fullscreen/ static public void main(String args[]) { // this method is not called when run from within the processing environment. // export as applet, in terminal: cd into applet folder and run (java -cp./:presentationmode.jar presentationmode) // try { // get default screendevice and configuration GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice (); GraphicsConfiguration gc = gd.getDefaultConfiguration(); Rectangle bounds = gc.getBounds(); //////////////////////////////////////////////////// // // change this to your sketch name... // Class c = Class.forName("nhifull"); BApplet applet = (BApplet) c.newInstance(); applet.init(); //applet.size(bounds.width, bounds.height); // works but need to add menu-bar height to be fullscreen // applet.start(); // frame to hide desktop and other windows ... Frame frame_hides_desktop = new Frame(); frame_hides_desktop.setUndecorated(true); frame_hides_desktop.setBackground(Color.black); frame_hides_desktop.setBounds(bounds.x, bounds.y, bounds.width, bounds.height); frame_hides_desktop.show(); Frame frame = new Frame(); frame.setUndecorated(true); frame.setBackground(Color.black); frame.setLayout(new GridBagLayout()); frame.add(applet); frame.pack(); /* // i just leave this in for documentation ... // // besides the trouble of getting processing 68 to work with java 1.4+ on os-x, // the applet stopped responding to mouse and keyboard (were not passed on to it) // test if fullscreen mode is available (jvm 1.4+) and activate it if (gd.isFullScreenSupported()) { gd.setFullScreenWindow(frame); } // test if display mode is available (jvm 1.4+) and set it to the // size of the applet if (gd.isDisplayChangeSupported()) { gd.setDisplayMode(new DisplayMode(applet.g.width, applet.g.height, 32, 0)); } */ // center applet on screen // frame.setLocation(bounds.x+(int)((bounds.width-applet.g.width)/2), bounds.y+(int)((bounds.height-applet.g.height)/2)); frame.show(); applet.requestFocus(); frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); /*frame.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) {System.out.println("clicked " + e.getX() + " " + e.getY());} public void mouseEntered(MouseEvent e) {System.out.println("entered " + e.getX() + " " + e.getY());} public void mouseExited(MouseEvent e) {System.out.println("exited " + e.getX() + " " + e.getY());} public void mousePressed(MouseEvent e) {System.out.println("pressed " + e.getX() + " " + e.getY());} public void mouseReleased(MouseEvent e) {System.out.println("released " + e.getX() + " " + e.getY());} });*/ } catch (Exception e) { e.printStackTrace(); System.exit(1); } // Hide the menu bar and dock try { // Create a classloader to use this classpath StringBuffer strPath = new StringBuffer(); strPath.append(File.separator); strPath.append("System"); strPath.append(File.separator); strPath.append("Library"); strPath.append(File.separator); strPath.append("Java"); strPath.append(File.separator); File systemPath = new File(strPath.toString()); java.net.URLClassLoader classLoader = new java.net.URLClassLoader( new java.net.URL[] {systemPath.toURL()} ); // Create the NSMenu object Class appleMenuHelper = Class.forName("com.apple.cocoa.application.NSMenu", true, classLoader); // Get access to the method we need to hide the menu bar and dock Class defArgs[] = {Boolean.TYPE}; java.lang.reflect.Method setMenuBarVisibleMethod = appleMenuHelper.getDeclaredMethod("setMenuBarVisible", defArgs); if (setMenuBarVisibleMethod != null) { // Make the menu bar and dock invisible Object nargs[] = {Boolean.FALSE}; setMenuBarVisibleMethod.invoke(appleMenuHelper, nargs); } } catch (ClassNotFoundException e) { System.err.println("Could not find NSMenu"); System.err.println(e.getMessage()); } catch (Throwable t) { System.err.println("Exception while loading the appleMenuHelper: " + t.getMessage()); t.printStackTrace(); } } its real important for me thanks, clemens
|
|
|
|
fjen
|
Re: full-screen & setUndecorated
« Reply #1 on: Jan 26th, 2005, 7:17pm » |
|
that a java 1.4 thing ... see here: Frame make sure java 1.4 is installed and you're using it. /F
|
|
|
|
der.clemens
|
Re: full-screen & setUndecorated
« Reply #2 on: Jan 26th, 2005, 8:51pm » |
|
i do this in MRJApp.properties # enable java 1.3 and higher, meaning that java 1.4 # will be used if it's installed. com.apple.mrj.application.JVMVersion=1.3+ # if you're having trouble, add a # to the line above # and remove the # from the following line: #com.apple.mrj.application.JVMVersion=1.3.1 # this will revert back to java 1.3, since 1.4 has some issues but that give a lot of errors, like. you need to modify your classpath, sourcepath, bootclasspath etc. sorry, but i don't have an idea about such things, can you help? //clemens
|
|
|
|
fjen
|
Re: full-screen & setUndecorated
« Reply #3 on: Jan 26th, 2005, 11:45pm » |
|
ja ... i had trouble with the stupid mrjapp thing as well. ended up running my fullscreen app from the command line. if that's not an option (in case you have to have a double-clickable app) use applescript to start it: http://www.florianjenett.de/p55/launcher.scpt.zip that's basicly a wrapper around the shell ... so you can add what you want to the command in the script ... even force usage of java 1.4 don't forget to change the class-name in the script with ScriptEditor and save it as application (better no startup-screen) ... /F
|
|
|
|
der.clemens
|
Re: full-screen & setUndecorated
« Reply #4 on: Jan 27th, 2005, 7:56pm » |
|
thanks
|
|
|
|
|