OZONE Asylum
Forums
DHTML/Javascript
Open Source fullscreen stub for Java
This page's ID:
28405
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
And for the same price, you get the java application version of the code, which I'll use later on to demonstrate: [code] package ake; /* Applet code by Mauro Colella (c) 2006 ================ Feel free to use for personal needs. For commercial uses, include the source of this applet. ** Tips -- It is subject to security restructions when run from a browser -- works well when run from appletViewer -- Useful for inclusion in Java applications or webstarted applications -- JOGL friendly */ import java.awt.GraphicsDevice; import java.awt.*; import java.awt.image.*; import java.awt.event.*; public class appStub extends Object implements Runnable, KeyListener { GraphicsDevice context = null; private static Thread runner = null; private static Frame window = null; private static BufferStrategy strategy = null; private static BufferCapabilities capabilities = null; GraphicsConfiguration gc = null; private int i = 0; DisplayMode newDisplayMode = null, oldDisplayMode = null; // = // myDevice.getDisplayMode(); public appStub(){ super(); // TODO Auto-generated constructor stub } public void main() { appStub st = new appStub(); st.start(); } public void start() { if (runner == null) { context = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice(); gc = context.getDefaultConfiguration(); oldDisplayMode = context.getDisplayMode(); newDisplayMode = new DisplayMode(800,600,32,85); window = new Frame(gc); window.setName("Fullscreen applet"); //myWindow.setSize(800, 600); window.addKeyListener(this); window.setUndecorated(true); window.setIgnoreRepaint(true); //window.setAlwaysOnTop(true); window.setVisible(true); runner = new Thread(this); strategy = window.getBufferStrategy(); capabilities = strategy.getCapabilities(); try { context.setFullScreenWindow(window); if(context.isDisplayChangeSupported()){ context.setDisplayMode(newDisplayMode); } } catch(Exception e) { context.setFullScreenWindow(null); if(context.isDisplayChangeSupported()){ context.setDisplayMode(oldDisplayMode); } } System.out.println(capabilities.isMultiBufferAvailable()); runner.start(); } } public void run() { BufferStrategy bs; while (true) { // repaint(); //g = myWindow.getGraphics(); //if (context.isFullScreenSupported() /* /* && * context.isDisplayChangeSupported() *///) { i++; i %= window.getHeight(); try{ //window.createBufferStrategy(1,capabilities); bs = window.getBufferStrategy(); if (!bs.contentsLost()) { Graphics g = bs.getDrawGraphics(); render(g); bs.show(); g.dispose(); } } catch(Exception e){ e.printStackTrace(); } //} } } private final void render(Graphics g){ g.setColor(new Color(0, 0, 255)); g.drawLine(0, i, window.getWidth(), i); try{ Thread.sleep(1); } catch(InterruptedException e){ //e.printStackTrace(); } g.setColor(new Color(255, 255, 255)); g.drawLine(0, i, window.getWidth(), i); } public void paint(Graphics g) { //myWindow.paintComponents(myFrame.getGraphics()); } public void update() { } public void keyPressed(KeyEvent e) { runner.interrupt(); window.setVisible(false); System.exit(0); } public void keyTyped(KeyEvent e) { } public void keyReleased(KeyEvent e) { } } [/code] edit TP: Looks much nicer with [ code] tags [small](Edited by [url=http://www.ozoneasylum.com/user/1424]Tyberius Prime[/url] on 09-09-2006 18:50)[/small]
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »