java右下角彈窗示例分享
package com.wolf.action;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JDialog;
import javax.swing.Timer;
public class Demo extends Timer {
private static final long serialVersionUID = 2791827603307165823L;
public Demo(int arg0, ActionListener arg1) {
super(arg0, arg1);
}
public static void main(String[] args) {
MyDialog mydialog = new MyDialog();
int height = 150;
TimerAction timerAction = new TimerAction(mydialog);
Timer timer = new Timer(0, timerAction);
timer.start();
for (int i = 0; i < 10; i++) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
e.printStackTrace();
}
height = height + 5;
timerAction.setHeight(height);
}
timer.stop();
new Demo(1, timerAction);
}
}
class TimerAction implements ActionListener {
private MyDialog mydialog = null;
private int height = 0;
public void setHeight(int height) {
this.height = height;
}
public TimerAction(MyDialog mydialog) {
this.mydialog = mydialog;
}
public void actionPerformed(ActionEvent event) {
mydialog.setLocation(((int) mydialog.getScreenSize().getWidth()) - 200,
((int) mydialog.getScreenSize().getHeight() - 20 - height));
mydialog.setSize(new Dimension(200, height));
}
}
class MyDialog extends JDialog {
private static final long serialVersionUID = 2791827603307165823L;
private Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
public Dimension getScreenSize() {
return screenSize;
}
public MyDialog() {
super();
init();
}
private void init() {
this.getContentPane().setLayout(new BorderLayout());
this.setLocation(((int) screenSize.getWidth()) - 200,
((int) screenSize.getHeight() - 20));
this.setVisible(true);
this.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
}
}
相關(guān)文章
java中@DateTimeFormat和@JsonFormat注解的使用
本文主要介紹了java中@DateTimeFormat和@JsonFormat注解的使用,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2022-08-08springsecurity輕松實(shí)現(xiàn)角色權(quán)限的示例代碼
這篇文章主要介紹了springsecurity輕松實(shí)現(xiàn)角色權(quán)限的示例代碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-03-03Java的Synchronized關(guān)鍵字學(xué)習(xí)指南(全面 & 詳細(xì))
這篇文章主要給大家介紹了關(guān)于Java的Synchronized關(guān)鍵字的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2021-03-03如何在Maven項(xiàng)目配置pom.xml指定JDK版本和編碼
maven是個(gè)項(xiàng)目管理工具,如果我們不告訴它要使用什么樣的jdk版本編譯,它就會(huì)用maven-compiler-plugin默認(rèn)的jdk版本來(lái)處理,這樣就容易出現(xiàn)版本不匹配的問(wèn)題,這篇文章主要給大家介紹了關(guān)于如何在Maven項(xiàng)目配置pom.xml指定JDK版本和編碼的相關(guān)資料,需要的朋友可以參考下2024-01-01mvc架構(gòu)實(shí)現(xiàn)商品的購(gòu)買(二)
這篇文章主要為大家詳細(xì)介紹了mvc架構(gòu)實(shí)現(xiàn)商品購(gòu)買功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-11-11Spring Gateway自定義請(qǐng)求參數(shù)封裝的實(shí)現(xiàn)示例
這篇文章主要介紹了Spring Gateway自定義請(qǐng)求參數(shù)封裝的實(shí)現(xiàn)示例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-09-09