含動畫的java氣泡提示效果,右下角訊息提示窗
訊息提示框類,包含動畫的設定,以及取工作列高度
TipWindow類由網上找來經過本人修改,現將修改後的小程式發給大家試用,你們可以改的更漂亮更豐富
package test;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Image;
import java.awt.Insets;
import java.awt.Rectangle;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
/**
*
* @author lgh
*/
public class TipWindow extends JDialog implements Runnable {
private static Dimension dim;
private int x, y;
private int width, height;
private static Insets screenInsets;
public TipWindow(int width,int height){
dim = Toolkit.getDefaultToolkit().getScreenSize();
screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(this.getGraphicsConfiguration());
this.width=width;
this.height=height;
x = (int) (dim.getWidth() - width-3);
y = (int) (dim.getHeight()-screenInsets.bottom-3);
initComponents();
}
/*
* 開啟漸入效果
* 開啟後3秒,視窗自動漸出
* 若不需要漸出,註釋掉,sleep(3000)和close()方法
*/
public void run() {
for (int i = 0; i <= height; i += 10) {
try {
this.setLocation(x, y - i);
Thread.sleep(5);
} catch (InterruptedException ex) {
Logger.getLogger(TipWindow.class.getName()).log(Level.SEVERE, null, ex);
}
}
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
close();
}
private void initComponents() {
this.setSize(width, height);
this.setLocation(x, y);
this.setBackground(Color.black);
this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e) {
close();
}
});
}
public void close(){
for (int i = 0; i <= height; i += 10) {
try {
setLocation(x, y-height+i);
Thread.sleep(5);
} catch (InterruptedException ex) {
Logger.getLogger(TipWindow.class.getName()).log(Level.SEVERE, null, ex);
}
}
dispose();
}
}
測試類 TipTest
package test;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.HashMap;
import java.util.Map;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
/*
* java氣泡提示效果
* @author noobjava
* @version 1.0
* @since JDK1.6(建議)
*
*/
public class TipTest extends Thread{
private Map<String,String> feaMap=null;
public TipTest(){
feaMap=new HashMap<String,String>();
feaMap.put("name", "noobjava氣泡提醒");
feaMap.put("release", "2010-08-20 11:33:00");
feaMap.put("feature", "1.含動畫漸入與漸出效果\n2.3秒後啟動動畫漸出效果");
super.start();
}
public void run(){
final TipWindow tw=new TipWindow(300,220);
tw.setTitle("noobjava動畫氣泡提示");
JPanel headPan=new JPanel();
JPanel feaPan=new JPanel(new FlowLayout(FlowLayout.RIGHT));
JPanel btnPan=new JPanel();
JButton update=new JButton("確定");
// feaPan.setBorder(BorderFactory.createMatteBorder(1, 2, 3, 0, Color.gray));
JLabel head=new JLabel(feaMap.get("name")+",含以下功能");
head.setPreferredSize(new Dimension(250,30));
head.setForeground(Color.black);
JTextArea feature=new JTextArea(feaMap.get("feature"));
feature.setEditable(false);
feature.setForeground(Color.red);
feature.setFont(new Font("宋體",Font.PLAIN,13));
// feature.setBackground(Color.ORANGE);
feature.setPreferredSize(new Dimension(280,60));
JScrollPane jfeaPan=new JScrollPane(feature);
jfeaPan.setPreferredSize(new Dimension(283,80));
// jfeaPan.setBorder(null);
jfeaPan.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 1, Color.gray));
JLabel releaseLabel=new JLabel("釋出日期"+feaMap.get("release").substring(0,19));
releaseLabel.setForeground(Color.gray);
feaPan.add(jfeaPan);
feaPan.add(releaseLabel);
headPan.add(head);
btnPan.add(update);
tw.add(headPan,BorderLayout.NORTH);
tw.add(feaPan,BorderLayout.CENTER);
tw.add(btnPan,BorderLayout.SOUTH);
update.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e){
JOptionPane.showMessageDialog(tw, "點這裡幹嗎?點那個XX關掉嘛");
}
});
tw.setAlwaysOnTop(true);
tw.setResizable(false);
tw.setVisible(true);
tw.run();
}
public static void main(String args[]){
new TipTest();
}
}
相關文章
- reactnative實現qq聊天訊息氣泡拖拽消失效果React
- vue提示訊息Vue
- js氣泡排序動畫JS排序動畫
- e/易語言 按鈕介面彈出氣泡提示
- css3氣泡動態上升效果CSSS3
- 氣泡排序(Java)排序Java
- hp惠普插入耳機右下角提示"檢測到音訊裝置" 取消提醒彈窗音訊
- 動畫-CAShapeLayer實現QQ訊息紅點拖拽效果動畫
- JavaScript氣泡排序+Vue視覺化冒泡動畫JavaScript排序Vue視覺化動畫
- H5說話氣泡點選動畫H5動畫
- 搭建直播平臺,iYiuMessage 訊息提示元件元件
- java程式的氣泡排序操作Java排序
- 漫畫:什麼是氣泡排序?排序
- myeclipse中提示Hot Code Replace Failed提示窗錯誤EclipseAI
- 榮耀手機鎖屏訊息提示怎麼設定?榮耀手機鎖屏訊息提示的設定方法教程
- JAVA基礎--氣泡排序Java排序
- Java實現氣泡排序Java排序
- 氣泡圖繪製軟體那個專業,怎麼畫氣泡圖
- 去掉RedisDesktopManager更新提示彈窗Redis
- 直播平臺搭建,自定義氣泡效果(BubbleView)View
- 漲姿勢了,有意思的氣泡 Loading 效果
- 使用純 CSS 實現超酷炫的粘性氣泡效果CSS
- Text Messages for Mac(簡訊社交聊天彈窗對話氣泡fcpx外掛)Mac
- 【原始碼解讀】js原生訊息提示外掛原始碼JS
- 重繪DevExpress的XtraMessageBox訊息提示框控制元件devExpress控制元件
- 【排序演算法動畫解】排序介紹及氣泡排序排序演算法動畫
- 線上直播原始碼,自定義氣泡效果(BubbleView)原始碼View
- Vue ElementUI 如何修改訊息提示框樣式---messageBoxVueUI
- Java 給PPT新增動畫效果(預設動畫/自定義動畫)Java動畫
- 手機直播原始碼,文字上下滾動切換 用於公告訊息提示原始碼
- 用Java語言寫氣泡排序Java排序
- JavaScript 密碼強度提示效果JavaScript密碼
- WPF 自定義MessageBox 彈窗提示 彈窗載入
- 雕蟲曉技(十) Android超簡單氣泡效果Android
- 短視訊app原始碼,提示以按鈕彈窗的形式實現APP原始碼
- 氣泡排序排序
- OCX 控制元件主動傳送訊息給 MFC 視窗訊息控制元件
- java氣泡排序演算法實現Java排序演算法
- Java排序演算法之氣泡排序Java排序演算法