Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
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 1840 times)
0 Members and 1 Guest are viewing this topic.
Offline zappsweden

Junior Member




Java games rock!


« Posted 2006-11-01 12: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(Color.red) on my JDialog it will be white!

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

Senior Member





« Reply #1 - Posted 2006-11-01 18: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 Member





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

I remembered an issue when applet was producing white background or something like that, maybe you have similar problem:
http://www.java-gaming.org/forums/index.php?topic=14290.0
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline zappsweden

Junior Member




Java games rock!


« Reply #3 - Posted 2006-11-02 11: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 Member





« Reply #4 - Posted 2006-11-03 01: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 Member




Java games rock!


« Reply #5 - Posted 2007-01-23 21: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 Member





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

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

Junior Member




Java games rock!


« Reply #7 - Posted 2007-01-30 02: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) {
    this.yes=false;
    this.setVisible(false);
  }



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 Member




Java games rock!


« Reply #8 - Posted 2007-01-31 01: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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (37 views)
2014-04-15 18:08:23

BurntPizza (33 views)
2014-04-15 03:46:01

UprightPath (48 views)
2014-04-14 17:39:50

UprightPath (31 views)
2014-04-14 17:35:47

Porlus (48 views)
2014-04-14 15:48:38

tom_mai78101 (69 views)
2014-04-10 04:04:31

BurntPizza (129 views)
2014-04-08 23:06:04

tom_mai78101 (229 views)
2014-04-05 13:34:39

trollwarrior1 (193 views)
2014-04-04 12:06:45

CJLetsGame (200 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org 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‑gaming.org
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!