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

📄 firstframe.java

📁 这是一个基础的创建用户图形代码
💻 JAVA
字号:
import java.awt.*;
import javax.swing.*;
public class FirstFrame{
	public static void main(String args[]){
		SimpleFrame frame = new SimpleFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.show();
		
	}
}
class SimpleFrame extends JFrame{
	public SimpleFrame(){
		setTitle("hello");
		setSize(WIDTH,HEIGHT);
		HelloWorldPanel panel = new HelloWorldPanel();
		panel.setBackground(Color.pink);
		Container contentPane=getContentPane();
		contentPane.add(panel);
		
	}
public static final int WIDTH=300;
public static final int HEIGHT=200;
     class HelloWorldPanel extends JPanel{
	public void paint(Graphics g){
		super.paint(g);
		g.setColor(Color.green);
		Font f=new Font("宋体",Font.BOLD+Font.ITALIC,20);
		g.setFont(f);
		g.drawString("hello!",MESSAGE_X,MESSAGE_Y);
		
	}
	public static final int MESSAGE_X=75;
	public static final int MESSAGE_Y=75;
}



}

⌨️ 快捷键说明

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