propdialog.java
来自「一个简单的visio程序。」· Java 代码 · 共 55 行
JAVA
55 行
package webide.views.prop;
import java.awt.Insets;
import java.awt.Dialog;
import java.awt.Button;
import java.awt.Dimension;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyEditor;
public class PropDialog extends Dialog implements ActionListener
{
private Button doneButton;
private Component body;
private final static int vPad = 5;
private final static int hPad = 4;
PropDialog(java.awt.Frame frame, PropertyEditor pe, int x, int y)
{
super(frame, pe.getClass().getName(), true);
setLayout(null);
body = pe.getCustomEditor();
if(body == null) System.out.println("body : " + pe);
add(body);
doneButton = new Button("Done");
doneButton.addActionListener(this);
add(doneButton);
setLocation(x, y);
}
public void actionPerformed(ActionEvent evt)
{
dispose();
}
public void doLayout()
{
Insets ins = getInsets();
Dimension bodySize = body.getPreferredSize();
Dimension buttonSize = doneButton.getPreferredSize();
int width = ins.left + 2*hPad + ins.right + bodySize.width;
int height = ins.top + 3*vPad + ins.bottom + bodySize.height + buttonSize.height;
body.setBounds(ins.left+hPad, ins.top+vPad, bodySize.width, bodySize.height);
doneButton.setBounds( (width-buttonSize.width)/2, ins.top+(2*hPad) + bodySize.height,
buttonSize.width, buttonSize.height );
setSize(width, height);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?