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

📄 9.9-testovals.java

📁 介绍有关java的资料 课件 相当一本书籍 里面都是很基础的知识
💻 JAVA
字号:
// TestOvals.java: Demonstrate drawing ovals
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Graphics;

public class TestOvals extends JFrame
{
  // Default constructor
  public TestOvals()
  {
    setTitle("Show Ovals");
    getContentPane().add(new OvalsPanel());
  }

  // Main method
  public static void main(String[] args)
  {
    TestOvals frame = new TestOvals();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(250, 250);
    frame.setVisible(true);
  }
}

// The class for drawing the ovals on a panel
class OvalsPanel extends JPanel
{
  public void paintComponent(Graphics g)
  {
    super.paintComponents(g);

    g.drawOval(10, 30, 100, 60);
    g.drawOval(130, 30, 60, 60);
    g.setColor(Color.yellow);
    g.fillOval(10, 130, 100, 60);
    g.fillOval(130, 130, 60, 60);
  }
}

⌨️ 快捷键说明

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