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

📄 paintdemo.java

📁 这是一个用java编写的关于GUI应用编程的简单的样例
💻 JAVA
字号:
package chap13.demo;

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

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2008-3-18
 * Time: 1:01:18
 * File PaintDemo.java
 */
public class PaintDemo extends JPanel {

    public PaintDemo() {
    }

    public void paint(Graphics g) {
        super.paint(g);    //To change body of overridden methods use File | Settings | File Templates.
        g.draw3DRect(100,50,100,100,true);
        g.drawOval(200,50,100,100);
        Font font=new Font("SimSun",Font.ITALIC,20);
        g.setFont(font);
        g.drawString("Welcome",100,250);
    }
    private static void createAndShowGUI() {
        //Make sure we have nice window decorations.
        JFrame.setDefaultLookAndFeelDecorated(true);

        //Create and set up the window.
        JFrame frame = new JFrame("PaintDemo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        //Create and set up the content pane.
        PaintDemo demo = new PaintDemo();
        frame.add(demo,BorderLayout.CENTER);

        //Display the window.
        frame.setSize(800,600);
        frame.setVisible(true);
    }

    public static void main(String[] args) {
        //Schedule a job for the event-dispatching thread:
        //creating and showing this application's GUI.
        for(Font f:GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts()){
            System.out.println(f);
        }
        javax.swing.SwingUtilities.invokeLater(new Runnable() {
            public void run() {
                createAndShowGUI();
            }
        });
    }

}

⌨️ 快捷键说明

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