亚洲精品中文字幕无乱码_久久亚洲精品无码AV大片_最新国产免费Av网址_国产精品3级片

JAVA認(rèn)證

Java怎么編寫走馬燈程序

時(shí)間:2024-10-07 06:24:08 JAVA認(rèn)證 我要投稿
  • 相關(guān)推薦

Java怎么編寫走馬燈程序

  走馬燈程序怎么編寫呢,不用急,下面小編準(zhǔn)備了關(guān)于Java怎么編寫走馬燈程序的文章,提供給大家參考!

  package clock;

  import java.awt.*;

  import java.awt.event.*;

  import javax.swing.*;

  import java.util.Calendar;

  import java.util.Date;

  import java.text.*;

  public class removingLight extends JFrame {

  public removingLight() {

  Font font1 = new Font("幼圓", Font.BOLD, 16);

  Calendar cal = Calendar.getInstance();

  SimpleDateFormat formatter = new SimpleDateFormat(

  "EEEE,MMMMdd日,yyyy年 HH:mm:ss");

  String mDateTime = formatter.format(cal.getTime());

  MovingMessagePanel messagePanel = new MovingMessagePanel(mDateTime);

  messagePanel.setFont(font1);

  messagePanel.setBackground(Color.BLACK);

  messagePanel.setForeground(Color.PINK);

  add(messagePanel);

  }

  public static void main(String[] args) {

  removingLight frame = new removingLight();

  JLabel label = new JLabel("開始調(diào)試時(shí)間:5月5日 結(jié)束調(diào)試時(shí)間:5月6日");

  label.setBackground(Color.black);

  frame.setTitle("軟件1班 XXX 3107006757");

  frame.setLocationRelativeTo(null);

  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  frame.setSize(320, 120);

  frame.setVisible(true);

  frame.add(label, BorderLayout.SOUTH);

  }

  static class MovingMessagePanel extends JPanel {

  private String message = " ";

  private int xCoordinate = 0;

  private int yCoordinate = 40;

  public MovingMessagePanel(String message) {

  this.message = message;

  Timer timer = new Timer(100, new TimerListener());

  timer.start();

  }

  public void paintComponent(Graphics g) {

  super.paintComponent(g);

  if (xCoordinate > getWidth()) {

  xCoordinate = -100;

  }

  xCoordinate += 5;

  g.drawString(message, xCoordinate, yCoordinate);

  }

  class TimerListener implements ActionListener {

  public void actionPerformed(ActionEvent e) {

  repaint();

  }

  }

  }

  }

【Java怎么編寫走馬燈程序】相關(guān)文章:

java編寫即時(shí)聊天程序06-12

Java程序編寫記事本方法大全09-04

Java編寫計(jì)算器的的常見做法07-08

sun認(rèn)證java程序員須知Java日志框架09-05

怎么安裝java環(huán)境09-13

java程序中如何調(diào)用linux命令06-13

初級(jí)java程序員任職要求07-07

初級(jí)java程序員面試要求07-12

Java程序員面試題及答案09-23

java初級(jí)程序員面試題「經(jīng)典」07-24