📄 moneymanager.java
字号:
import java.awt.event.*;
import java.awt.*;
import javax.swing.*;
import javax.swing.table.*;
class MainWindow implements ActionListener
{
int j,k;
JFrame zbManagerf;
JLabel l1,l2;
JTextArea ta;
JButton b1,b2,b3,b4,b5,b6;
DefaultListModel listData;
JList jList;
JScrollPane jScrollPane;
String ZbName;
//新建帐簿信息
JFrame f;
JButton Tijiao;
JButton Quxiao;
JTextField NewNameText;
JTextField NewPasswordText;
JTextField NewUserText;
JTextField NewRiqiText;
//loginDialog
JDialog loginDialog;
JPasswordField passwordText;
JTextField nameText;
JButton loginBtu;
JButton exitBtu;
//具体入账,查询,统计总窗口
JMenuBar mainMenuBar;
JMenu Menu1;
JMenu Menu2;
JMenu Menu3;
JMenuItem MenuItem1;
JMenuItem MenuItem2;
JMenuItem MenuItem4;
JMenuItem MenuItem5;
JMenuItem MenuItem6;
JMenuItem MenuItem7;
JFrame frame;
JLabel framel4;
JLabel framel5;
JLabel framel6;
String shouru="shouru";
String zhichu="zhichu";
String yue="yue";
//删除时验证密码窗口
JDialog deleteDialog;
JLabel YnameLabel,YpasswordLabel;
JTextField YnameText,YpasswordText;
JButton Ybutton1,Ybutton2;
//input
JFrame inputf;
JButton inputb1;
JButton inputb2;
JButton inputb3;
JTextField t1;
JTextField t2;
JTextField t3;
CheckboxGroup c;
Checkbox c1;
Checkbox c2;
Choice ch1;
Choice ch2;
//select
JFrame selectf;
JTextField selectt1;
JTextField selectt2;
JButton selectb1;
JButton selectb2;
CheckboxGroup cc;
Checkbox cc1;
Checkbox cc2;
Choice cch1,cch2;
//myTable
JFrame tablef;
JTable table;
Object[][] n;
JScrollPane s;
JButton tableb1;
//nameDialog
JDialog nameDialog;
JTextField nameDialogText;
JButton nameDialogButton1,nameDialogButton2;
//passwordDialog
JDialog passwordDialog;
JTextField pDialogText1,pDialogText2;
JButton pDialogButton1,pDialogButton2;
//xiangxixinxi
JFrame xf;
JLabel xl4,xl5,xl6;
JButton xb1;
MainWindow(){}
void ManagerWindow()
{
zbManagerf=new JFrame("家庭理财管理系统");
l1=new JLabel("帐簿管理中心");
l1.setBorder(BorderFactory.createTitledBorder(""));
l1.setFont(new java.awt.Font("Dialog",0,15));
ta=new JTextArea();
b1=new JButton("打开");b1.addActionListener(this);
b2=new JButton("新建");b2.addActionListener(this);
b3=new JButton("删除");b3.addActionListener(this);
b4=new JButton("详细信息");b4.addActionListener(this);
b5=new JButton("刷新");b5.addActionListener(this);
b6=new JButton("退出");b6.addActionListener(this);
JPanel p1=new JPanel();
p1.setLayout(new GridLayout(6,1));
p1.add(b1);
p1.add(b2);
p1.add(b3);
p1.add(b4);
p1.add(b5);
p1.add(b6);
JPanel p2=new JPanel();
p2.setBackground(Color.CYAN);
p2.add(l1);
listData=new DefaultListModel();
jList=new JList(listData);
jList.setBorder(BorderFactory.createTitledBorder("账簿名"));
jScrollPane = new JScrollPane();
jScrollPane.getViewport().setView(jList);
JPanel p3=new JPanel();
JPanel p4=new JPanel();
p3.setLayout(new BorderLayout());
JLabel ll=new JLabel("请选择帐簿",SwingConstants.LEFT);
p4.add(ll);
p4.setBackground(Color.pink);
p3.add(p4,BorderLayout.NORTH);
p3.add(jScrollPane,BorderLayout.CENTER);
zbManagerf.setLayout(new BorderLayout());
zbManagerf.add(p2,BorderLayout.NORTH);
zbManagerf.add(p3,BorderLayout.CENTER);
zbManagerf.add(p1,BorderLayout.EAST);
zbManagerf.setSize(400,240);
zbManagerf.setLocation(200,200);
new SQL(this).selectZbName();
zbManagerf.setVisible(true);
}
void loginDialog()//打开帐簿时验证密码窗口
{
loginDialog=new JDialog(zbManagerf,"打开帐簿验证窗口",true);
loginDialog.setLayout(null);
loginDialog.setSize(250,180);
JLabel nameLabel=new JLabel();
JLabel passwordLabel=new JLabel();
nameText=new JTextField(6);
passwordText=new JPasswordField(6);
loginBtu=new JButton();loginBtu.addActionListener(this);
exitBtu=new JButton();exitBtu.addActionListener(this);
nameLabel.setText("帐簿名");
nameLabel.setFont(new java.awt.Font("Dialog",0,13));
nameLabel.setBounds(new Rectangle(50,30,79,19));
passwordLabel.setText("密码");
passwordLabel.setFont(new java.awt.Font("Dialog",0,13));
passwordLabel.setBounds(new Rectangle(50,60,79,19));
nameText.setBounds(new Rectangle(100,30,90,19));
passwordText.setBounds(new Rectangle(100,60,90,19));
nameText.setText(ZbName);
loginBtu.setText("打开");
loginBtu.setFont(new java.awt.Font("Dialig",0,13));
loginBtu.setBounds(new Rectangle(40,110,65,19));
exitBtu.setText("返回");
exitBtu.setFont(new java.awt.Font("Dialog",0,13));
exitBtu.setBounds(new Rectangle(130,110,65,19));
loginDialog.add(nameLabel);
loginDialog.add(nameText);
loginDialog.add(passwordLabel);
loginDialog.add(passwordText);
loginDialog.add(exitBtu);
loginDialog.add(loginBtu);
loginDialog.setLocation(200,200);
loginDialog.show();
}
void NewZHangbu()//新建帐簿窗口
{
f=new JFrame("新建帐簿");
JLabel nameLabel=new JLabel("帐簿名");
nameLabel.setFont(new java.awt.Font("Dialog",0,13));
nameLabel.setBounds(new Rectangle(50,30,79,19));
JLabel passwordLabel=new JLabel("密码");
passwordLabel.setFont(new java.awt.Font("Dialog",0,13));
passwordLabel.setBounds(new Rectangle(50,60,79,19));
JLabel userLabel=new JLabel("建账者");
userLabel.setFont(new java.awt.Font("Dialog",0,13));
userLabel.setBounds(new Rectangle(50,90,79,19));
JLabel riqiLabel=new JLabel("建账日期");
riqiLabel.setFont(new java.awt.Font("Dialog",0,13));
riqiLabel.setBounds(new Rectangle(50,120,79,19));
JLabel riqiLabel2=new JLabel("(如:20070206)");
riqiLabel2.setBounds(new Rectangle(110,140,90,19));
riqiLabel2.setFont(new java.awt.Font("Dialog",0,13));
NewNameText=new JTextField(20);
NewNameText.setBounds(new Rectangle(110,30,90,19));
NewPasswordText=new JTextField(20);
NewPasswordText.setBounds(new Rectangle(110,60,90,19));
NewUserText=new JTextField(20);
NewUserText.setBounds(new Rectangle(110,90,90,19));
NewRiqiText=new JTextField(20);
NewRiqiText.setBounds(new Rectangle(110,120,90,19));
Tijiao=new JButton("新建");Tijiao.addActionListener(this);
Tijiao.setFont(new java.awt.Font("Dialog",0,13));
Tijiao.setBounds(new Rectangle(40,170,65,19));
Quxiao=new JButton("取消");Quxiao.addActionListener(this);
Quxiao.setFont(new java.awt.Font("Dialog",0,13));
Quxiao.setBounds(new Rectangle(130,170,65,19));
f.add(nameLabel);
f.add(NewNameText);
f.add(passwordLabel);
f.add(NewPasswordText);
f.add(userLabel);
f.add(NewUserText);
f.add(riqiLabel);
f.add(NewRiqiText);
f.add(riqiLabel2);
f.add(Tijiao);
f.add(Quxiao);
f.setLayout(null);
f.setSize(250,250);
f.setLocation(200,200);
f.setVisible(true);
}
void frame()//具体入账,查询,等的窗口
{
mainMenuBar=new JMenuBar();
Menu1=new JMenu("选项");
Menu2=new JMenu("账本设置");
MenuItem1=new JMenuItem("入账");MenuItem1.addActionListener(this);
MenuItem2=new JMenuItem("查询");MenuItem2.addActionListener(this);
MenuItem4=new JMenuItem("退出");MenuItem4.addActionListener(this);
MenuItem5=new JMenuItem("重命名");MenuItem5.addActionListener(this);
MenuItem6=new JMenuItem("修改密码");MenuItem6.addActionListener(this);
frame=new JFrame();
frame.setLayout(new BorderLayout());
frame.setSize(529,411);
frame.setLocation(200,200);
frame.setJMenuBar(mainMenuBar);
Menu1.add(MenuItem1);
Menu1.add(MenuItem2);
Menu1.addSeparator();
Menu1.add(MenuItem4);
Menu2.add(MenuItem5);
Menu2.add(MenuItem6);
mainMenuBar.add(Menu1);
mainMenuBar.add(Menu2);
Menu1.setFont(new java.awt.Font("Dialog",0,13));
Menu2.setFont(new java.awt.Font("Dialog",0,13));
MenuItem1.setFont(new java.awt.Font("Dialog",0,13));
MenuItem2.setFont(new java.awt.Font("Dialog",0,13));
MenuItem4.setFont(new java.awt.Font("Dialog",0,13));
MenuItem5.setFont(new java.awt.Font("Dialog",0,13));
MenuItem6.setFont(new java.awt.Font("Dialog",0,13));
JPanel p=new JPanel();
JLabel framel1=new JLabel("总收入");
JLabel framel2=new JLabel("总支出");
JLabel framel3=new JLabel("余额");
framel4=new JLabel();
framel5=new JLabel();
framel6=new JLabel();
framel1.setBounds(new Rectangle(50,50,50,30));
framel1.setFont(new java.awt.Font("Dialog",1,15));
framel2.setBounds(new Rectangle(50,80,50,30));
framel2.setFont(new java.awt.Font("Dialog",1,15));
framel3.setBounds(new Rectangle(50,110,50,30));
framel3.setFont(new java.awt.Font("Dialog",1,15));
framel4.setBounds(new Rectangle(120,50,50,30));
framel4.setFont(new java.awt.Font("Dialog",1,15));
framel5.setBounds(new Rectangle(120,80,50,30));
framel5.setFont(new java.awt.Font("Dialog",1,15));
framel6.setBounds(new Rectangle(120,110,50,30));
framel6.setFont(new java.awt.Font("Dialog",1,15));
new SQL(this).tongji();
p.setLayout(null);
p.add(framel1);p.add(framel4);
p.add(framel2);p.add(framel5);
p.add(framel3);p.add(framel6);
frame.add(p,BorderLayout.CENTER);
frame.setVisible(true);
}
void input()
{
inputf=new JFrame("入账");
JPanel p1=new JPanel();
JPanel p2=new JPanel();
c=new CheckboxGroup();
c1=new Checkbox("收入",true,c);
c2=new Checkbox("支出",false,c);
c1.setBounds(new Rectangle(25,15,50,19));
c2.setBounds(new Rectangle(25,45,50,19));
ch1=new Choice();
ch1.insert("工资",1);
ch1.insert("奖金",2);
ch1.insert("礼金",3);
ch1.insert("经营所得",4);
ch1.insert("亲属赠金",5);
ch1.insert("倒卖物品",6);
ch1.insert("补助津贴",7);
ch1.insert("债务收入",8);
ch1.insert("中奖奖金",9);
ch1.insert("租赁收入",10);
ch1.insert("利息收入",11);
ch1.setBounds(new Rectangle(80,15,100,19));
JLabel inputl5=new JLabel("(请选择类别)");
inputl5.setFont(new java.awt.Font("Dialog",0,13));
inputl5.setBounds(new Rectangle(180,15,80,19));
ch2=new Choice();
ch2.insert("交通费",1);
ch2.insert("生活费",2);
ch2.insert("通信费",3);
ch2.insert("债务费",4);
ch2.insert("教育费",5);
ch2.insert("休闲娱乐",6);
ch2.insert("医疗保健",7);
ch2.insert("维修保养",8);
ch2.insert("慈善送礼",9);
ch2.setBounds(new Rectangle(80,45,100,19));
JLabel inputl6=new JLabel("(请选择类别)");
inputl6.setFont(new java.awt.Font("Dialog",0,13));
inputl6.setBounds(new Rectangle(180,45,80,19));
JLabel l1=new JLabel("金额");
l1.setBounds(new Rectangle(25,80,70,19));
l1.setFont(new java.awt.Font("Dialog",0,13));
JLabel l2=new JLabel("日期");
l2.setBounds(new Rectangle(25,110,70,19));
l2.setFont(new java.awt.Font("Dialog",0,13));
JLabel l3=new JLabel("(如:20070204)");
l3.setBounds(new Rectangle(185,110,80,19));
l3.setFont(new java.awt.Font("Dialog",0,12));
JLabel l6=new JLabel("元(RMB)");
l6.setBounds(new Rectangle(185,80,70,19));
l6.setFont(new java.awt.Font("Dialog",0,13));
JLabel l7=new JLabel("yyyy");
l7.setBounds(new Rectangle(190,110,70,19));
l7.setFont(new java.awt.Font("Dialog",0,13));
JLabel l4=new JLabel("说明");
l4.setBounds(new Rectangle(25,140,70,19));
l4.setFont(new java.awt.Font("Dialog",0,13));
inputb1=new JButton("计算器");inputb1.addActionListener(this);
inputb1.setFont(new java.awt.Font("Dialog",0,13));
inputb2=new JButton("入账");inputb2.addActionListener(this);
inputb2.setFont(new java.awt.Font("Dialog",0,13));
inputb3=new JButton("取消");inputb3.addActionListener(this);
inputb3.setFont(new java.awt.Font("Dialog",0,13));
t1=new JTextField(125);
t1.setBounds(new Rectangle(65,80,115,19));
t2=new JTextField(125);
t2.setBounds(new Rectangle(65,110,115,19));
t3=new JTextField(125);
t3.setBounds(new Rectangle(65,140,200,19));
p1.setLayout(null);
p1.add(l1);p1.add(t1);p1.add(l6);
p1.add(l2);p1.add(t2);p1.add(l3);
p1.add(c1);p1.add(ch1);p1.add(inputl5);
p1.add(c2);p1.add(ch2);p1.add(inputl6);
p1.add(l4);p1.add(t3);
p1.setBorder(BorderFactory.createTitledBorder(""));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -