1 渐入功能 프레임 (书写表白语句的)
패키지 com.wanju.blessing; import java.awt.color; import java.awt.container; java.awt.dimension import; Java.awt.Font 가져 오기; java.awt.graphics 가져 오기; import java.awt.image; java.awt.toolkit import; import java.awt.event.mouseadapter; java.awt.event.mouseevent import; import java.net.url; import javax.swing.imageicon; import javax.swing.jframe; import javax.swing.jpanel; 수입 shen.panel; import com.sun.awt.awtutilities; Public Class Showframe은 Jframe {public showframe () {this.setsize (600, 500); Dimension Screensize = Toolkit.getDefaultToolKit (). getScreensize (); 치수 framesize = this.getSize (); this.setUndEcorated (true); this.setLocation ((screensize.width- framesize.width) / 2, (screensize.height- framesize.height) / 2); this.setDefaultCloseOperation (jframe.exit_on_close); 컨테이너 컨테이너 = this.getContentPane (); // awtutilities.setwindowopaque (this, true); awtutilities.setwindowopacity (this, 0.01f); container.add (new mypanel (this)); this.setbackground (null); this.set -Visible (true); 새로운 페이드 아웃 (this) .start (); } public static void main (String [] args) {showframe showframe = new showframe (); }} class myPanel은 jpanel {개인 이미지 배경; JFrame 프레임; public mypanel (최종 JFrame 프레임) {this.frame = 프레임; {url url = panel.class.getResource ( "a.jpg"); ImageIcon 아이콘 = 새로운 ImageIcon (URL); 배경 = icon.getImage (); // background = imageio.read (새 파일 ( "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.setvesible (false); dispose ()}); } catch (예외 e) {e.printstacktrace (); }} 보호 된 void paintcomponent (그래픽 g) {super.paintcomponent (g); G. drawImage (배경, 0,0,666,666, null); g.setcolor (color.red); g.setfont (new font ( "", font.bold, 15); G.DrawString ( "祝愿宝儿永远幸福的像花儿一样", 60, 280); }} 클래스 FadeOut 확장 스레드 {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 (예외 예) {ex.printstacktrace (); }}} 2 玫瑰花 프레임
패키지 Shen; java.awt.eventqueue import; import javax.swing.jframe; import com.sun.awt.awtutilities; 공개 클래스 프레임은 jframe {private static final long serialversionuid = 751757607014736983L; public frame () {settitle ( "png 透明窗体"); setDefaultCloseOperation (jframe.exit_on_close); setUndEcorated (true); setsize (666, 666); setLocationRelativeto (null); awtutilities.setwindowopaque (this, false); SetContentPane (새 패널 (this)); AddMousElistener (New MoveWindow (this)); } public static void main (string [] args) {eventqueue.invokelater (new Runnable () {@override public void run () {new Frame (). setVisible (true);}}); }}3
패키지 Shen; java.awt.graphics 가져 오기; import java.awt.image; Java.awt.Point 가져 오기; import java.awt.event.mouseadapter; java.awt.event.mouseevent import; 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; 공개 클래스 Move -Window는 MouseAdapter {개인 포인트 마지막; 개인 J 프레임 프레임; public movewindow (jframe 프레임) {this.frame = 프레임; } public void mousepressed (mouseevent e) {last = e.getLocationOnscreen (); } public void mouserEleled (mouseevent e) {point point = e.getLocationOnscreen (); 포인트 fpoint = frame.getLocation (); frame.setLocation (fpoint.x + point.x -last.x, fpoint.y + point.y -last.y); 마지막 = 포인트; }} 4
패키지 Shen; java.awt.graphics 가져 오기; import java.awt.image; import java.awt.event.mouseadapter; java.awt.event.mouseevent import; import java.net.url; import javax.swing.imageicon; import javax.swing.jframe; import javax.swing.jpanel; import com.sun.awt.awtutilities; com.wanju.blessing.showframe 가져 오기; 공개 클래스 패널은 jpanel {개인 이미지 배경; jframe frame = null; public jframe getframe () {return frame; } public void setframe (jframe frame) {this.frame = 프레임; } 공개 패널 (jframe 프레임) {this.frame = 프레임; try {// background = imageio.read (새 파일 ( "d : //workspace//maven//blessing//src//shen//window.png")); // background = imageio.read (새 파일 ( "d : //workspace//maven//blessing//src//shen//b.jpg")); url url = panel.class.getResource ( "c.jpg"); ImageIcon 아이콘 = 새로운 ImageIcon (URL); 배경 = icon.getImage (); // background = imageio.read (새 파일 ( "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 (예외 e) {e.printstacktrace (); }} 클래스 FadeOut 확장 스레드 {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 (예외 예) {ex.printstacktrace (); } wnd.setVisible (false); wnd.dispose (); 새로운 쇼 프레임 (); }} 보호 된 void paintcomponent (그래픽 g) {super.paintcomponent (g); G. drawImage (배경, 0,0,666,666, null); }}5 : :
以上就是本文的全部内容 以上就是本文的全部内容, 希望对大家的学习有所帮助, 也希望大家多多支持武林网。