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

📄 test.java

📁 《Java2图形设计卷II:Swing》配套光盘源码
💻 JAVA
字号:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;

public class Test extends JApplet {
	private JButton button_1 = new JButton("button one"),
				   button_2 = new JButton("button two"),
				   button_3 = new JButton("button three"),
				   button_4 = new JButton("button four"),
				   button_5 = new JButton("button five"),
				   button_6 = new JButton("button six");

	public void init() {
		Container contentPane = getContentPane();

		javax.swing.FocusManager.setCurrentManager(
								 new CustomFocusManager());

		contentPane.setLayout(new FlowLayout());
		contentPane.add(button_1);
		contentPane.add(button_2);
		contentPane.add(button_3);
		contentPane.add(button_4);
		contentPane.add(button_5);
		contentPane.add(button_6);
	}
}
class CustomFocusManager extends DefaultFocusManager {
	public boolean compareTabOrder(Component a, Component b) {
		Point location_a = a.getLocation(),
			  location_b = b.getLocation();

		int ax = location_a.x, ay = location_a.y;
		int bx = location_b.x, by = location_b.y;

	 	if(Math.abs(ay - by) < 10) {
            return (bx < ax);
        }
        return (ay > by);	
	}
}

⌨️ 快捷键说明

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