⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 polylines.java

📁 主要是在网页上展示给大家一个清晰的图形用户界面
💻 JAVA
字号:
import java.applet.Applet;
import java.awt.*;
import java.awt.event.*;

public class Polylines extends Applet {
  private static Color[] colors = { 
    Color.white, Color.black, Color.blue, Color.red, 
    Color.yellow, Color.orange, Color.cyan, Color.pink, 
    Color.magenta, Color.green };

        public void init() {
          Button button = new Button("repaint");
          add(button);
          button.addActionListener(new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            Polylines.this.repaint();
          }
         });
        }
        public void paint(Graphics g) {
          int arraySize = ((int)(Math.random()*100));
          int[] xPoints = new int[arraySize];
          int[] yPoints = new int[arraySize];
        
          for(int i=0; i < xPoints.length; ++i) {
            xPoints[i] = ((int)(Math.random()*200)); 
            yPoints[i] = ((int)(Math.random()*200)); 
          }
          g.setColor(colors[(int)(Math.random()*10)]);
          g.drawPolyline(xPoints, yPoints, xPoints.length);
          showStatus(arraySize + " points");
        }
  
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -