MEMon
22-08-2006, 16:59
Quando uso il fullscreen mi appare solo il canvas ma non quello che ci disegno sopra, il codice è tipo questo:
JFrame frame=new JFrame("prova");
frame.setIgnoreRepaint(true);
frame.setUndecorated(true);
GraphicsConfiguration gc = frame.getGraphicsConfiguration();
GraphicsDevice gd = gc.getDevice();
gd.setFullScreenWindow(frame);
gd.setDisplayMode(new DisplayMode(SCREEN_WIDTH,SCREEN_HEIGHT,BIT_DEPTH,REFRESH_RATE));
MyCanvas c=new MyCanvas();
frame.getContenPane().add(c);
frame.pack();
frame.setVisible(true);
public class MyCanvas implements Runnable{
BufferStrategy bs;
public MyCanvas(){
setBounds(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
setBackground(Color.blue);
}
public addNotify(){
super.addNotify();
createBufferStrategy(2);
bs=getBufferStrategy();
setVisible(true);
Thread t=new Thread(this);
t.start();
}
public void run(){
while(true){
Graphics g=bs.getDrawGraphics();
renderizza(g);
Thread.yield();
}
}
}
JFrame frame=new JFrame("prova");
frame.setIgnoreRepaint(true);
frame.setUndecorated(true);
GraphicsConfiguration gc = frame.getGraphicsConfiguration();
GraphicsDevice gd = gc.getDevice();
gd.setFullScreenWindow(frame);
gd.setDisplayMode(new DisplayMode(SCREEN_WIDTH,SCREEN_HEIGHT,BIT_DEPTH,REFRESH_RATE));
MyCanvas c=new MyCanvas();
frame.getContenPane().add(c);
frame.pack();
frame.setVisible(true);
public class MyCanvas implements Runnable{
BufferStrategy bs;
public MyCanvas(){
setBounds(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);
setBackground(Color.blue);
}
public addNotify(){
super.addNotify();
createBufferStrategy(2);
bs=getBufferStrategy();
setVisible(true);
Thread t=new Thread(this);
t.start();
}
public void run(){
while(true){
Graphics g=bs.getDrawGraphics();
renderizza(g);
Thread.yield();
}
}
}