filesupport.java
字号:
package piy.support;
import java.awt.event.*;
import java.awt.*;
import piy.*;
import javax.swing.*;
import java.awt.Dimension;
import java.io.*;
/**
* Support for properties of Color type.
* @author David Vivash
* @version 1.0, 26/02/01
*/
public class FileSupport extends ClassSupport implements ActionListener
{
private File value = null;
private JButton browseButton = null;
private JTextField asText = null;
public FileSupport(Property property) {
super(property);
setLayout(new BorderLayout());
value = (File)property.getValue();
asText = new JTextField(""+value);
asText.setEnabled(false); //don't allow the user to type in the filename for now
browseButton = new JButton("...");
browseButton.addActionListener(this);
browseButton.setPreferredSize(new Dimension(32,24));
add(browseButton, BorderLayout.EAST);
add(asText, BorderLayout.CENTER);
}
public static Class getSupportedClass() { return File.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); }
//---- PropertyChangeListener method -----
public void actionPerformed(ActionEvent e) {
FileDialog dialog = new FileDialog(new JFrame(), "Select Filename");
dialog.setFile(asText.getText());
dialog.show();
value = new File(dialog.getDirectory(), dialog.getFile());
asText.setText(""+value);
property.setValue(value);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -