0

My friend and I have been troubleshooting this program all afternoon. I can compile this fine on my mac. However, he cannot compile it on his Windows 7 machine. We are both running Netbeans. Can someone point out what may be causing him this error. It is not liking the declaration for setBackgroundColor.

The error that is being shown is as follows....

Exception in thread "AWT-EventQueue-0" java.awt.IllegalComponentStateException: The frame is decorated
    at java.awt.Frame.setBackground(Frame.java:986)
    at FadeOut.<init>(FadeOut.java:24)
    at FadeOut$2.run(FadeOut.java:70)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
    at java.awt.EventQueue.access$200(EventQueue.java:103)
    at java.awt.EventQueue$3.run(EventQueue.java:694)
    at java.awt.EventQueue$3.run(EventQueue.java:692)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)

Code

import java.awt.Color;
import java.awt.Dimension;
import java.awt.GradientPaint;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.GridLayout;
import java.awt.Paint;
import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;

public class FadeOut extends javax.swing.JFrame
{
    public javax.swing.JPanel panel1;

 public FadeOut() 
{

        super("FadeOut");
        setBackground(new Color(0,0,0,0));//////////////Compiler doesn't like me
        setSize(new Dimension(800,800));
        setLocationRelativeTo(null);
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel panel = new JPanel()
        {
            @Override
            protected void paintComponent(Graphics g)
            {
                if (g instanceof Graphics2D)
                {
                    final int R = 100;
                    final int G = 100;
                    final int B = 100;
                    Paint p = new GradientPaint(0.f,0.f,new Color(R, G, B, 0),0.f, getHeight(), new Color(R, G, B, 0), true);
                    Graphics2D g2d = (Graphics2D)g;
                    g2d.setPaint(p);
                    g2d.fillRect(0,0,getWidth(),getHeight());
                }//END GRAPHICS2D
            }//END PAINTCOMPONENT
        };//END FRAME & PANEL TRANSLUCENT DEFINITION
        setContentPane(panel);
        init();
    }//END FadeOut CONSTRUCTOR

 public void init()
 {
     setLayout(new GridLayout(1,1));
     Border blueLine;
     blueLine = BorderFactory.createLineBorder(Color.decode("0xFF00FF"));

     panel1 = new JPanel(new GridLayout(1,1));
     panel1.setBorder(BorderFactory.createTitledBorder(blueLine,"I'm translucent bitches!!", TitledBorder.CENTER,2,null,Color.decode("0x007FF")));
     add(panel1);
 }




  public static void main(String args[])
    {
         SwingUtilities.invokeLater(new Runnable()
        {
            @Override
            public void run()
            {
                FadeOut gtw = new
                    FadeOut();
                // Display the window.
                gtw.setVisible(true);
            }//END RUN
        });//SWINGUTILITIES.INVOKELATER  
    }//END MAIN

}//END FadeOut
Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
Shane Yost
  • 231
  • 6
  • 14
  • As it works in one place and not another i sould assume it has to do with some background configuration, might start with having a look at this, and comparing the system variables and JDK's etc that you both have http://stackoverflow.com/questions/16219111/cant-transparent-and-undecorated-jframe-in-jdk7-when-enabling-nimbus – Sean F Aug 26 '13 at 01:07

1 Answers1

2

Dont forget when you get a weird exception that you cant diagnose ALWAYS look for it on the internet chances are very likely other people have had the same problem.

I searched for "java.awt.IllegalComponentStateException: The frame is decorated" and found Is The Java Tutorials Translucent Window example giving trouble to those playing with jdk7?

Community
  • 1
  • 1
ug_
  • 11,267
  • 2
  • 35
  • 52
  • Solution to the problem : **wrapper class for Frame** [refer](http://stackoverflow.com/questions/951017/java-awt-frame-setbackground-not-working-in-os-x) – Srinath Ganesh Aug 26 '13 at 01:45