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

📄 gradient.java

📁 Java学习源代码检索系统免费版
💻 JAVA
字号:
//==============================================================
// Gradient.java - Display a Color in various shades (gradients)
//
// Java学习源代码检索系统 Ver 1.0 20031015 免费正式版
// 版权所有: 中国IT认证实验室(www.ChinaITLab.com)
// 程序制作: ChinaITLab网校教研中心
// 主页地址: www.ChinaITLab.com    中国IT认证实验室
// 论坛地址: bbs.chinaitlab.com  
// 电子邮件: Java@ChinaITLab.com
//==============================================================

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Gradient extends JFrame {

// Constructor 
 public Gradient() {
  // Select local system look and feel
  try {
   UIManager.setLookAndFeel(
    UIManager.getCrossPlatformLookAndFeelClassName());
  } catch (Exception e) { }
  // End program when window closes
  addWindowListener(new WindowAdapter() {
   public void windowClosing(WindowEvent e) {
    System.exit(0);
   }
  });
 }

 public void paint(Graphics g) {
  int increment = 40;
  Rectangle r = getBounds(null);
  Color c = new Color(50, 255, 50);
  int x = 0;
  while (x < r.width) {
   g.setColor(c);
   g.fillRect(x, 0, x + increment, r.height);
   c = c.darker();
   x += increment;
  }
 }

 public static void main(String[] args) {
  Gradient app = new Gradient();
  app.setTitle("Gradient Color Demonstration");
  app.setSize(320, 240);
  app.show();
 }
}

⌨️ 快捷键说明

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