Java

本类阅读TOP10

·使用MyEclipse开发Struts框架的Hello World!(录像1)
·hibernate配置笔记
·AOP编程入门--Java篇
·linux下Tomcat 5.0.20 与 Apache 2 安装/集成/配置
·在win2003下整合了整合Tomcat5.5+ apache_2.0.53+ mod_jk_2.0.47.dll
·构建Linux下IDE环境--Eclipse篇
·Jsp 连接 mySQL、Oracle 数据库备忘(Windows平台)
·ASP、JSP、PHP 三种技术比较
·Tomcat5.5.9的安装配置
·AWT GUI 设计笔记(二)

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
javax.swing.Popup的应用

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

我们先来看看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();
这样就可以只有一个标签的窗口放在屏幕的任何位置了。
往往可以用,在鼠标移动时,来显示一些临时的信息等等。




相关文章

相关软件