wangting
2024-11-27 3b3fd904b9b34e77445d749bca8c28beadcaf3db
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
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);
            }
        });
    }
    
}