Hi !
Featured games (84)
games approved by the League of Dukes
Games in Showcase (601)
Games in Android Showcase (171)
games submitted by our members
Games in WIP (649)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  White Background flicker on JDialog.  (Read 2424 times)
0 Members and 1 Guest are viewing this topic.
Offline zappsweden

Junior Devvie

Java games rock!

« Posted 2006-11-01 11:28:14 »

When setVisible(true) and setVisible(false) is used for my JDialogs, they often have a white bakground flashin by in the area intended for the JDialog.

For instance, i setVisible(false), i see one white rectangle (same loaction and size as my JDialog) for fractions of a second before the JDialog is gone.

Swing is double buffered, but the showing of JDialogs on top of other UI seems to be not?
 I could solve this if this white color could be set because I could then set the color to (0, 0, 0, 0) with 0 alpha no one would see it. BUT, it seems I cannot change this color. Even if I this.setBackground( on my JDialog it will be white!

Is there a way to set this white color to something else?
Offline fletchergames

Senior Devvie

« Reply #1 - Posted 2006-11-01 17:53:03 »

I had this problem before and could only "fix" it by not using JDialogs.

Are you using some kind of active rendering?  That was what I was doing when I encountered this problem.

I believe there have been some improvements for JDialogs, so you might want to try the newest version of Java 6 if you haven't already.  I don't think it'll solve this sort of problem though.
Offline Kova

Senior Devvie

« Reply #2 - Posted 2006-11-01 18:07:46 »

I remembered an issue when applet was producing white background or something like that, maybe you have similar problem:
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline zappsweden

Junior Devvie

Java games rock!

« Reply #3 - Posted 2006-11-02 10:28:55 »

I tried RUNNING (not compiling) my Java 4 code in the new Java 6 and the problems with JDialog white flickers were gone but the framerate was only like 25% of the framerate I had in 1.4

I have not compiled in Java 6 yet, but I am wondering

"What is the best Java Editor if I want Java 6 support?
Offline fletchergames

Senior Devvie

« Reply #4 - Posted 2006-11-03 00:48:08 »

I don't think Java 6 changes the language, so any editor that works with Java 5 should work with Java 6.  Eclipse seems to work just fine.

It's kind of strange that Java 6 made your game slower.  Try running the game with the argument "-Dsun.java2d.d3d=false".  For one of my games, this made it alot faster.  It's possible that the "feature" that's being turned off by that argument didn't exist (or was off by default) in Java 4.
Offline zappsweden

Junior Devvie

Java games rock!

« Reply #5 - Posted 2007-01-23 20:30:57 »

This is still a problem for me, I have not found a solution. By the way, still running Java 1.4
Offline Kova

Senior Devvie

« Reply #6 - Posted 2007-01-23 22:15:25 »

If you make basic runnable example with the problem, I would look into it.
Offline zappsweden

Junior Devvie

Java games rock!

« Reply #7 - Posted 2007-01-30 01:04:26 »

If you make basic runnable example with the problem, I would look into it.

public class YesNoDialog extends JDialog {

void jButton2_actionPerformed(ActionEvent e) {

so, very simple, the class has 2 buttons, one yes and one no and apparently stores the result so that the game can read it. When the this.setVisible(false) is execute, The next frame that gets painted when it closes is the screen like it looked before i opened the dialog BUT the area where the dialog sat on is a white rectangle.

I understand that this is some kind of buffer problem that when the dialog releases control of the buffer. I know that I start using some buffering technique so solve it but I wonder if there was any elegant solution to this that means Swing will handle it without interfering.

I tried to (from outside the dialog code) paint over the dialog and then close it afterwards but still when i close it (despite the jdialog being invisible!) the white rectangle appears.
Offline zappsweden

Junior Devvie

Java games rock!

« Reply #8 - Posted 2007-01-31 00:01:55 »

I localised the bug. Apparently it is a infamous bug under the name "gray rectangle bug". I read that the Java 6 solved that problem. So, I took my code and compiled plus ran in Java 6.

Yes, it now works, the new Java 6 handles the buffering better so i get no strange rectangles showing... but I lost like LOTS of speed!!! I even ran a profiler software and it was like everything from mouse click resposner, calculations, drawing the display took LOTS of more time!

I used as much swing components I could and been very careful not to use any deprecated stuff or to use methods that they warn will not be compatible with future releases. Anyone has experience converting from Java 1.4 or Java 5  to Java 6 and can give me some advice ?

Oh, also. When I run and comile it in Java 6 I have no errors, just some warnings like "blahblahblah is not being used" so there should not be any strange code.

Another strange thing is. If I compile and run manually from the command prompt, my project compile+run with JSDK1.4, but not with Java5 or Java6 (i compile in 5 + run in 5,  or i compile in 6 + run in 6) and I cannot make it work with my Install4j either. The only place where I can make my game run with Java 6 run is with Eclipse.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

Riven (32 views)
2015-07-27 16:38:00

Riven (16 views)
2015-07-27 15:35:20

Riven (20 views)
2015-07-27 12:26:13

Riven (10 views)
2015-07-27 12:23:39

BurntPizza (28 views)
2015-07-25 00:14:37

BurntPizza (39 views)
2015-07-24 22:06:39

BurntPizza (22 views)
2015-07-24 06:06:53

NoxInc (25 views)
2015-07-22 22:16:53

NoxInc (17 views)
2015-07-22 22:13:39

Jesse (41 views)
2015-07-22 03:10:36
List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21 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!