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

My pixels won't draw in the places I've put them

I'm trying to draw individual pixels to the screen using a BufferStrategy but when I run the program all the pixels are displayed werid, it's supposed to make 1 square in the top left, but it makes multiple squares that have black lines in between…
0
votes
0 answers

Game written in java swing stutters

I've got a small problem with my new project which is a Flappy Bird game written in Java. It stutters a lot. I do not know what to do. I've been looking for a solution in other topics but unfortunatelly I have no idea what is wrong. I used a Buffer…
TomD
  • 9
  • 2
0
votes
0 answers

Calling getBufferStrategy and createBufferStrategy without an object

I was watching a video on making a game in Java and saw the following code for creating a BufferStrategy object: public void render() { BufferStrategy bs = getBufferStrategy(); if bs==null { createBufferStrategy(3); return …
robzoid
  • 11
0
votes
0 answers

Buffer Stragy and Graphics object works fin in IDE, but not when exported to a jar

So, I'm working on a tile game for my programming class, and I've made some progress. but when I try and export my game to a runnable jar, it doesn't work yet works in the IDE. The render method that renders everything. private void render() { …
0
votes
0 answers

Component must have a valid peer (BufferStrategy)

So I'm making a 2D game on java and I implemented the BufferStrategy method into my game. It's stuck at this line 'this.createBufferStrategy(3);' Since then, I'm getting this error: Exception in thread "Thread-2" java.lang.IllegalStateException:…
0
votes
1 answer

What is the correct way to use createBufferStrategy()?

Even after using Java Swing for over a year, it still seems like magic to me. How do I correctly use a BufferStrategy, in particular, the method createBufferSrategy()? I would like to have a JFrame and a Canvas that gets added to it and then…
SaphirShroom
  • 90
  • 1
  • 8
0
votes
0 answers

BufferStrategy and Graphics g

I have a sprite sheet that I want to use in a src folder within the project. Here is some code I have for a simple game I am making. I get an error when trying to draw anything with the paintbrush or (g). Can you help me figure out what is wrong? I…
0
votes
1 answer

Java buffer strategy sometimes doesn't draw properly

I created a game in Java which uses buffer strategy. But sometimes I just get a white frame or a white border. That happens about every fifth time. I searched a lot but I really can't figure out what I'm doing wrong. The code compiles and there…
tobxd
  • 1
  • 1
0
votes
0 answers

Why is createBufferStrategy(3) just as fast as createBufferStrategy(3+x)?

As far as I know, you can put any int into the createBufferStrategy parameter. I've been told that there's no visible difference in buffer speed after triple buffering. Why is this?
0
votes
0 answers

BufferStrategy used with a retina display

Let me start with this small example application: public class Main extends Canvas{ public static void main(String[] args) { new Main(); } private BufferStrategy buffstrat; public Main() { JFrame frame = new…
0
votes
1 answer

BufferStrategy in windowed mode causes constant intense white screen flicker

I put this code together based on a lot of examples I found around here on stackoverflow. When I run the program the entire screen flickers intensely. I'm sure there is something simple I'm overlooking, but so far have been unable to track down a…
Orange
  • 63
  • 8
0
votes
1 answer

How to render one panel in a JFrame

I'm creating an application and as the picture below crudely illustrates there are 3 sections: a top menu (JPanel), a sidebar menu (another JPanel) and a 3rd part which I'll call the preview pane (the yellow part). The preview pane displays a…
quantum285
  • 1,032
  • 2
  • 11
  • 23
0
votes
1 answer

BufferStrategy Not Always Showing on JFrame

I have an application that is using a BufferStrategy created by a JFrame object to paint shapes. The code is pretty standard, what you would find elsewhere: // JFrame class frame.setVisible( true ); frame.createBufferStrategy( 2 ); new Logic(…
Sloth Armstrong
  • 1,066
  • 2
  • 19
  • 39
0
votes
2 answers

Swing requires createBufferStrategy(2) to properly paint

I have some grids that is painted to screen one by one. I use arrow keys to move grids around as a group. Swing is said to be doubleBuffered by default so I believe frame.createBufferStrategy(2) is a bad practice but the problem is when I don't use…
WVrock
  • 1,725
  • 3
  • 22
  • 30
0
votes
1 answer

AWT Canvas BufferStrategy and resize flickering

I am trying to make a simple game using Java2D for maximum compatibility. It is working great under Java 8 on Mac OS X Yosemite, but it is not as fluid when I try the same code under Windows 7. The canvas flickers when the JFrame is being resized…
Béatrice Cassistat
  • 1,048
  • 12
  • 37