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

📄 guidemo1.java

📁 java程序设计语言源代码
💻 JAVA
字号:
//Example 1 of Chapter 5

import java.awt.*;

public class GUIDemo1
{
	public static void main(String[] args)
	{
		Frame f = new Frame("候选人输入");
		
		Panel p1 = new Panel();
		Panel p2 = new Panel();
		Panel p3 = new Panel();
		
		Label l1 = new Label("第一候选人");
		Label l2 = new Label("第二候选人");
		Label l3 = new Label("第三候选人");
		
		TextField t1 = new TextField(20);
		TextField t2 = new TextField(20);
		TextField t3 = new TextField(20);
		
		Button b1 = new Button("输入");
		Button b2 = new Button("输入");
		Button b3 = new Button("输入");
		
		f.setLayout(new GridLayout(3,1));
		p1.setLayout(new FlowLayout());
		p2.setLayout(new FlowLayout());
		p3.setLayout(new FlowLayout());
		
		p1.add(l1);
		p1.add(t1);
		p1.add(b1);
		p1.setBackground(Color.cyan);
		
		p2.add(l2);
		p2.add(t2);
		p2.add(b2);
		p2.setBackground(Color.yellow);
		
		p3.add(l3);
		p3.add(t3);
		p3.add(b3);
		p3.setBackground(Color.pink);
		
		f.add(p1);
		f.add(p2);
		f.add(p3);
		
		f.setSize( 300 , 160 );
		f.setVisible(true);
	}
}

⌨️ 快捷键说明

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