“Whiteout” entire swing GUI except from one component

丶灬走出姿态 提交于 2019-12-24 09:12:57

问题


[This question is in relation to this question]

Setting: I have this home-crafted "editable label" component which looks like a label, but when you click it, it turns into an editable field, allowing you to edit it. You can hit Esc to cancel, or Shift-Enter to OK your edits - or click the respective buttons beneath the editable field.

The Challenge: When hitting edit, I want the entire UI to be "whited out", except for the edit-label's area, to clearly denote to the user where it is expected that he should focus.


回答1:


Alternative, this could be achieved using the JXLayer project. Take a look at some of their demos where they blur out the GUI when an item is selected. You would have to implement your own JXLayer view in order to white out your GUI.

Project URL: https://jxlayer.dev.java.net/

Demos are under the "getting started" item on the front page.




回答2:


You could take a look at possible usages of the glass pane ...

UPDATED due to question author's comment.

This kind of problemn is typically solved by a personnal implementation of Look'n'Feel.

Typically, the component requiring the screen will have a client property set for that purpose. The LnF, which has created a rendering compoent for that component, has also registered a listenr. When this property is set, an event is fired by component, that LnF will receive. At event reception, a glass pane is then installed over the whole container frame.



来源:https://stackoverflow.com/questions/3600040/whiteout-entire-swing-gui-except-from-one-component

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!