时间:2021-05-02
1 书写表白语句的frame(渐入功能)
? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 package com.wanju.blessing; import java.awt.color; import java.awt.container; import java.awt.dimension; import java.awt.font; import java.awt.graphics; import java.awt.image; import java.awt.toolkit; import java.awt.event.mouseadapter; import java.awt.event.mouseevent; import java.net.url; import javax.swing.imageicon; import javax.swing.jframe; import javax.swing.jpanel; import shen.panel; import com.sun.awt.awtutilities; public class showframe extends jframe { public showframe() { this.setsize(600, 500); dimension screensize = toolkit.getdefaulttoolkit().getscreensize(); dimension framesize = this.getsize(); this.setundecorated(true); this.setlocation((screensize.width - framesize.width) / 2, (screensize.height - framesize.height) / 2); this.setdefaultcloseoperation(jframe.exit_on_close); container container = this.getcontentpane(); // awtutilities.setwindowopaque(this, true); awtutilities.setwindowopacity(this, 0.01f); container.add(new mypanel(this)); this.setbackground(null); this.setvisible(true); new fadeout(this).start(); } public static void main(string[] args) { showframe showframe = new showframe(); } } class mypanel extends jpanel{ private image background; jframe frame; public mypanel(final jframe frame){ this.frame = frame; try { url url=panel.class.getresource("a.jpg"); imageicon icon = new imageicon(url); background = icon.getimage() ; // background = imageio.read(new file("d:\\workspace\\maven\\blessing\\src\\shen\\b.jpg")); this.addmouselistener(new mouseadapter() { @override public void mouseclicked(mouseevent e) { super.mouseclicked(e); // new fadeout(mypanel.this.frame).start(); frame.setvisible(false); frame.dispose(); } }); } catch (exception e) { e.printstacktrace(); } } protected void paintcomponent(graphics g) { super.paintcomponent(g); g.drawimage(background,0,0,666,666,null); g.setcolor(color.red); g.setfont(new font("", font.bold, 15)); g.drawstring("祝愿宝儿永远幸福的像花儿一样", 60, 280); } } class fadeout extends thread { private jframe wnd; public fadeout(jframe wnd) { this.wnd = wnd; } public void run() { try { for (int i = 0; i < 50; i++) { thread.sleep(50); awtutilities.setwindowopacity(wnd, i / 50f); } } catch (exception ex) { ex.printstacktrace(); } } }2 玫瑰花frame
? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 package shen; import java.awt.eventqueue; import javax.swing.jframe; import com.sun.awt.awtutilities; public class frame extends jframe { private static final long serialversionuid = 7517576070147366983l; public frame() { settitle("png透明窗体"); setdefaultcloseoperation(jframe.exit_on_close); setundecorated(true); setsize(666, 666); setlocationrelativeto(null); awtutilities.setwindowopaque(this, false); setcontentpane(new panel(this)); addmouselistener(new movewindow(this)); } public static void main(string[] args) { eventqueue.invokelater(new runnable() { @override public void run() { new frame().setvisible(true); } }); } }3
? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 package shen; import java.awt.graphics; import java.awt.image; import java.awt.point; import java.awt.event.mouseadapter; import java.awt.event.mouseevent; import java.net.url; import javax.swing.imageicon; import javax.swing.jframe; import javax.swing.jpanel; import com.sun.awt.awtutilities; import shen.panel.fadeout; public class movewindow extends mouseadapter { private point last; private jframe frame; public movewindow(jframe frame) { this.frame = frame; } public void mousepressed(mouseevent e) { last = e.getlocationonscreen(); } public void mousereleased(mouseevent e) { point point = e.getlocationonscreen(); point fpoint = frame.getlocation(); frame.setlocation(fpoint.x + point.x - last.x, fpoint.y + point.y - last.y); last = point; } }4
? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 package shen; import java.awt.graphics; import java.awt.image; import java.awt.event.mouseadapter; import java.awt.event.mouseevent; import java.net.url; import javax.swing.imageicon; import javax.swing.jframe; import javax.swing.jpanel; import com.sun.awt.awtutilities; import com.wanju.blessing.showframe; public class panel extends jpanel{ private image background; jframe frame = null; public jframe getframe() { return frame; } public void setframe(jframe frame) { this.frame = frame; } public panel(jframe frame){ this.frame = frame; try { // background = imageio.read(new file("d:\\workspace\\maven\\blessing\\src\\shen\\window.png")); // background = imageio.read(new file("d:\\workspace\\maven\\blessing\\src\\shen\\b.jpg")); url url=panel.class.getresource("c.jpg"); imageicon icon = new imageicon(url); background = icon.getimage() ; // background = imageio.read(new file("d:\\workspace\\maven\\blessing\\src\\shen\\b.jpg")); this.addmouselistener(new mouseadapter() { @override public void mouseclicked(mouseevent e) { super.mouseclicked(e); new fadeout(panel.this.frame).start(); } }); } catch (exception e) { e.printstacktrace(); } } class fadeout extends thread { private jframe wnd; public fadeout(jframe wnd) { this.wnd = wnd; } public void run() { try { for (int i = 50; i > 0; i--) { thread.sleep(50); awtutilities.setwindowopacity(wnd, i / 50f); } } catch (exception ex) { ex.printstacktrace(); } wnd.setvisible(false); wnd.dispose(); new showframe(); } } protected void paintcomponent(graphics g) { super.paintcomponent(g); g.drawimage(background,0,0,666,666,null); } }5 效果图:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。
原文链接:https://blog.csdn.net/cgwcgw_/article/details/19899169
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
情人节快乐!这个节日怎么会少了浪漫的玫瑰花!用Python的turtle库绘图是很简单的,画了一个玫瑰花,下面奉上源码:源码:'''CreatedonNov18
今年的情人节,与以往最大的不同是口罩成了最好的礼物。微博上,情人节礼物的话题里,口罩打败了玫瑰花,成为爱的最好表达。有的人把口罩放进花束里送给爱人;而有人的花束
2月14日“情人节”,各路商家又想法设法做好节日经济,尤其是具有畅销优势的玫瑰花和巧克力市场,更是呈现量价齐升的局面。记者走访发现,今年,市场上的进口玫瑰花的价
本文实例讲述了javascript+HTML5的canvas实现七夕情人节3D玫瑰花效果。分享给大家供大家参考。具体如下:下面的玫瑰绘制用到了HTML5的can
送你999朵玫瑰花.版本2.程序集窗口程序集1.子程序__启动窗口_创建完毕.局部变量屏幕快照,字节集屏幕快照=快照(,,)_启动窗口.可视=真_启动窗口.位置