stringsupport.java

来自「PIY(Program It Yourself)是一个基于Java的应用程序开发」· Java 代码 · 共 46 行

JAVA
46
字号
package piy.support;

import java.awt.event.*;
import java.awt.*;
import piy.*;
import javax.swing.*;
import java.awt.Dimension;

/**
* Support for properties of String type.
* @author David Vivash
* @version 1.0, 08/02/01
*/
public class StringSupport extends ClassSupport implements KeyListener
{
	private String value = null;
	private JTextField textField;

	public StringSupport(Property property) {
		super(property);
	
		value = (String)property.getValue();

		setLayout(new BorderLayout());
		add(textField = new JTextField(value), BorderLayout.CENTER);
		textField.addKeyListener(this);

		setBackground(Color.red);
	}

	public static Class getSupportedClass() { return String.class; }

	public Dimension getMinimumSize() { return new Dimension(10, 20); }
	public Dimension getPreferredSize() { return new Dimension(100, 20); }
	public Dimension getMaximumSize() { return new Dimension(10000, 20); }

	//--------- KeyListener methods ------------
	public void keyPressed(KeyEvent e) {	/* ignore */ }
	public void keyTyped(KeyEvent e) { 		/* ignore */ }

	public void keyReleased(KeyEvent e) {	
		ProjectHandler.getInstance().projectChanged();
		property.setValue(textField.getText());
	}

}

⌨️ 快捷键说明

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