Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (753)
Games in Android Showcase (228)
games submitted by our members
Games in WIP (842)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Java Game APIs & Engines / Java 2D / Re: Need help to structure my "laggy" graphic interface SWING on: 2012-06-04 18:08:58
Thank you for all your answers.
To simplify the code and take the problems stepby step, i tried to kept only the Frame and the buffer strategy.
Unfortunately, it seems i have another problem : the code behind should normally be working (as far I know...) unfortunatelly the line appears with a probability of 50%...

I tried it on a friend's computer and it is working perfectly fine... How is that possible ?

The main class
public class main {
   public static void main(String[] args) {
      Fenetre fen = new Fenetre();

The Frame class, "Fenetre"

   import java.awt.Cursor;
   import java.awt.Frame;
   import java.awt.Graphics;

   import java.awt.Image;
   import java.awt.Insets;
   import java.awt.Point;
   import java.awt.RenderingHints;
   import java.awt.Shape;
   import java.awt.Toolkit;
   import java.awt.Window;
   import java.awt.event.ActionEvent;
   import java.awt.event.ActionListener;
   import java.awt.event.ComponentEvent;
   import java.awt.event.ComponentListener;
   import java.awt.event.ItemEvent;
   import java.awt.event.WindowAdapter;
   import java.awt.event.WindowEvent;
   import java.awt.image.BufferStrategy;
   import java.util.Iterator;

   import javax.imageio.ImageIO;

   public class Fenetre extends Frame implements ComponentListener {

      int fenHaut = 0;
      int fenLarg = 0;
       BufferStrategy strategy;
       private Graphics           backBuffer          = null;
       private boolean            initiated           = false;

      public Fenetre() {
         fenHaut = 720;
         fenLarg = 950;
         this.setSize(fenLarg, fenHaut);

         this.addWindowListener(new WindowAdapter() {
              public void windowClosing(WindowEvent e) {

      public void setVisible(boolean b) {
           if (b & !initiated)

        * initialise l'affichage
       private void init() {
           strategy = getBufferStrategy();
           initiated = true;
      public void componentHidden(ComponentEvent arg0) {

      public void componentMoved(ComponentEvent arg0) {

      public void componentResized(ComponentEvent arg0) {

      public void componentShown(ComponentEvent arg0) {
      public void graphicalRender(){
         backBuffer = strategy.getDrawGraphics();

         backBuffer.drawString("Can you see me ?", 100, 200 );


2  Java Game APIs & Engines / Java 2D / Re: Need help to structure my "laggy" graphic interface SWING on: 2012-05-23 12:52:04
Thank you for your answer.

There were a lot of lags at start (VisualVM showed that it was because of ImageFetcher and AWT EDT), and that is why I decided to improve the JPanel paint by using a double buffering software on it...
However, the problems remains the same without this doubleBuffering. If we forget about it you'll find below part of the code. I think the main problem come from calling the swing painting with layeredPane.getGraphics.
How could i do to avoid it ?

JFrame : 

 BufferStrategy strategy = w.getBufferStrategy();
RenderingThreatHardBuffer renderingThread;

JLayeredPane layeredPane;


RenderingThreadHardBuffer :

 while (true) {
    Graphics g = strategy.getDrawGraphics();

JPanel map;
JPanel interfaceComponent1;
JPanel interfaceComponent2;
3  Java Game APIs & Engines / Java 2D / Need help to structure my "laggy" graphic interface SWING on: 2012-05-23 06:57:16
Hello everybody,

first time posting on this forum, so please be nice   Cheesy.

I am programming a 2D tiles gamebut i have some probelms of lags. Ok, my computer is quite old, and the game works perfectly fine on gamer computer, but i amsure i have a problem in my interface architecture.

I tried to improve it several time and as far as i am, my architecture is the one below :

JFrame <- JLayeredPane <- JPanel

I use the JFrame to display the whole game. It implements a double buffering hardware based on a JLayeredPane.getGraphics()...

I use the JLayeredPaneto organize all my interface : show or hide the character inventory, craft interface, overview map, etc.

JPanel are used to paint all the interface components such as the global view, the charcater inventory, overview map, etc.
Each JPanel implements a software double buffering to update their image. They are also implementing the museListener for all the player actions.

Despite all that buffers, it is still laggy and not fluent.So i am sure there is a problem coming from the way i structured everything (for example, i guess the JLayredPane.getGraphics is not very fine because it use the EDT... but i don't know any other way to do it.)

Tkank's for you'r help and advices.

Please also excuse my english... i am doing my best
Pages: [1]
ivj94 (583 views)
2018-03-24 14:47:39

ivj94 (47 views)
2018-03-24 14:46:31

ivj94 (374 views)
2018-03-24 14:43:53

Solater (61 views)
2018-03-17 05:04:08

nelsongames (108 views)
2018-03-05 17:56:34

Gornova (150 views)
2018-03-02 22:15:33

buddyBro (693 views)
2018-02-28 16:59:18

buddyBro (91 views)
2018-02-28 16:45:17

xxMrPHDxx (493 views)
2017-12-31 17:17:51

xxMrPHDxx (732 views)
2017-12-31 17:15:51
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!