package com.vci.client.tool;
|
|
import java.awt.BorderLayout;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
import java.util.HashMap;
|
import java.util.Map;
|
|
import javax.swing.JFrame;
|
import javax.swing.SwingUtilities;
|
|
import com.vci.client.ui.swing.VCISwingUtil;
|
import com.vci.client.ui.swing.components.VCIJButton;
|
import com.vci.client.ui.swing.components.VCIJFrame;
|
import com.vci.client.ui.swing.components.VCIJPanel;
|
import com.vci.client.ui.swing.components.VCIJDialog.DialogResult;
|
import com.vci.client.uif.engine.client.UIHelper;
|
|
/**
|
* FormAttrSetting 功能Frame
|
* @author xiongchao
|
*
|
*/
|
public class FormAttrSetting extends VCIJFrame implements ActionListener{
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 2938888965536900112L;
|
private VCIJButton btnOk = VCISwingUtil.createVCIJButton("ok", "确定", "", "accept.png", this);
|
private VCIJButton btnCancel = VCISwingUtil.createVCIJButton("cancel", "取消", "取消", "cancel.png", this);
|
public void buildDialog(){
|
init();
|
}
|
|
private void init(){
|
initUI();
|
initActionMap();
|
initSizeAndLocation();
|
}
|
|
private void initUI(){
|
setLayout(new BorderLayout());
|
add(getNorthPanel(), BorderLayout.SOUTH);
|
add(getWestPanel(), BorderLayout.WEST);
|
add(getCenterPanel(), BorderLayout.CENTER);
|
add(getEastPanel(), BorderLayout.EAST);
|
add(getSouthPanel(), BorderLayout.SOUTH);
|
}
|
private VCIJPanel getNorthPanel(){
|
VCIJPanel pal = new VCIJPanel();
|
return pal;
|
}
|
private VCIJPanel getWestPanel(){
|
VCIJPanel pal = new VCIJPanel();
|
return pal;
|
}
|
private VCIJPanel getCenterPanel(){
|
VCIJPanel pal = new VCIJPanel(new BorderLayout());
|
pal.add(new FormAttrSettingPanel(), BorderLayout.CENTER);
|
return pal;
|
}
|
private VCIJPanel getEastPanel(){
|
VCIJPanel pal = new VCIJPanel();
|
return pal;
|
}
|
private VCIJPanel getSouthPanel(){
|
VCIJPanel pal = new VCIJPanel();
|
pal.add(btnOk);
|
pal.add(btnCancel);
|
return pal;
|
}
|
|
private Map<String, Runnable> actionMap = new HashMap<String, Runnable>();
|
private void initActionMap(){
|
actionMap.put(btnOk.getActionCommand(), new Runnable() {
|
@Override
|
public void run() {
|
ok();
|
}
|
});
|
actionMap.put(btnCancel.getActionCommand(), new Runnable() {
|
@Override
|
public void run() {
|
cancel();
|
}
|
});
|
}
|
@Override
|
public void actionPerformed(ActionEvent e) {
|
String actionCommand = e.getActionCommand();
|
if(actionMap.containsKey(actionCommand)){
|
actionMap.get(actionCommand).run();
|
}
|
}
|
|
private void initSizeAndLocation(){
|
setSize(UIHelper.DIALOG_DEFAULT_WIDTH, UIHelper.DIALOG_DEFAULT_HEIGHT);
|
setLocationRelativeTo(getOwner());
|
}
|
private void ok(){
|
close(DialogResult.OK);
|
}
|
|
private void cancel(){
|
close(DialogResult.CANCEL);
|
}
|
private void close(DialogResult dialogResult){
|
close();
|
}
|
private void close(){
|
dispose();
|
setVisible(false);
|
}
|
|
public static void main(String[] args){
|
SwingUtilities.invokeLater(new Runnable() {
|
@Override
|
public void run() {
|
VCISwingUtil.setLookAndFeel(VCISwingUtil.LOOK_AND_FEEL_NimbusLookAndFeel);
|
FormAttrSetting f = new FormAttrSetting();
|
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
f.buildDialog();
|
f.setSize(1280, 800);
|
f.setLocationRelativeTo(null);
|
f.setVisible(true);
|
f.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
}
|
});
|
}
|
|
}
|