0

我有两个 JFrame,当单击第一个 JFrame 时,它​​会根据按下和释放鼠标的位置打开第二个。它们都没有装饰,当我将不透明度设置为时它工作正常

setOpacity(0.3f);

在第一帧中,当它被点击时,第二帧的不透明度是

setOpacity(1.0f);

但是,当我将第二帧的不透明度更改为 1.0 以下的任何值时,我会收到以下错误。

线程“AWT-EventQueue-0”java.awt.IllegalComponentStateException 中的异常:框架在 BackWindow$3.mouseReleased(BackWindow. java:58) 在 java.awt.Component.processMouseEvent(Unknown Source) 在 javax.swing.JComponent.processMouseEvent(Unknown Source) 在 java.awt.Component.processEvent(Unknown Source) 在 java.awt.Container.processEvent(Unknown源) 在 java.awt.Component.dispatchEventImpl(Unknown Source) 在 java.awt.Container.dispatchEventImpl(Unknown Source) 在 java.awt.Component.dispatchEvent(Unknown Source) 在 java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)在 java.awt 的 java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)。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) at java.awt.EventQueue.access$200(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController .doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt。 java.security.AccessController 中的 EventQueue$4.run(Unknown Source)。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 (未知来源)在 java.awt.EventDispatchThread.pumpEvents(未知来源)在 java.awt.EventDispatchThread.pumpEvents(未知来源)在 java.awt.EventDispatchThread.run(未知来源)在 java.awt.EventDispatchThread.pumpEventsForHierarchy(未知来源)资源)pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(来源不明)pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(来源不明)

有谁知道错误是什么以及如何使第二帧的不透明度小于 1.0?提前致谢。

4

0 回答 0