-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBaseActivity.java
66 lines (53 loc) · 1.61 KB
/
BaseActivity.java
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
package com.base;
import com.db.SqlUser;
import com.db.SqlHelper;
import javax.swing.*;
import java.awt.*;
public abstract class BaseActivity {
protected Font titleFont;
protected Font textFont;
private JFrame dialogFrame;
/**
* 每个活动持有一个SQL对象
*/
private SqlUser sqlUser = null;
private SqlHelper sqlHelper;
/**
* View初始化自动调用
*/
public BaseActivity() {
dialogFrame = new JFrame();
dialogFrame.setSize(400, 400);
dialogFrame.setLocationRelativeTo(null);
dialogFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
this.sqlUser = initSqlUser();
sqlHelper = new SqlHelper(sqlUser);
javax.swing.SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
initView();
addListener();
}
});
//全局字体初始化
titleFont = new Font("黑体", Font.PLAIN, 18);
textFont = new Font("黑体", Font.PLAIN, 16);
}
public void showMessageDialog(String message) {
JOptionPane.showMessageDialog(dialogFrame, message, "消息提示", JOptionPane.INFORMATION_MESSAGE);
}
//初始化SQL对象
public SqlHelper getSqlHelper() {
return sqlHelper;
}
public abstract SqlUser initSqlUser();
//初始化界面
public abstract void initView();
//SQL对象的getter
protected SqlUser getSqlUser() {
return this.sqlUser;
}
//事件设置
public abstract void addListener();
public abstract void loadData();
}