The code test is available, and the running results are very eye-catching, and it feels like the loss is not mainstream that is popular among primary and secondary school students in the early 21st century!
It is still of more reference value, obtaining the current date and time, date class formatting, graphic interface development, etc.
Java awt implements dynamic flash diagram source code example: I Iove You, it is not convenient to intercept dynamic diagrams. Here we only intercept png format diagrams for reference, and you can test it yourself.
package cn.ecit.iloveyou;import java.awt.Color;import java.awt.Font;import java.awt.Frame;import java.awt.Graphics;import java.awt.event.WindowEvent;import java.awt.event.WindowListener;import java.util.Date;public class ILoveYou extends Frame implements Runnable {public ILoveYou() {// this.setComponentZOrder(this, 2); this.setBounds(Constant.X, Constant.Y, Constant.WIDTH, Constant.HEIGHT); this.setTitle(Constant.string); this.setVisible(true); this.setBackground(Color.BLACK); this.setExtendedState(MAXIMIZED_BOTH); this.addWindowListener(new WindowListener() {@Override public void windowOpened(WindowEvent e) {}@Override public void windowIconified(WindowEvent e) {// TODO Auto-generated method stub}@Override public void windowDeiconized(WindowEvent e) {// TODO Auto-generated method stub}@Override public void windowDeactivated(WindowEvent e) {// TODO Auto-generated method stub}@Override public void windowClosing(WindowEvent e) {System.exit(0);}@Override public void windowClosed(WindowEvent e) {// TODO Auto-generated method stub}@Override public void windowActivated(WindowEvent e) {// TODO Auto-generated method stub}});}public void paint(Graphics g) {for (int i = 0; i < 500; i++) {g.setColor(new Color((int) (Math.random() * 256), (int) (Math .random() * 256), (int) (Math.random() * 256)));g.drawString("★", (int) (Math.random() * 1366), (int) (Math .random() * 1366), (int) (Math .random() * 768));}g.setFont(new Font("Microsoft Yahei", Font.BOLD, 150));g.drawString(Constant.string, Constant.X - 80, Constant.Y + 250);g.setColor(new Color((int) (Math.random() * 256), (int) (Math.random() * 256), (int) (Math.random() * 256)));g.drawString(new Date().toLocaleString(), 5, 200);g.setColor(new Color((int) (Math.random() * 256), (int) (Math.random() * 256), (int) (Math.random() * 256)));g.setFont(new Font("Microsoft Yahei", Font.BOLD, 200));g.drawString(Constant.string1, 100, 650);}@Override public void run() {while (true) {try {Thread.sleep(500);}catch (Exception e) {e.printStackTrace();}repaint();}}public static void main(String[] args) {new Thread(new ILoveYou()).start();}} package cn.ecit.iloveyou;import java.awt.Toolkit;public class Constant {static final int WIDTH = 800;static final int HEIGHT = 450;static final int X = (Toolkit.getDefaultToolkit().getScreenSize().width - WIDTH) / 2;static final int Y = (Toolkit.getDefaultToolkit().getScreenSize().height - HEIGHT) / 2;static final int WIDTH_BUFF = 300;static final int HEIGHT_BUFF = 100;static final int X_BUFF = (WIDTH - WIDTH_BUFF) / 2;static final int Y_BUFF = (HEIGHT - HEIGHT_BUFF) / 2;static final String string = "I LOVE YOU !";static final String string1 = "★ Lifelong★";}Running results:
Summarize
The above is all about the romance exclusive to programmers - Java output dynamic flash map iloveyou, I hope it will be helpful to everyone. Interested friends can continue to refer to this site:
Detailed explanation of Java graphical interface design container (JFrame)
Java implements the console output distance between two points
The basics of Java programming: imitating user login code sharing
If there are any shortcomings, please leave a message to point it out.