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

📄 floatingtextfield.java

📁 JHotDraw学习过程中对数组的测试程序haha 学习过程中对数组的测试程序
💻 JAVA
字号:
/* * @(#)FloatingTextField.java 5.1 * */package CH.ifa.draw.util;import java.awt.*;import java.awt.event.*;/** * A text field overlay that is used to edit a TextFigure. * A FloatingTextField requires a two step initialization: * In a first step the overlay is created and in a * second step it can be positioned. * * @see TextFigure */public  class FloatingTextField extends Object {    private TextField   fEditWidget;    private Container   fContainer;    public FloatingTextField() {        fEditWidget = new TextField(20);    }    /**     * Creates the overlay for the given Component.     */    public void createOverlay(Container container) {        createOverlay(container, null);    }    /**     * Creates the overlay for the given Container using a     * specific font.     */    public void createOverlay(Container container, Font font) {        container.add(fEditWidget, 0);        if (font != null)            fEditWidget.setFont(font);        fContainer = container;    }    /**     * Adds an action listener     */	public void addActionListener(ActionListener listener) {	    fEditWidget.addActionListener(listener);	}    /**     * Remove an action listener     */	public void removeActionListener(ActionListener listener) {	    fEditWidget.removeActionListener(listener);	}    /**     * Positions the overlay.     */    public void setBounds(Rectangle r, String text) {	    fEditWidget.setText(text);        fEditWidget.setBounds(r.x, r.y, r.width, r.height);        fEditWidget.setVisible(true);	    fEditWidget.selectAll();	    fEditWidget.requestFocus();    }    /**     * Gets the text contents of the overlay.     */    public String getText() {        return fEditWidget.getText();    }    /**     * Gets the preferred size of the overlay.     */    public Dimension getPreferredSize(int cols) {        return fEditWidget.getPreferredSize(cols);    }    /**     * Removes the overlay.     */    public void endOverlay() {	    fContainer.requestFocus();	    if (fEditWidget == null)	        return;	    fEditWidget.setVisible(false);	    fContainer.remove(fEditWidget);	    Rectangle bounds = fEditWidget.getBounds();	    fContainer.repaint(bounds.x, bounds.y, bounds.width, bounds.height);    }}

⌨️ 快捷键说明

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