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);
}
}
下一篇: MYSQL更新优化实录