Questions tagged [bufferstrategy]

The BufferStrategy is a Java class representing the mechanism used to organize complex memory on a certain AWT Canvas or Window. Use this tag for general questions related to creating or managing a BufferStrategy.

Official Documentation:

75 questions
0
votes
0 answers

Rendering transparent pixels to BufferStrategy/BufferedImage cause bleeding/not updating

I honestly cannot find an answer to the problem I'm having. I'm making a game engine with Java and I have a function called render: public void Render() { List> cachedBuffer = new ArrayList>(buffer); …
decduck3
  • 48
  • 8
0
votes
0 answers

Problems with thread and bufferstrategy: IllegalStateException: Component must have a valid peer

Here is the code that I tried to execute, but failed: public class Game extends Canvas implements Runnable,KeyListener { private static final long serialVersionUID = 1L; private static Thread thread ; private int width = 240; …
0
votes
1 answer

Problem with NullPointerException in Animation method

I'm not very good at programming, it's my very first programme which uses Swing and AWT libraries. I have a problem while buffering my gameview. Here's the code of my Gra (game) class. This class uses some attributes like xPredkoscMax (xMaxVelocity)…
0
votes
0 answers

Why does my program has an error in the render method?

So I'm trying to build my first game loop and yes, I've watched a tutorial on this but can't seem to find what's wrong. Every time I run my program, the image doesn't show on frame and also, it keeps telling me errors in the render method and where…
0
votes
2 answers

How can I paint an image from BufferStrategy to Png file?

I've created a Java program that generates snowflakes and I'd like to save the image created as a .png file once the program finishes drawing. I've searched on Internet, but I've found only programs using BufferedImage, while I use a BufferStrategy,…
0
votes
1 answer

JPanel position whacked by BufferStrategy

I have a JFrame to which I add a JPanel. I'm doing some animation, so I implement a BufferStrategy for rendering. I also a rendering loop to keep it rendering while running. If I run the program like normal, the JPanel renders correctly. Of course,…
Frecklefoot
  • 1,660
  • 2
  • 21
  • 52
0
votes
1 answer

Java - how to create bufferedStrategy to jframe

i'm new using java2D and java Graphics i have some issue while using BufferStrategy in java, i tried solve but it doesn't work, while creating a BufferStrategy it gives errors like this... Exception in thread "Thread-0"…
0
votes
0 answers

Is setting the BufferStrategy every time the game renders a good idea?

For some reason everyone sets their BufferStrategy to the BufferStrategy in their canvas whenever they render their game. BufferStrategy bs; Graphics2D g; private void render() { bs = window.getCanvas().getBufferStrategy(); if (bs…
user8492997
0
votes
0 answers

Java Abstract Class - What is going on here?

I've been searching/reading docs from Oracle for about 2 hours, and I'm pretty stumped. I had thought I understood what an abstract class was, and how it was used (at a basic level, at least). I'm still fairly new to all this, so bear with me…
0
votes
0 answers

Trying to animate in Java, but not sure how to go about it

I am working on trying to make a game as a side project with a few friends of mine. But I am kind of stuck at animating in java. private void render() {//Everything that renders BufferStrategy bs = this.getBufferStrategy(); if (bs ==…
Auti
  • 23
  • 3
0
votes
0 answers

How to convert from using Canvas to using JPanel?

I want to use JPanel to display the Game content as of now I was able to use canvas. This is what I have. import java.awt.*; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.image.BufferStrategy; …
0
votes
1 answer

KeyEvent not getting generated due to BufferStrategy

So I'm making a game, and my main Game application is running fine. The problem is, when I try to launch my game through a menu (using a button ActionEvent, for instance), my game can't seem to detect KeyEvents given to it. So I decided to make a…
SaintSix_
  • 103
  • 2
0
votes
1 answer

Screen objects sometimes not rendering

I am a mildly experienced programmer who has created several game engine templates and small 2d games in Java. I am currently expanding to 3d game engines and am re-writing a previous engine to be more adaptive and Object-oriented. My issue is, and…
Ryan
  • 1
  • 2
0
votes
1 answer

BufferStrategy cleans Frame background

I have tried to make a simple GUI in Java Using graphics2D and JFrame. I have added a background-color on JFrame typing this.setBackground(new Color(54, 71, 99)) inside initWindow() method. It turned out that backBuffer was clearing that background…
Feelsbadman
  • 1,163
  • 4
  • 17
  • 37
0
votes
1 answer

Java buffer strategy Multi Driver display

I am creating an application in java using the buffer strategy. The only problem is when I use the buffer strategy maximized on my integrated graphics, it crashes with this error: Exception in thread "Thread-2" java.lang.IllegalStateException:…
Dick Jon
  • 1
  • 2