CushyPro

Work3

May 10th, 2020
2,162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.75 KB | None | 0 0
  1. package CushyPro;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5.  
  6. import javax.swing.JFrame;
  7. import javax.swing.JLabel;
  8. import javax.swing.JPanel;
  9.  
  10. public class Main {
  11.  
  12.     private static int type = 0;
  13.  
  14.     public static void main(String[] args) {
  15.  
  16.         JFrame window = new JFrame("Profile");
  17.         window.setUndecorated(false);
  18.         window.pack();
  19.  
  20.         window.setSize(300, 250);
  21.         window.setVisible(true);
  22.         window.setLocationRelativeTo(null);
  23.         window.setResizable(false);
  24.         window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  25.  
  26.         JPanel panel = new JPanel();
  27.         window.setContentPane(panel);
  28.  
  29.         panel.setBackground(Color.BLACK);
  30.  
  31.         if (true) {
  32.             String n = "Name: นายวรณัชญ์ สุนามะ";
  33.             JLabel label = new JLabel();
  34.             label.setFont(new Font(null, 0, 20));
  35.             label.setForeground(Color.green);
  36.             panel.add(label);
  37.             Runing(label, n, 0);
  38.         }
  39.  
  40.         if (true) {
  41.             String n = "รหัส: 6132224013";
  42.             JLabel label = new JLabel("");
  43.             label.setFont(new Font(null, 0, 20));
  44.             label.setForeground(Color.green);
  45.             panel.add(label);
  46.             Runing(label, n, 1);
  47.         }
  48.  
  49.         if (true) {
  50.             String n = "สาขา เทคโนโลยีสารสนเทศ";
  51.             JLabel label = new JLabel("");
  52.             label.setFont(new Font(null, 0, 20));
  53.             label.setForeground(Color.green);
  54.             panel.add(label);
  55.             Runing(label, n, 2);
  56.         }
  57.  
  58.         if (true) {
  59.             String n = "Email: [email protected]";
  60.             JLabel label = new JLabel("");
  61.             label.setFont(new Font(null, 0, 20));
  62.             label.setForeground(Color.green);
  63.             panel.add(label);
  64.             Runing(label, n, 3);
  65.         }
  66.  
  67.         if (true) {
  68.             String n = "ชอบสี: ดำ";
  69.             JLabel label = new JLabel("");
  70.             label.setFont(new Font(null, 0, 20));
  71.             label.setForeground(Color.green);
  72.             panel.add(label);
  73.             Runing(label, n, 4);
  74.         }
  75.  
  76.         if (true) {
  77.             String n = "ชอบสัตว์: แมว";
  78.             JLabel label = new JLabel("");
  79.             label.setFont(new Font(null, 0, 20));
  80.             label.setForeground(Color.green);
  81.             panel.add(label);
  82.             Runing(label, n, 5);
  83.         }
  84.  
  85.         if (true) {
  86.             String n = "เกิดวันที่: 17/12/2541";
  87.             JLabel label = new JLabel("");
  88.             label.setFont(new Font(null, 0, 20));
  89.             label.setForeground(Color.green);
  90.             panel.add(label);
  91.             Runing(label, n, 6);
  92.         }
  93.  
  94.     }
  95.  
  96.     public static void Runing(JLabel label, String n, int t) {
  97.         new Thread(new Runnable() {
  98.  
  99.             int x = 0;
  100.  
  101.             @Override
  102.             public void run() {
  103.                 try {
  104.                     while (true) {
  105.                         if (type == t) {
  106.                             if (x > n.length()) {
  107.                                 type++;
  108.                                 return;
  109.                             }
  110.                             label.setText(n.substring(0, x));
  111.                             x++;
  112.                         }
  113.                         Thread.sleep(50);
  114.                     }
  115.                 } catch (Exception e) {
  116.                     e.printStackTrace();
  117.                 }
  118.             }
  119.  
  120.         }).start();
  121.     }
  122.  
  123. }
Advertisement
Add Comment
Please, Sign In to add comment