when i set the background color of my JPanel using a JColorChooser to transparent(or even semi-transparent) i get all kinds of problems. otherwise no problems at all. no similar problems with foreground.
i solved the problem that led me to the bug by changing the way i faded an image(i was doing it ass-backwards). so now there is no reason to make the JPanel background transparent. however the bug remained. it basically crashes the program. too many things to describe. my battery ran out before i could try it but i am sure i fixed it by not letting the user do that. it must be that JPanel does not like having it's background color transparent. just add a line like this.
back = new Color(back.getRed(), back.getGreen(), back.getBlue(), 255);
i forgot to mention it doesn't throw an exception. it just causes the program to crash(buttons do the wrong thing as do menu items etc.). i don't think it is my code so i wonder if Oracle knows about this problem. as for an SSCCE, think about it. the SSCCE would be almost as long as my program and i am sure you don't want me posting a dozen classes. just thought i would alert people to this problem.
Joined: Jun 13, 2009
when i set the background color of my JPanel using a JColorChooser to transparent(or even semi-transparent) i get all kinds of problems
So, based on your description of the problem, then the SSCCE would be 1 line of code (in addition to the create of the frame):
panel.setBackground( new Color(...) ); //hardcode any transparent color here.
think about it ... i am sure you don't want me posting a dozen classes
I did think about. You haven't isolated the problem and you are asking us to guess based on a single line problem statement.
i don't think it is my code
How do you know? If your code is spread out over 12 classes, maybe you made a mistake.
ps: i don't use an IDE. i jar from the command line. i have 18 class files now. i might jar the broken version for oracle if they want to see the problem but not for you.
write your own SSCCE if you don't believe me.
you are the one who is truly amazing. i told you over and over that it is not "my" problem but a problem with java. as i showed it is very easy to fix, but it should not occur in the first place. my program works fine. the user can no longer set the background of the JPanel to transparent.
since it is a paint program i have to let the user select a background color for the JPanel. i just made it so he cant select transparency
Joined: Jun 13, 2009
You still have not posted a SSCCE. So stating it is a Java problem is completely unreasonable. Just because something doesn't work the way you expect it to does not make it a problem with Java. The painting mechanism for Swing is well documented.
Based on your verbal description, it is not a problem with Java. Java supports transparent backgrounds. Your code doesn't. Again, it appears to me you do not understand how the setOpaque() method works in Java. That is not Java's problem. That is your problem. I gave you a link that explains how this works. Apparently you choose to ignore it, or still don't understand it.
Your solution to not allow transparent backgrounds is a reasonable solution if it meets your requirements. But it is not the only solution.