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

📄 flowlayouttest.java

📁 《Java程序设计与应用》-张仕斌-源程序 《Java程序设计与应用》-张仕斌-源程序
💻 JAVA
字号:
//FlowLayoutTest.java
import java.awt.*;
import javax.swing.*;

public class FlowLayoutTest extends JFrame {
	private JLabel lblPrompt = null;
	private JTextField txtInput = null;
	private JButton btnOK = null;
	
	public FlowLayoutTest() {
		super("FlowLayout Test");
		//设置当前容器的布局方式为FlowLayout
		this.getContentPane().setLayout(new FlowLayout(FlowLayout.LEADING));
		
		lblPrompt = new JLabel("请输入你的姓名:");
		txtInput = new JTextField(10);
		btnOK = new JButton("OK");
		
		//依次加入三个组件(顺序:从左到右,从上到下)
		this.getContentPane().add(lblPrompt);		
		this.getContentPane().add(txtInput);
		this.getContentPane().add(btnOK);
	}
	
	public static void main(String[]args) {
		FlowLayoutTest flt = new FlowLayoutTest();
		
		flt.setSize(400,100);
		flt.setDefaultCloseOperation(EXIT_ON_CLOSE);
		flt.setVisible(true);
	}
}

⌨️ 快捷键说明

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