To the Rose of the Lover Confession Program code--java version

Source: Internet
Author: User

1 The frame (gradual function) of the statement of confession

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.mouseclic
Ked (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 ("Wish Bao son forever happy like a flower", 60, 280);
    } class Fadeout extends Thread {private JFrame wnd;
    Public fadeout (JFrame wnd) {this.wnd = Wnd;
            	public void Run () {try {= 0; I < i++) {Thread.Sleep (50);
            Awtutilities.setwindowopacity (WND, i/50f);
        } catch (Exception ex) {ex.printstacktrace (); }
    }
}

2 Rose Frame

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 transparent form");
		Setdefaultcloseoperation (jframe.exit_on_close);
		Setundecorated (true);
		SetSize (666, 666);
		Setlocationrelativeto (null);
		Awtutilities.setwindowopaque (this, false);
		Setcontentpane (The new Panel (this));
		Addmouselistener (This) (new MoveWindow);
	}

	public static void Main (string[] args) {
		eventqueue.invokelater (new Runnable () {
			@Override public
			Void Run () {
				new Frame (). setvisible (True);}}
		);
}

3

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

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 {i = > 0; i--) {thre
                    Ad.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 Effect Chart:



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.