我有两个JFrame,当点击第一个JFrame时,它会根据鼠标按下和释放的位置打开第二个JFrame。它们都是未修饰的,当我将不透明度设置为
时它可以正常工作setOpacity(0.3f);
在第一帧中,当它被点击时,第二帧的不透明度为
setOpacity(1.0f);
但是当我将第二帧的不透明度更改为1.0以下的任何值时,我得到以下错误。
线程中的异常“AWT-EventQueue-0”java.awt.IllegalComponentStateException:框架被装饰 at java.awt.Frame.setOpacity(Unknown Source) 在FrontWindow。(FrontWindow.java:26) 在BackWindow $ 3.mouseReleased(BackWindow.java:58) at java.awt.Component.processMouseEvent(Unknown Source) 在javax.swing.JComponent.processMouseEvent(未知来源) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) 在java.awt.EventQueue.access $ 200(未知来源) 在java.awt.EventQueue $ 3.run(未知来源) 在java.awt.EventQueue $ 3.run(未知来源) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain $ 1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain $ 1.doIntersectionPrivilege(Unknown Source) 在java.awt.EventQueue $ 4.run(未知来源) 在java.awt.EventQueue $ 4.run(未知来源) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain $ 1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) 在java.awt.EventDispatchThread.run(未知来源)
有谁知道错误是什么以及我如何使第二帧的不透明度小于1.0?提前谢谢。