最近需要一个java实现桌面弹窗的小功能,类似于电脑桌面右下角的小广告一样的功能,在csdn上找到一个很好的一个,功能很多,我去除了一点不需要的代码,改了下外观等。
修改后的代码如下:
InfoUtil.java
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Point;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.SwingConstants;
import java.awt.Insets;
import java.awt.Toolkit;
import javax.swing.JDialog;
/**
* @author Administrator 此工具类用法:实例化出对象,调用 void show("标题","内容") 方法. InfoUtil tool
* = new InfoUtil(); tool.show("标题","内容")
*/
public class InfoUtil {
private TipWindow tw = null; // 提示框
private JPanel headPan = null;
private JPanel feaPan = null;
private JPanel btnPan = null;
private JLabel title = null; // 栏目名称
private JLabel head = null; // 蓝色标题
private JLabel close = null; // 关闭按钮
private JTextArea feature = null; // 内容
private JScrollPane jfeaPan = null;
private JButton sure = null;
private String titleT = null;
private String word = null;
private Desktop desktop = null;