javax.swing.Popup的应用

王朝java/jsp·作者佚名  2006-01-09
窄屏简体版  字體: |||超大  

我们先来看看javax.swing.Popup的javadoc中的描述:

Popups are used to display a Component to the user, typically on top of all the other Components in a particular containment hierarchy. Popups have a very small life cycle. Once you have obtained a Popup, and hidden it (invoked the hide method), you should no longer invoke any methods on it. This allows the PopupFactory to cache Popups for later use.

The general contract is that if you need to change the size of the Component, or location of the Popup, you should obtain a new Popup.

Popup does not descend from Component, rather implementations of Popup are responsible for creating and maintaining their own Components to render the requested Component to the user.

You typically do not explicitly create an instance of Popup, instead obtain one from a PopupFactory.

大致意思就是popup可以把一个组件显示在窗口的顶层,一般说来它只有很短的生命周期……还有就是建议利用PopupFactory来获取实例。<p>

Popup的一个典型用法就是toolTip你可以从tooltip的源码中看到。

这里给出简单的例子:

Popup mypopup = PopupFactory.getSharedInstance().getPopup(frame,

new JLabel("popupwindow"), posx,posy);

mypopup.show();

这样就可以只有一个标签的窗口放在屏幕的任何位置了。

往往可以用,在鼠标移动时,来显示一些临时的信息等等。

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航