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

📄 flowlayoutuse.java

📁 JAVA编程思想源代码 值得一下 很难找的
💻 JAVA
字号:
package chapter11;

import java.awt.Button;
import java.awt.FlowLayout;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

public class FlowLayoutUse {

	private static int state = 0;

	public static void main(String[] args) {
		final Frame fm = new Frame("new Frame with FlowLayout!");
		final FlowLayout fl = new FlowLayout(state);
		fm.setLayout(fl);
		Button bu = new Button("press me please!");
		Button b1 = new Button("no action!");
		Button b2 = new Button("no action!");
		fm.add(b1);
		fm.add(b2);
		bu.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent e) {
				switch (state) {

				case 0:
					fl.setAlignment(1);
					state = 1;
					fl.layoutContainer(fm);
					break;
				case 1:
					fl.setAlignment(2);
					state = 2;
					fl.layoutContainer(fm);
					break;
				case 2:
					fl.setAlignment(3);
					state = 3;
					fl.layoutContainer(fm);
					break;
				case 3:
					fl.setAlignment(4);
					state = 4;
					fl.layoutContainer(fm);
					break;
				case 4:
					fl.setAlignment(0);
					state = 0;
					fl.layoutContainer(fm);
					break;
				default:
					assert false;
					System.out.println("the align value is impossible!");
					break;
				}
			}
		});
		fm.add(bu);
		
		fm.setSize(200, 300);
		fm.setVisible(true);

	}

}

⌨️ 快捷键说明

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