public void link(Window window) {
			if (window!=null) {
				onClose(window, Fs.invokeRef(stopF));
			}
		}
	}

	public static P0 selectAllF(final JTextField tb) {
		return new P0() {public void e() {
			tb.selectAll();
		}};
	}
	public static Component dialogControls(Component... comps) {
		return panel_vertical(new JSeparator(), panel(comps));
	}
	public static void onAction(final AbstractButton btn, final P0 action) {
		btn.addActionListener(toActionListener(ThreadUtil.async(new P0() {public void e() {
			btn.setEnabled(false);
			action.e();
			btn.setEnabled(true);
		}})));
	}
	
	public static void main(String[] args) {
		JTextField tf = new JTextField();
		onlyLowerAlphaNumeric(tf);
		DesktopUI4.alert(tf);
	}
	public static void onlyLowerAlphaNumeric(final JTextField tf) {
		onChange(tf, new P1<String>() {public void e(final String str) {
			asyncRun(new P0() {public void e() {
				String newVal = str.replaceAll("\\W+", "").toLowerCase();
//				System.out.println(newVal);
				tf.setText(newVal);
			}});
		}});
	}
	public static ActionListener toActionListener(final P0 f) {
	    return new ActionListener() {
	        public void actionPerformed(ActionEvent e) {
	            f.e();
	        }
	    };
	}
	public static Rectangle expand(Rectangle rect, int amount) {
		return new Rectangle(
				rect.x - amount,
				rect.y - amount,
				rect.width + amount*2,
				rect.height + amount*2
				);
	}
	public static void draw(BufferedImage image, Rectangle rectangle,
			BufferedImage backgroundImg) {
		Graphics2D g = backgroundImg.createGraphics();
		if (rectangle == null) {
			g.drawImage(image, 0, 0, null);
		} else {
			g.drawImage(image, rectangle.x, rectangle.y, null);
		}
		g.dispose();
	}
	public static P0 setVisibleF(final Window w, final boolean visible) {
		return new P0() {public void e() {
			w.setVisible(visible);
		}};
	}
	public static void onMouseHover(Component comp, final P1<Boolean> p1) {
		comp.addMouseListener(new MouseAdapter() {
			
			@Override
			public void mouseExited(MouseEvent arg0) {
				p1.e(false);
			}
			
			@Override
			public void mouseEntered(MouseEvent arg0) {
				p1.e(true);
			}
		});

	}
	public static Color alpha(int alpha, Color color) {
		return new Color(color.getRed(), color.getGreen(), color.getBlue(), alpha);
	}
	public static GetSet<Integer> getSetIndex(final JComboBox combobox) {
		return new GetSet<Integer>(
				new F0<Integer>() {public Integer e() {
					return combobox.getSelectedIndex();
				}},
				new P1<Integer>() {public void e(Integer obj) {
					combobox.setSelectedIndex(obj);
				}}