• <sub id="h4knl"><ol id="h4knl"></ol></sub>
    <sup id="h4knl"></sup>
      <sub id="h4knl"></sub>

      <sub id="h4knl"><ol id="h4knl"><em id="h4knl"></em></ol></sub><s id="h4knl"></s>
      1. <strong id="h4knl"></strong>

      2. Java怎么編寫走馬燈程序

        時間:2024-08-19 07:56:41 JAVA認證 我要投稿
        • 相關推薦

        Java怎么編寫走馬燈程序

          走馬燈程序怎么編寫呢,不用急,下面小編準備了關于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("開始調試時間:5月5日 結束調試時間: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();

          }

          }

          }

          }

        《&.doc》
        将本文的Word文档下载到电脑,方便收藏和打印
        推荐度:
        点击下载文档

        【Java怎么編寫走馬燈程序】相關文章:

        Java怎么編寫Oracle存儲過程03-20

        如何編譯java程序03-05

        Java編寫計算器的的常見做法01-22

        實現鼠標畫圖的Java程序03-16

        Java程序開發與運行環境03-05

        sun認證java程序員須知Java日志框架03-30

        如何使用Swing編寫全屏程序03-21

        怎么安裝java環境03-29

        初級java程序員任職要求03-29

        在线咨询
        国产高潮无套免费视频_久久九九兔免费精品6_99精品热6080YY久久_国产91久久久久久无码
      3. <sub id="h4knl"><ol id="h4knl"></ol></sub>
        <sup id="h4knl"></sup>
          <sub id="h4knl"></sub>

          <sub id="h4knl"><ol id="h4knl"><em id="h4knl"></em></ol></sub><s id="h4knl"></s>
          1. <strong id="h4knl"></strong>

          2. 欧美大片一级中文字幕 | 日韩欧美理论在线观看 | 色久综合网精品一区二区 | 天天噜啦在线播放 | 亚洲欧美综合另类久久精品 | 婷婷六月中文字幕 |

            Java怎么編寫走馬燈程序

              走馬燈程序怎么編寫呢,不用急,下面小編準備了關于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("開始調試時間:5月5日 結束調試時間: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();

              }

              }

              }

              }