/** * Get the BufferStrategy object needed for triple-buffering. * * @return the BufferStrategy * @throws IllegalArgumentException if this function is called when * not rendering to a JFrame */ public BufferStrategy getBufferStrategy() { if (frame != null) { return frame.getBufferStrategy(); } else { throw new IllegalArgumentException("BufferStrategy not used " + "for JComponent access"); } }
JFrame jframe = new JFrame (); ... BufferStrategy bufferstrategy = jframe.getBufferStrategy (); if (bufferstrategy == null) { jframe.createBufferStrategy(3); return; } g.dispose(); bufferstrategy.show();
public void start() { int[] pixels = ((DataBufferInt) img.getRaster().getDataBuffer()).getData(); boolean running = true; while (running) { BufferStrategy bs = frame.getBufferStrategy(); if (bs == null) { frame.createBufferStrategy(4); return; } for (int i = 0; i < width * height; i++) pixels[i] = 0; Graphics g = bs.getDrawGraphics(); g.drawImage(img, heightOffset, widthOffset, width, height, null); g.dispose(); bs.show(); } } }
public void start() { int[] pixels = ((DataBufferInt) img.getRaster().getDataBuffer()).getData(); boolean running = true; while (running) { BufferStrategy bs = frame.getBufferStrategy(); if (bs == null) { frame.createBufferStrategy(4); return; } for (int i = 0; i < width * height; i++) pixels[i] = 0; Graphics g = bs.getDrawGraphics(); g.drawImage(img, heightOffset, widthOffset, width, height, null); g.dispose(); bs.show(); } } }
public void start(){ int[] pixels = ((DataBufferInt)img.getRaster().getDataBuffer()).getData(); boolean running = true; while(running){ BufferStrategy bs = frame.getBufferStrategy(); if(bs==null){ frame.createBufferStrategy(4); return; } for (int i = 0; i < width * height; i++) pixels[i] = 0; Graphics g= bs.getDrawGraphics(); g.drawImage(img, heightOffset, widthOffset, width, height, null); g.dispose(); bs.show(); } } }
f.createBufferStrategy(2); BufferStrategy bs = f.getBufferStrategy(); while (true) { try {
final BufferStrategy bs = frame.getBufferStrategy();
bufferStrategy = frame.getBufferStrategy();