我在我的 GWT 应用程序中使用 GXT 的 Info 类来显示消息或通知。为了使消息有点粘,我实现了自己的 Info 类版本:我创建了一个InfoConfig
实例并设置了毫秒数:config.display(int milliseconds);
问题是有时我不需要信息是“粘性的”,所以当我做其他事情时我需要隐藏它:我试图调用该hide()
方法但它不起作用!
我对 Info 类的实现:
public class StickyInfo extends Info {
private static StickyInfo info = new StickyInfo();
public StickyInfo() {
super();
}
@Override
protected void onShowInfo() {
super.onShowInfo();
}
/**
* Show the message with a title for 20sec (default duration)
*
* @param title
* the title of the message.
* @param message
* the message to display.
*/
public void show(String title, String message) {
show(title, message, 20000); // for 20sec
}
/**
* Show the message with no title for 20sec (default duration)
*
* @param message
* the message to display.
*/
public void show(String message) {
show(null, message, 20000); // for 20sec
}
/**
* Show the message for the specified number of milliseconds.
*
* @param title
* the title of the message.
* @param message
* the message to display.
* @param milliseconds
* the number of milliseconds to display the message.
*/
public void show(String title, String message, int milliseconds) {
// Configuration
InfoConfig config = new DefaultInfoConfig(title, message);
config.setDisplay(milliseconds);
// Formatting
info.setStyleName("background-color:#f9ff4f;text-align:center;"
+ "border:0x solid black; padding: 3px; font-size:11px;font-weight: bold;");
info.show(config);
// Position
// Point p = info.position();
// p.setY(p.getY() + 400);
// p.setX(0);
info.setPagePosition(info.position().getX(), 55);
}
/**
* Show the message in the given position for the number of milliseconds.
*
* @param title
* the title of the message.
* @param message
* the message to display.
* @param milliseconds
* the number of milliseconds to display the message.
*/
public void show(String title, String message, int milliseconds, int pX,
int pY) {
// Configuration
InfoConfig config = new DefaultInfoConfig(title, message);
config.setDisplay(milliseconds);
// Formatting
info.setStyleName("background-color:#f9ff4f;text-align:center;"
+ "border:0x solid black; padding: 3px; font-size:11px;font-weight: bold;");
info.show(config);
// Position
// Point p = info.position();
// p.setY(p.getY() + 400);
// p.setX(0);
info.setPagePosition(pX, pY);
}
任何指针?谢谢。