黄道十二宫

package Zodiac;
/**
 * @author ${聂传杰}
 *
 * 2010-8-5
 */

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;

 

public class Login extends JFrame {
 ActionLogin al=new ActionLogin(this);
 
 
 MyPanel jp = new MyPanel("images//11111.jpg");
 JPanel jp1 = new JPanel();

 public JTextField jtf = new JTextField(15);
 JTextField jtf2 = new JTextField(15);
 JLabel jl = new JLabel("<html><font face=楷体_GB2312 size=5 color =RED>姓名:</font></html>");
 JLabel jll = new JLabel("<html><font face=楷体_GB2312 size=5 color =RED>密码:</font></html>");
 
 JLabel jl2 = new JLabel("<html><font face=楷体_GB2312 size=5 color =red>黄道十二宫</font></html>");

 JButton jb = new JButton("登入");
 JButton jb1 = new JButton("注册");

 public Login() {
  this.setSize(800, 600);
  this.setLayout(new BorderLayout());
  this.add(jp, BorderLayout.CENTER);

  jp.setSize(307, 261);
  jp.setLayout(null);

  jp.add(jl2);
  jl2.setBounds(330, 200, 200, 60);
  jp.add(jl);
  jl.setBounds(300, 260, 50, 50);
  jp.add(jll);
  jll.setBounds(300, 310, 50, 50);
  jp.add(jtf2);
  jp.add(jtf);
  jtf.setBounds(370, 280, 90, 20);
  jtf2.setBounds(370, 325, 90, 20);
  jp.add(jb);
  jb.setBounds(300, 380, 60, 30);
  jp.add(jb1);
  jb1.setBounds(380, 380, 60, 30);
  this.add(jp);
 
  
  jb.addActionListener(new ActionListener(){
   public void actionPerformed(ActionEvent e) {
     JButton bu=(JButton) e.getSource();
     String name=bu.getText();
     al.Action(name);
    
   }
   
   
  });
  jb1.addActionListener(new ActionListener(){

   public void actionPerformed(ActionEvent e) {
   
    Register register = new Register();
    
    JButton bu=(JButton) e.getSource();
    String name=bu.getText();
    
        al.Action(name);
   }
   
  });
  this.setLocationRelativeTo(null);
  this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  this.setVisible(true);
 }

 public static void main(String[] args) {
        Login l = new Login();
 }
 

 
 
 

}
 

 

package Zodiac;

import java.awt.BorderLayout;
import java.awt.Choice;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.PopupMenu;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JTextField;

/*主界面*/
/**
 * @author ${聂传杰}
 *
 * 2010-8-5
 */


public class MainPanel{
 
 JFrame jf = new JFrame("黄道十二宫");
 ActionMainPanel am=new ActionMainPanel(this);

 JPanel jp = new JPanel(){
  
  private static final long serialVersionUID = 1L;
  Image image=new ImageIcon("images//清香夏日.jpg").getImage();
  public  void paintComponent(Graphics g) {
   g.drawImage(image,  0, 0,this.getWidth(),this.getHeight(),null);
  }
 };
 
/* JPanel jp11 = new JPanel()
{
  
  private static final long serialVersionUID = 1L;
  Image image=new ImageIcon("image//hongse.jpg").getImage();
  public  void paintComponent(Graphics g) {
   g.drawImage(image,  10, 10,this.getWidth(),this.getHeight(),null);
  }
 };*/
 
 JLabel jl = new JLabel();
 JLabel jl1 = new JLabel("出生日期");
 JLabel jl2 = new JLabel("星座测试系统");
 JLabel jl3 = new JLabel("年");
 JLabel jl4 = new JLabel("月");
 JLabel jl5 = new JLabel("日");
 JButton jb = new JButton("星座特征");
 
 //JPanel jp1 = new JPanel();
 
// Choice year = new Choice();
// Choice month = new Choice();
// Choice day = new Choice();
 JComboBox year = new JComboBox();
 JComboBox month = new JComboBox();
 JComboBox day = new JComboBox();
 

 
 /*JMenuBar jmb = new JMenuBar();
 JMenu jm = new JMenu("星座测试系统");
 JMenuItem jmi1 = new JMenuItem("星座查询");
 JMenuItem jmi2 = new JMenuItem("当日运势");
 JMenuItem jmi3 = new JMenuItem("星座特征");
 JMenuItem jmi4 = new JMenuItem("星座配对");
 JMenuItem jmi5 = new JMenuItem("双子座");
 
    JMenu jm1 = new JMenu("别人眼中的我");
    JMenuItem jmi11 = new JMenuItem("双子座");
 JMenuItem jmi12 = new JMenuItem("双子座");
 JMenuItem jmi13 = new JMenuItem("双子座");
 JMenuItem jmi14 = new JMenuItem("双子座");
 JMenuItem jmi15 = new JMenuItem("对话框");
*/
 
 
 
  MainPanel(){
  
  jf.setSize(800,600);
  jf.setResizable(false);
  
  jf.setLayout(new BorderLayout());
  jf.add(jp,BorderLayout.CENTER);
  jf.add(jp);
  
  jp.setLayout(null);
  
  jp.add(year);
  jp.add(month);
  jp.add(day);
  
  year.setFont(new Font("宋体",0,15));
  year.setBounds(210, 240, 80, 20);
  month.setFont(new Font("宋体", 0,16));
  month.setBounds(350, 240, 80, 20);
  day.setFont(new Font("宋体", 0,16));
  day.setBounds(480,240,80,20);
  
     for (int i = 0; i < 31; i++) {
   int[] in = new int[31];
   in[i] = i + 1;
   day.addItem(in[i]);
  }

  for (int i = 0; i < 12; i++) {
   int[] it = new int[12];
   it[i] = i + 1;
   month.addItem(it[i]);
  }

  for (int i = 0; i < 30; i++) {
   int[] nt = new int[30];
   nt[i] = 1985 + i;
   year.addItem(nt[i]);
  }

  
  jp.add(jl1);
     jl1.setBounds(100,200,100,100);//设置标签坐标 X Y轴  长 宽 // 出生日期
  this.jl1.setFont(new Font("华文行楷",Font.BOLD | Font.ITALIC,20));  
  
  jp.add(jl2);
  jl2.setBounds(300,30,150,150); //欢迎来到
  this.jl2.setFont(new Font("华文行楷",Font.BOLD | Font.ITALIC,20));//设置标签字体
  
  jp.add(jl3);
        jl3.setBounds(300,200,100,100);//年
  this.jl3.setFont(new Font("华文行楷",Font.BOLD | Font.ITALIC,20));
  
  jp.add(jl4);
  jl4.setBounds(450,200,100,100);//月
  this.jl4.setFont(new Font("华文行楷",Font.BOLD | Font.ITALIC,20));
  
  jp.add(jl5);
  jl5.setBounds(600,200,100,100);//日
  this.jl5.setFont(new Font("华文行楷",Font.BOLD | Font.ITALIC,20));
 
  jp.add(jb);
  jb.addActionListener(new ActionListener() {

   public void actionPerformed(ActionEvent e) {
    // int year=(Integer) jcn.getSelectedItem();
    int monthr = (Integer) month.getSelectedItem();
    int date = (Integer) day.getSelectedItem();
    String name = am.checkStar(monthr, date);
    am.Action(name);

   }

  });
 
  
  
    // jp.add(jp11);
     jb.setBounds(300,400,120,40);

  

 
  
  
  
 /*  for(int i1=1900;i1<=2009;i1++) {
    new String();
    year.add(String.valueOf(i1));
   }
   year.setFont(new Font("宋体",0,15));
   year.setBounds(230, 240, 65, 50);
   jp.add(year);
   
   for(int i1=1;i1<=12;i1++) {
    new String();
    month.add(String.valueOf(i1));
   }
   month.setFont(new Font("宋体", 0,16));
   month.setBounds(360, 240, 60, 60);
   
   jp.add(month);
   
   for(int i1=1;i1<=31;i1++) {
    new String();
    day.add(String.valueOf(i1));
   }
   day.setFont(new Font("宋体", 0,16));
   day.setBounds(490,240,60,60);
   jp.add(day);*/
   
     jf.setLocationRelativeTo(null);
     jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
     jf.setVisible(true);
 }

 public static void main(String[] args){
  MainPanel mp=new MainPanel();
  }

 public void add(PopupMenu jhbp) {
  // TODO Auto-generated method stub
  
 }
 
 
 
 
 

  
  
  
 
 /*jb.addActionListener(new ActionListener(){

  public void actionPerformed(ActionEvent e) {
   
   Horoscope h = new Horoscope();
   
*/
 
}

/*private JMenuBar createJMenuBar(Action[] actions){//创建菜单栏
   JMenuBar menubar = new JMenuBar(); //实例化菜单栏
   JMenu menuFile = new JMenu("文件");
   JMenu menuAbout = new JMenu("帮助");

   menuAbout.add(new JMenuItem(actions[0]));
   menuFile.add(new JMenuItem(actions[1]));
   menubar.add(menuFile); //增加菜单
   menubar.add(menuAbout);
   return menubar;
  }
/* private JToolBar createJToolBar(Action[] actions){//创建工具条
JToolBar toolBar = new JToolBar();//实例化工具条
for(int i=0; i< actions.length;i++){
 JButton bt = new JButton(actions[i]);
 bt.setRequestFocusEnabled(false);
 //设置不需要焦点
 toolBar.add(bt);//增加按钮到工具栏
}
return toolBar; //返回工具栏
}*/
 

 

/**
 *
 */
package Zodiac;


/**
 * @author ${聂传杰}
 *
 * 2010-8-7
 */
public class ActionMainPanel {
 StarInformation s1;
 
    public ActionStar as;
 public MainPanel mp;
 
 // 构造器传递对象
 public ActionMainPanel(MainPanel mp){
  
  this.mp=mp;
  
 }
 
 //  输入日期,判断是那个星座
 public String checkStar(int month,int date){
  String s="";
  if((month==1&&(date>=21&&date<=31))||(month==2&&(date>=1&&date<=18))){
   s="水瓶座";
  }
  else if((month==2&&(date>=19&&date<=31))||(month==3&&(date>=1&&date<=20))){
   s="双鱼座";
  }
  else if((month==3&&(date>=21&&date<=31))||(month==4&&(date>=1&&date<=20))){
   s="白羊座";
  }
  else if((month==4&&(date>=21&&date<=31))||(month==5&&(date>=1&&date<=21))){
   s="金牛座";
  }
  else if((month==5&&(date>=22&&date<=31))||(month==6&&(date>=1&&date<=21))){
   s="双子座";
  }
  else if((month==6&&(date>=22&&date<=31))||(month==7&&(date>=1&&date<=22))){
   s="巨蟹座";
  }
  else if((month==7&&(date>=23&&date<=31))||(month==8&&(date>=1&&date<=23))){
   s="狮子座";
  }
  else if((month==8&&(date>=24&&date<=31))||(month==9&&(date>=1&&date<=23))){
   s="处女座";
  }
  else if((month==9&&(date>=24&&date<=31))||(month==10&&(date>=1&&date<=23))){
   s="天秤座";
  }
  else if((month==10&&(date>=24&&date<=31))||(month==11&&(date>=1&&date<=22))){
   s="天蝎座";
  }
  else if((month==11&&(date>=23&&date<=31))||(month==12&&(date>=1&&date<=21))){
   s="射手座";
  }
  else{
   s="摩羯座";
  }
  return s;
  
  
 }
 
 //    输入星座名称,调出相应星座的面板。
 public void Action(String name){
  String str;
  if (name.equals("白羊座")) {
   s1=new StarInformation("白羊座","images//白羊座.jpg");
   mp.jf.setVisible(false);
   mp.jf.dispose();
   as =new ActionStar(s1);
   str = "folder_2//baiyang_d.txt";

   as.readOut(str);

  }
  if (name.equals("金牛座")) {
   s1=new StarInformation("金牛座","images//金牛座.jpg");
   mp.jf.setVisible(false);
   mp.jf.dispose();
   as =new ActionStar(s1);
   str = "folder_2//jinniu_d.txt";

   as.readOut(str);

  }
  if (name.equals("双子座")) {
   s1=new StarInformation("双子座","images//双子座.jpg");
   mp.jf.setVisible(false);
   mp.jf.dispose();
   as =new ActionStar(s1);
   str = "folder_2//shuangzi_d.txt";

   as.readOut(str);

  }
  if (name.equals("巨蟹座")) {
   s1=new StarInformation("巨蟹座","images//巨蟹座.jpg");
   mp.jf.setVisible(false);
   mp.jf.dispose();
   as =new ActionStar(s1);
   str = "folder_2//jvxie_d.txt";

   as.readOut(str);

  }
  if (name.equals("狮子座")) {
   s1=new StarInformation("狮子座","images//狮子座.jpg");
   mp.jf.setVisible(false);
   mp.jf.dispose();
   as =new ActionStar(s1);
   str = "folder_2//shizi.txt";

   as.readOut(str);

  }
  if (name.equals("处女座")) {
   s1=new StarInformation("处女座","images//处女座.jpg");
   mp.jf.setVisible(false);
   mp.jf.dispose();
   as =new ActionStar(s1);
   str = "folder_2//chunv_d.txt";

   as.readOut(str);

  }
  if (name.equals("天秤座")) {
   s1=new StarInformation("天秤座","images//天枰座.jpg");
   mp.jf.setVisible(false);
   mp.jf.dispose();
   as =new ActionStar(s1);
   str = "folder_2//tianping_d.txt";

   as.readOut(str);

  }
  if (name.equals("天蝎座")) {
   s1=new StarInformation("天蝎座","images//天蝎座.jpg");
   mp.jf.setVisible(false);
   mp.jf.dispose();
   as =new ActionStar(s1);
   str = "folder_2//tianxie_d.txt";

   as.readOut(str);

  }
  if (name.equals("射手座")) {
   s1=new StarInformation("射手座","images//射手座.jpg");
   mp.jf.setVisible(false);
   mp.jf.dispose();
   as =new ActionStar(s1);
   str = "folder_2//sheshou_d.txt";

   as.readOut(str);

  }
  if (name.equals("摩羯座")) {
   s1=new StarInformation("摩羯座","images//摩羯座.jpg");
   mp.jf.setVisible(false);
   mp.jf.dispose();
   as =new ActionStar(s1);
   str = "folder_2//moxie_d.txt";

   as.readOut(str);

  }
  if (name.equals("水瓶座")) {
   s1=new StarInformation("水瓶座","images//水瓶座.jpg");
   mp.jf.setVisible(false);
   mp.jf.dispose();
   as =new ActionStar(s1);
   str = "folder_2//shuiping_d.txt";

   as.readOut(str);

  }
  if (name.equals("双鱼座")) {
   s1=new StarInformation("双鱼座","images//双鱼座.jpg");
   mp.jf.setVisible(false);
   mp.jf.dispose();
   as =new ActionStar(s1);
   str = "folder_2//shuangyv_d.txt";

   as.readOut(str);

  }
  
  
 }

}
 

package Zodiac;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Checkbox;
import java.awt.CheckboxGroup;
import java.awt.Choice;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Label;
import java.awt.Panel;
import java.awt.TextField;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.Box;
import javax.swing.JOptionPane;

class Register extends Frame implements ActionListener,ItemListener{
 /**
  * @author ${聂传杰}
  *
  * 2010-8-5
  */

private static final long serialVersionUID = 625458974842746121L;
Box name,edit,baseBox;
Button exit=new Button("退    出"),summit=new Button("提    交");
Choice city=new Choice();
Choice province=new Choice();
Choice year=new Choice();
TextField age=new TextField(12),username=new TextField(12);
TextField password1=new TextField(12),password2=new TextField(12);
TextField answer=new TextField();
TextField email=new TextField();
Register(){
   super("注册窗口");
   name=Box.createVerticalBox();
   name.add(new Label("*用 户 名:"));
   name.add(Box.createVerticalStrut(8));
   name.add(new Label("*密    码:"));
   name.add(Box.createVerticalStrut(8));
   name.add(new Label("*确认秘密:"));
   name.add(Box.createVerticalStrut(8));
   name.add(new Label("*密码提示问题:"));
   name.add(Box.createVerticalStrut(8));
   name.add(new Label("*答案:"));
   name.add(Box.createVerticalStrut(8));
   name.add(new Label("*保密邮箱:"));
   name.add(Box.createVerticalStrut(8));
   name.add(new Label("*出生日期:"));
   name.add(Box.createVerticalStrut(8));
   name.add(new Label("*性别:"));
   name.add(Box.createVerticalStrut(8));
   name.add(new Label("年龄:"));
   name.add(Box.createVerticalStrut(8));
   name.add(new Label("个人星座:"));
   name.add(Box.createVerticalStrut(8));
   name.add(new Label("所在省:"));
   name.add(Box.createVerticalStrut(8));
   name.add(new Label("所在城市:"));

 
 
   edit=Box.createVerticalBox();
   edit.add(username); //*用 户 名:
   edit.add(Box.createVerticalStrut(8));
   edit.add(password1); //*密    码:
   edit.add(Box.createVerticalStrut(8));
   edit.add(password2); //*确认秘密:
   edit.add(Box.createVerticalStrut(8));
 
 
   Choice choice=new Choice();
   choice.add("你的出生地在那里?");
   choice.add("你妈妈的名字叫什么?");
   choice.add("你爸爸的名字叫什么?");
   choice.add("你的学校位于哪里?");
   choice.add("你的名字是什么?");
   choice.add("你的学号是多少?");
   choice.add("你家有多少人?");
   edit.add(choice); //*密码提示问题:
   edit.add(Box.createVerticalStrut(8));
 
 
 
   edit.add(answer); //*答案
   edit.add(Box.createVerticalStrut(8));
   edit.add(email); //*保密邮箱:
   edit.add(Box.createVerticalStrut(8));
 
 
// DateChooser dateChooser = new DateChooser(this);
   Box birth=Box.createHorizontalBox();
 
   for(int i=1900;i<=2009;i++) {
 new String();
 year.add(String.valueOf(i));
}
   Choice mouth=new Choice();
   for(int i=1;i<=12;i++) {
 new String();
 mouth.add(String.valueOf(i));
}
   Choice day=new Choice();
   for(int i=1;i<=31;i++) {
 new String();
 day.add(String.valueOf(i));
}
   birth.add(year);
   year.addItemListener(this);
   birth.add(new Label("年"));
   Box.createHorizontalStrut(5);
   birth.add(mouth);
   birth.add(new Label("月"));
   Box.createHorizontalStrut(5);
   birth.add(day);
   birth.add(new Label("日"));
   edit.add(birth);   //*出生日期:
   edit.add(Box.createVerticalStrut(8));
 
 
 
   CheckboxGroup sex=new CheckboxGroup();
   Box peoplesex=Box.createHorizontalBox();
   peoplesex.add(new Checkbox("男",true,sex));
   peoplesex.add(new Checkbox("女",false,sex));
   edit.add(peoplesex);//*性别
   edit.add(Box.createVerticalStrut(8));
 
 
 
   edit.add(age);//年龄
   edit.add(Box.createVerticalStrut(8));
 
 
 
 
 
   Choice shouru=new Choice();
   shouru.add("白羊座");
   shouru.add("金牛座");
   shouru.add("双子座");
   shouru.add("巨蟹座");
   shouru.add("狮子座");
   shouru.add("处女座");
   shouru.add("天枰座");
   shouru.add("天蝎座");
   shouru.add("射手座");
   shouru.add("魔羯座");
   shouru.add("水瓶座");
   shouru.add("双鱼座");
   edit.add(Box.createVerticalStrut(8));
   edit.add(shouru);
 
 
   province.add("湖北省");
   province.add("广东省");
   province.add("广西省");
   province.add("云南省");
   province.add("山东省");
   province.add("辽宁省");
   province.addItemListener(this);
   edit.add(Box.createVerticalStrut(8));
   edit.add(province);//所在省
   edit.add(Box.createVerticalStrut(8));
 
 
 
 
 
   city.add("荆州市");
   city.add("荆门市");
   city.add("仙桃市");
   city.add("天门市");
   city.add("随州市");
   city.add("襄樊市");
   city.add("武汉市");
   city.add("宜昌市");
   city.add("十堰市");
   city.add("鄂州市");
   city.add("黄冈市");
   city.add("咸宁市");
   city.add("孝感市");
   city.add("黄石市");
   city.add("潜江市");
   city.add("恩施土家族苗族自治州");
   city.add("神农架林区");
   city.add("其他");
   edit.add(city);
   edit.add(Box.createVerticalStrut(20));
 
 
 
 
 
 
 
   baseBox=Box.createHorizontalBox();
   baseBox.add(name);
   baseBox.add(Box.createHorizontalStrut(20));
   baseBox.add(edit);
 
// setLayout(new FlowLayout());
// add(baseBox);
 
   Panel one=new Panel();
   one.add(baseBox);
 
   Panel tow=new Panel();
   Box k=Box.createHorizontalBox();
   k.add(summit);
   k.add(Box.createHorizontalStrut(100));
   k.add(exit);
   summit.addActionListener(this);
   exit.addActionListener(this);
   tow.add(k);
 
 
   Label main=new Label("注册窗口");
   Font f=new Font(null,Font.BOLD,32);
   main.setFont(f); 
   Panel three=new Panel();
   three.setLayout(new FlowLayout());
   three.add(main);
 
 
   add(three,BorderLayout.NORTH);
   add(one,BorderLayout.CENTER);
   add(tow,BorderLayout.SOUTH);

   setBounds(120,125,400,540);
 
 

   addWindowListener(new WindowAdapter(){
    public void windowClosing(WindowEvent e){
     System.exit(0);
    }
  
   });
 
 
   setVisible(true);

   validate();
 
  
 
 
 
}

 

public void actionPerformed(ActionEvent e) {
   if(e.getSource()==exit)System.exit(0);
   else if(e.getSource()==summit){
    String uname=username.getText();
  
    String pw1=password1.getText();
    String pw2=password2.getText();
    String ans=answer.getText();
    String eml=email.getText();
    if(uname.equals(""))JOptionPane.showMessageDialog(null,"用户名不能为空!!!");
    else if(pw1.equals("") || pw2.equals(""))JOptionPane.showMessageDialog(null,"密码不能为空!!!");
    else if(ans.equals(""))JOptionPane.showMessageDialog(null,"答案不能为空!!!");
    else if(eml.equals(""))JOptionPane.showMessageDialog(null,"保密邮箱不能为空!!!");
    else if(!pw1.equals(pw2))JOptionPane.showMessageDialog(null,"密码错误!!!");
    else{
     JOptionPane.showMessageDialog(null,"恭喜您 "+uname+"/n注册成功/n请记住您的秘密:"+pw1);
    }
  
   }
 
}


public void itemStateChanged(ItemEvent e) {
   if (e.getSource() == province) {
    String name = province.getSelectedItem();

    System.out.println(name);
    if (name == "湖北省") {
     city.removeAll();
     city.add("荆州市");
     city.add("荆门市");
     city.add("仙桃市");
     city.add("天门市");
     city.add("随州市");
     city.add("襄樊市");
     city.add("武汉市");
     city.add("宜昌市");
     city.add("十堰市");
     city.add("鄂州市");
     city.add("黄冈市");
     city.add("咸宁市");
     city.add("孝感市");
     city.add("黄石市");
     city.add("潜江市");
     city.add("恩施土家族苗族自治州");
     city.add("神农架林区");
     city.add("其他");
        edit.add(city);
   }if (name == "广东省") {
     city.removeAll();
     city.add("广州市");
     city.add("佛山市");
     city.add("潮州市");
     city.add("汕头市");
     city.add("清远市");
     city.add("韶关市");
     city.add("河源市");
     city.add("梅州市");
     city.add("其他");
     edit.add(city);
    } else if (name == "广西省") {
     city.removeAll();
     city.add("桂林市");
     city.add("南宁市");
     city.add("北海市");
     city.add("梧州市");
     city.add("玉林市");
     city.add("贵港市");
     city.add("百色市");
     city.add("河池市");
     city.add("其他");
    } else if (name == "山东省") {
     city.removeAll();
     city.add("济南市");
     city.add("青岛市");
     city.add("烟台市");
     city.add("济宁市");
     city.add("泰安市");
     city.add("威海市");
     city.add("德州市");
     city.add("日照市");
     city.add("其他");
    } else if (name == "云南省") {
     city.removeAll();
     city.add("昆明市");
     city.add("玉溪市");
     city.add("曲靖市");
     city.add("梧州市");
     city.add("昭通市");
     city.add("保山市");
     city.add("丽江市");
     city.add("临沧市");
     city.add("其他");
    } else if (name == "辽宁省") {
     city.removeAll();
     city.add("沈阳市");
     city.add("新民市");
     city.add("大连市");
     city.add("鞍山市");
     city.add("抚顺市");
     city.add("锦州市");
     city.add("本溪市");
     city.add("丹东市");
     city.add("其他");
    }
   }
   else if(e.getSource()==year){
    String s=year.getSelectedItem();
    int suishu=Integer.parseInt(s);
    suishu=2009-suishu;
    s=s.valueOf(suishu);
    age.setText(s);
   }
  

    }
  

 

 

//public class {
public static void main(String args[]){
   new Register();

}
}

/**
 *
 */
package Zodiac;

import java.awt.ScrollPane;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextArea;


/**
 * @author ${聂传杰}
 *
 * 2010-8-5
 */

public class StarInformation extends JFrame {

 public MyPanel mp ;
 JButton jb = new JButton("星座特性");
 JButton jb1 = new JButton("今日运势");
 JButton jb2 = new JButton("返回");
 JTextArea jta = new JTextArea();
 ScrollPane sp = new ScrollPane();
 ActionStar as = new ActionStar(this);
 JLabel b1 = new JLabel("<html><font face=楷体_GB2312 size=4 color =green>你的星座是:</font></html>");
 public JLabel b;
 public String str;

 JLabel jhbp;
 JComboBox hbp = new JComboBox();
 JButton jbhbp = new JButton("黑白配");

 public StarInformation(String ii,String img) {
  mp = new MyPanel(img);
  String[] star = { "白羊座", "天蝎座", "狮子座", "双鱼座", "摩羯座", "双子座", "处女座",
    "巨蟹座", "射手座", "金牛座", "水瓶座", "天秤座" };
  str = ii;
  String we = "<html><font face=楷体_GB2312 size=4 color =red>" + ii + "</font></html>";
  b = new JLabel(we);
  jhbp = new JLabel("<html><font face=楷体_GB2312 size=4 color =green>星座配对</font></html>");
  this.add(mp);
  mp.setLayout(null);
  mp.add(jhbp);
  jhbp.setBounds(70, 170, 60, 30);
  mp.add(hbp);
  for (int i = 0; i < 12; i++) {
   hbp.addItem(star[i]);
  }

  hbp.setBounds(62, 220, 70, 20);
  mp.add(jbhbp);
  jbhbp.setBounds(50, 270, 90, 30);

  jbhbp.addActionListener(new ActionListener() {

   public void actionPerformed(ActionEvent e) {

    String item = (String) hbp.getSelectedItem();
    as.starReason(str, item);

   }

  });
  mp.add(b);
  b.setBounds(120, 14, 60, 25);

  mp.add(b1);
  b1.setBounds(30, 15, 90, 20);
  
  
  mp.add(jta);
  jta.setOpaque(false);
  jta.setBounds(180, 40, 610, 520);

  mp.add(jb);
  jb.setBounds(50, 50, 90, 30);
  jb.addActionListener(new ActionListener() {

   public void actionPerformed(ActionEvent e) {
    JButton jb = (JButton) e.getSource();
    String name = jb.getText();
    as.Action(name, str);

   }

  });
  mp.add(jb1);
  jb1.setBounds(50, 100, 90, 30);
  jb1.addActionListener(new ActionListener() {

   public void actionPerformed(ActionEvent e) {
    JButton jb = (JButton) e.getSource();
    String name = jb.getText();

    as.Action(name, str);
   }

  });
  
  mp.add(jb2);
  jb2.setBounds(60, 520, 70, 30);
  jb2.addActionListener(new ActionListener(){

   public void actionPerformed(ActionEvent e) {
    JButton jb=(JButton) e.getSource();
    String name=jb.getText();
    as.Action(name, str);
    
   }
   
  });
  this.setSize(800, 600);
  this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  this.setLocationRelativeTo(null);
  this.setVisible(true);

 }

}
 

/**
 *
 */
package Zodiac;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

 

/**
 * @author ${聂传杰}
 *
 * 2010-8-5
 */

public class ActionStar {

 public StarInformation si;
 String str = "";
   // 利用构造器传递一个对象。
 public ActionStar(StarInformation si) {
  this.si = si;
 }
    //我晕!! 和starReason方法相同了.....
 
 public void Action(String name, String s) {
    if(name.equals("返回")){
    new MainPanel();
   si.setVisible(false);
   si.dispose();
    }

  if (name.equals("今日运势")) {
   if (s.equals("白羊座")) {
    str = "folder//baiyang.txt";

    this.readOut(str);

   }
   if (s.equals("金牛座")) {
    str = "folder//jinniu.txt";

    this.readOut(str);

   }
   if (s.equals("双子座")) {
    str = "folder//shuangzi.txt";

    this.readOut(str);

   }
   if (s.equals("巨蟹座")) {
    str = "folder//juxie.txt";

    this.readOut(str);

   }
   if (s.equals("狮子座")) {
    str = "folder//shizi.txt";

    this.readOut(str);

   }
   if (s.equals("处女座")) {
    str = "folder//chunv.txt";

    this.readOut(str);

   }
   if (s.equals("天秤座")) {
    str = "folder//tianping.txt";

    this.readOut(str);

   }
   if (s.equals("天蝎座")) {
    str = "folder//tianxie.txt";

    this.readOut(str);

   }
   if (s.equals("射手座")) {
    str = "folder//sheshou.txt";

    this.readOut(str);

   }
   if (s.equals("摩羯座")) {
    str = "folder//moxie.txt";

    this.readOut(str);

   }
   if (s.equals("水瓶座")) {
    str = "folder//shuiping.txt";

    this.readOut(str);

   }
   if (s.equals("双鱼座")) {
    str = "folder//shuangyv.txt";

    this.readOut(str);

   }
  }
  if (name.equals("星座特性")) {

   if (s.equals("白羊座")) {
    str = "folder//baiyang_t.txt";

    this.readOut(str);

   }
   if (s.equals("金牛座")) {
    str = "folder//jinniu_t.txt";

    this.readOut(str);

   }
   if (s.equals("双子座")) {
    str = "folder//shuangzi_t.txt";

    this.readOut(str);

   }
   if (s.equals("巨蟹座")) {
    str = "folder//jvxie_t.txt";

    this.readOut(str);

   }
   if (s.equals("狮子座")) {
    str = "folder//shizi_t.txt";

    this.readOut(str);

   }
   if (s.equals("处女座")) {
    str = "folder//chunv_t.txt";

    this.readOut(str);

   }
   if (s.equals("天秤座")) {
    str = "folder//tianping_t.txt";

    this.readOut(str);

   }
   if (s.equals("天蝎座")) {
    str = "folder//tianxie_t.txt";

    this.readOut(str);

   }
   if (s.equals("射手座")) {
    str = "folder//sheshou_t.txt";

    this.readOut(str);

   }
   if (s.equals("摩羯座")) {
    str = "folder//moxie_t.txt";

    this.readOut(str);

   }
   if (s.equals("水瓶座")) {
    str = "folder//shuiping_t.txt";

    this.readOut(str);

   }
   if (s.equals("双鱼座")) {
    str = "folder//shuangyv_t.txt";

    this.readOut(str);

   }
  }

 }
 
 //  星座配对的方法。向文件传入两个星座名,读取相应文件。
 
 
 public void starReason(String str,String item){
  if ((str.equals("白羊座")&&item.equals("金牛座"))||(item.equals("白羊座")&&str.equals("金牛座"))) {
   str = "folder//baiyang_jinniu.txt";

   this.readOut(str);

  }
  if ((str.equals("白羊座")&&item.equals("天蝎座"))||(item.equals("白羊座")&&str.equals("天蝎座"))) {
   str = "folder//baiyang_tianxie.txt";

   this.readOut(str);

  }
  if ((str.equals("白羊座")&&item.equals("射手座"))||(item.equals("白羊座")&&str.equals("射手座"))) {
   str = "folder//baiyang_sheshou.txt";

   this.readOut(str);

  }
  if ((str.equals("白羊座")&&item.equals("白羊座"))||(item.equals("白羊座")&&str.equals("白羊座"))) {
   str = "folder//baiyang_baiyang.txt";

   this.readOut(str);

  }
  if ((str.equals("白羊座")&&item.equals("处女座"))||(item.equals("白羊座")&&str.equals("处女座"))) {
   str = "folder//baiyang_chunv.txt";

   this.readOut(str);

  }
  if ((str.equals("白羊座")&&item.equals("双鱼座"))||(item.equals("白羊座")&&str.equals("双鱼座"))) {
   str = "folder//baiyang_shuangyv.txt";

   this.readOut(str);

  }
  if ((str.equals("白羊座")&&item.equals("双子座"))||(item.equals("白羊座")&&str.equals("双子座"))) {
   str = "folder//baiyang_shuangzi.txt";

   this.readOut(str);

  }
  if ((str.equals("白羊座")&&item.equals("狮子座"))||(item.equals("白羊座")&&str.equals("狮子座"))) {
   str = "folder//baiyang_shizi.txt";

   this.readOut(str);

  }
  if ((str.equals("白羊座")&&item.equals("摩羯座"))||(item.equals("白羊座")&&str.equals("摩羯座"))) {
   str = "folder//baiyang_moxie.txt";

   this.readOut(str);

  }
  if ((str.equals("白羊座")&&item.equals("巨蟹座"))||(item.equals("白羊座")&&str.equals("巨蟹座"))) {
   str = "folder//baiyang_jvxie.txt";

   this.readOut(str);

  }
  if ((str.equals("白羊座")&&item.equals("水瓶座"))||(item.equals("白羊座")&&str.equals("水瓶座"))) {
   str = "folder//baiyang_shuiping.txt";

   this.readOut(str);

  }
  if ((str.equals("白羊座")&&item.equals("天秤座"))||(item.equals("白羊座")&&str.equals("天秤座"))) {
   str = "folder//baiyang_tianping.txt";

   this.readOut(str);

  }


  
  /
  
  
  if ((str.equals("金牛座")&&item.equals("金牛座"))||(item.equals("金牛座")&&str.equals("金牛座"))) {
   str = "folder//jinniu_jinniu.txt";

   this.readOut(str);

  }
  if ((str.equals("金牛座")&&item.equals("天蝎座"))||(item.equals("金牛座")&&str.equals("天蝎座"))) {
   str = "folder//jinniu_tianxie.txt";

   this.readOut(str);

  }
  if ((str.equals("金牛座")&&item.equals("射手座"))||(item.equals("金牛座")&&str.equals("射手座"))) {
   str = "folder//jinniu_sheshou.txt";

   this.readOut(str);

  }
  
  if ((str.equals("金牛座")&&item.equals("处女座"))||(item.equals("金牛座")&&str.equals("处女座"))) {
   str = "folder//jinniu_chunv.txt";

   this.readOut(str);

  }
  if ((str.equals("金牛座")&&item.equals("双鱼座"))||(item.equals("金牛座")&&str.equals("双鱼座"))) {
   str = "folder//jinniu_shuangyv.txt";

   this.readOut(str);

  }
  if ((str.equals("金牛座")&&item.equals("双子座"))||(item.equals("金牛座")&&str.equals("双子座"))) {
   str = "folder//jinniu_shuangzi.txt";

   this.readOut(str);

  }
  if ((str.equals("金牛座")&&item.equals("狮子座"))||(item.equals("金牛座")&&str.equals("狮子座"))) {
   str = "folder//jinniu_shizi.txt";

   this.readOut(str);

  }
  if ((str.equals("金牛座")&&item.equals("摩羯座"))||(item.equals("金牛座")&&str.equals("摩羯座"))) {
   str = "folder//jinniu_moxie.txt";

   this.readOut(str);

  }
  if ((str.equals("金牛座")&&item.equals("巨蟹座"))||(item.equals("金牛座")&&str.equals("巨蟹座"))) {
   str = "folder//jinniu_jvxie.txt";

   this.readOut(str);

  }
  if ((str.equals("金牛座")&&item.equals("水瓶座"))||(item.equals("金牛座")&&str.equals("水瓶座"))) {
   str = "folder//jinniu_shuiping.txt";

   this.readOut(str);

  }
  if ((str.equals("金牛座")&&item.equals("天秤座"))||(item.equals("金牛座")&&str.equals("天秤座"))) {
   str = "folder//jinniu_tianping.txt";

   this.readOut(str);

  }
  
  
  /
  
  
  
  
  if ((str.equals("双子座")&&item.equals("天蝎座"))||(item.equals("双子座")&&str.equals("天蝎座"))) {
   str = "folder//shuangzi_tianxie.txt";

   this.readOut(str);

  }
  if ((str.equals("双子座")&&item.equals("射手座"))||(item.equals("双子座")&&str.equals("射手座"))) {
   str = "folder//shuangzi_sheshou.txt";

   this.readOut(str);

  }
  
  if ((str.equals("双子座")&&item.equals("处女座"))||(item.equals("双子座")&&str.equals("处女座"))) {
   str = "folder//shuangzi_chunv.txt";

   this.readOut(str);

  }
  if ((str.equals("双子座")&&item.equals("双鱼座"))||(item.equals("双子座")&&str.equals("双鱼座"))) {
   str = "folder//shuangzi_shuangyv.txt";

   this.readOut(str);

  }
  if ((str.equals("双子座")&&item.equals("双子座"))||(item.equals("双子座")&&str.equals("双子座"))) {
   str = "folder//shuangzi_shuangzi.txt";

   this.readOut(str);

  }
  if ((str.equals("双子座")&&item.equals("狮子座"))||(item.equals("双子座")&&str.equals("狮子座"))) {
   str = "folder//shuangzi_shizi.txt";

   this.readOut(str);

  }
  if ((str.equals("双子座")&&item.equals("摩羯座"))||(item.equals("双子座")&&str.equals("摩羯座"))) {
   str = "folder//shuangzi_moxie.txt";

   this.readOut(str);

  }
  if ((str.equals("双子座")&&item.equals("巨蟹座"))||(item.equals("双子座")&&str.equals("巨蟹座"))) {
   str = "folder//shuangzi_jvxie.txt";

   this.readOut(str);

  }
  if ((str.equals("双子座")&&item.equals("水瓶座"))||(item.equals("双子座")&&str.equals("水瓶座"))) {
   str = "folder//shuangzi_shuiping.txt";

   this.readOut(str);

  }
  if ((str.equals("双子座")&&item.equals("天秤座"))||(item.equals("双子座")&&str.equals("天秤座"))) {
   str = "folder//shuangzi_tianping.txt";

   this.readOut(str);

  }
  
  
  ///
  
  
  if ((str.equals("巨蟹座")&&item.equals("天蝎座"))||(item.equals("巨蟹座")&&str.equals("天蝎座"))) {
   str = "folder//jvxie_tianxie.txt";

   this.readOut(str);

  }
  if ((str.equals("巨蟹座")&&item.equals("射手座"))||(item.equals("巨蟹座")&&str.equals("射手座"))) {
   str = "folder//jvxie_sheshou.txt";

   this.readOut(str);

  }
  
  if ((str.equals("巨蟹座")&&item.equals("处女座"))||(item.equals("巨蟹座")&&str.equals("处女座"))) {
   str = "folder//jvxie_chunv.txt";

   this.readOut(str);

  }
  if ((str.equals("巨蟹座")&&item.equals("双鱼座"))||(item.equals("巨蟹座")&&str.equals("双鱼座"))) {
   str = "folder//jvxie_shuangyv.txt";

   this.readOut(str);

  }
  if ((str.equals("巨蟹座")&&item.equals("狮子座"))||(item.equals("巨蟹座")&&str.equals("狮子座"))) {
   str = "folder//jvxie_shizi.txt";

   this.readOut(str);

  }
  if ((str.equals("巨蟹座")&&item.equals("摩羯座"))||(item.equals("巨蟹座")&&str.equals("摩羯座"))) {
   str = "folder//jvxie_moxie.txt";

   this.readOut(str);

  }
  if ((str.equals("巨蟹座")&&item.equals("巨蟹座"))||(item.equals("巨蟹座")&&str.equals("巨蟹座"))) {
   str = "folder//jvxie_jvxie.txt";

   this.readOut(str);

  }
  if ((str.equals("巨蟹座")&&item.equals("水瓶座"))||(item.equals("巨蟹座")&&str.equals("水瓶座"))) {
   str = "folder//jvxie_shuiping.txt";

   this.readOut(str);

  }
  if ((str.equals("巨蟹座")&&item.equals("天秤座"))||(item.equals("巨蟹座")&&str.equals("天秤座"))) {
   str = "folder//jvxie_tianping.txt";

   this.readOut(str);

  }
  
  
  
  
  if ((str.equals("狮子座")&&item.equals("天蝎座"))||(item.equals("狮子座")&&str.equals("天蝎座"))) {
   str = "folder//shizi_tianxie.txt";

   this.readOut(str);

  }
  if ((str.equals("狮子座")&&item.equals("射手座"))||(item.equals("狮子座")&&str.equals("射手座"))) {
   str = "folder//shizi_sheshou.txt";

   this.readOut(str);

  }
  
  if ((str.equals("狮子座")&&item.equals("处女座"))||(item.equals("狮子座")&&str.equals("处女座"))) {
   str = "folder//shizi_chunv.txt";

   this.readOut(str);

  }
  if ((str.equals("狮子座")&&item.equals("双鱼座"))||(item.equals("狮子座")&&str.equals("双鱼座"))) {
   str = "folder//shizi_shuangyv.txt";

   this.readOut(str);

  }
  if ((str.equals("狮子座")&&item.equals("狮子座"))||(item.equals("狮子座")&&str.equals("狮子座"))) {
   str = "folder//shizi_shizi.txt";

   this.readOut(str);

  }
  if ((str.equals("狮子座")&&item.equals("摩羯座"))||(item.equals("狮子座")&&str.equals("摩羯座"))) {
   str = "folder//shizi_moxie.txt";

   this.readOut(str);

  }
 
  if ((str.equals("狮子座")&&item.equals("水瓶座"))||(item.equals("狮子座")&&str.equals("水瓶座"))) {
   str = "folder//shizi_shuiping.txt";

   this.readOut(str);

  }
  if ((str.equals("狮子座")&&item.equals("天秤座"))||(item.equals("狮子座")&&str.equals("天秤座"))) {
   str = "folder//shizi_tianping.txt";

   this.readOut(str);

  }
  
  /
  
  if ((str.equals("处女座")&&item.equals("天蝎座"))||(item.equals("处女座")&&str.equals("天蝎座"))) {
   str = "folder//chunv_tianxie.txt";

   this.readOut(str);

  }
  if ((str.equals("处女座")&&item.equals("射手座"))||(item.equals("处女座")&&str.equals("射手座"))) {
   str = "folder//chunv_sheshou.txt";

   this.readOut(str);

  }
  
  if ((str.equals("处女座")&&item.equals("处女座"))||(item.equals("处女座")&&str.equals("处女座"))) {
   str = "folder//chunv_chunv.txt";

   this.readOut(str);

  }
  if ((str.equals("处女座")&&item.equals("双鱼座"))||(item.equals("处女座")&&str.equals("双鱼座"))) {
   str = "folder//chunv_shuangyv.txt";

   this.readOut(str);

  }
  
  if ((str.equals("处女座")&&item.equals("摩羯座"))||(item.equals("处女座")&&str.equals("摩羯座"))) {
   str = "folder//chunv_moxie.txt";

   this.readOut(str);

  }
 
  if ((str.equals("处女座")&&item.equals("水瓶座"))||(item.equals("处女座")&&str.equals("水瓶座"))) {
   str = "folder//chunv_shuiping.txt";

   this.readOut(str);

  }
  if ((str.equals("处女座")&&item.equals("天秤座"))||(item.equals("处女座")&&str.equals("天秤座"))) {
   str = "folder//chunv_tianping.txt";

   this.readOut(str);

  }
  
  
  
  if ((str.equals("天秤座")&&item.equals("天蝎座"))||(item.equals("天秤座")&&str.equals("天蝎座"))) {
   str = "folder//tianping_tianxie.txt";

   this.readOut(str);

  }
  if ((str.equals("天秤座")&&item.equals("射手座"))||(item.equals("天秤座")&&str.equals("射手座"))) {
   str = "folder//tianping_sheshou.txt";

   this.readOut(str);

  }
  
  if ((str.equals("天秤座")&&item.equals("双鱼座"))||(item.equals("天秤座")&&str.equals("双鱼座"))) {
   str = "folder//tianping_shuangyv.txt";

   this.readOut(str);

  }
  
  if ((str.equals("天秤座")&&item.equals("摩羯座"))||(item.equals("天秤座")&&str.equals("摩羯座"))) {
   str = "folder//tianping_moxie.txt";

   this.readOut(str);

  }
 
  if ((str.equals("天秤座")&&item.equals("水瓶座"))||(item.equals("天秤座")&&str.equals("水瓶座"))) {
   str = "folder//tianping_shuiping.txt";

   this.readOut(str);

  }
  if ((str.equals("天秤座")&&item.equals("天秤座"))||(item.equals("天秤座")&&str.equals("天秤座"))) {
   str = "folder//tianping_tianping.txt";

   this.readOut(str);

  }
  
  
  
  
  if ((str.equals("天蝎座")&&item.equals("天蝎座"))||(item.equals("天蝎座")&&str.equals("天蝎座"))) {
   str = "folder//tianxie_tianxie.txt";

   this.readOut(str);

  }
  if ((str.equals("天蝎座")&&item.equals("射手座"))||(item.equals("天蝎座")&&str.equals("射手座"))) {
   str = "folder//tianxie_sheshou.txt";

   this.readOut(str);

  }
  
  if ((str.equals("天蝎座")&&item.equals("双鱼座"))||(item.equals("天蝎座")&&str.equals("双鱼座"))) {
   str = "folder//tianxie_shuangyv.txt";

   this.readOut(str);

  }
  
  if ((str.equals("天蝎座")&&item.equals("摩羯座"))||(item.equals("天蝎座")&&str.equals("摩羯座"))) {
   str = "folder//tianxie_moxie.txt";

   this.readOut(str);

  }
 
  if ((str.equals("天蝎座")&&item.equals("水瓶座"))||(item.equals("天蝎座")&&str.equals("水瓶座"))) {
   str = "folder//tianxie_shuiping.txt";

   this.readOut(str);

  }
  
  /
 
  if ((str.equals("射手座")&&item.equals("射手座"))||(item.equals("射手座")&&str.equals("射手座"))) {
   str = "folder//sheshou_sheshou.txt";

   this.readOut(str);

  }
  
  if ((str.equals("射手座")&&item.equals("双鱼座"))||(item.equals("射手座")&&str.equals("双鱼座"))) {
   str = "folder//sheshou_shuangyv.txt";

   this.readOut(str);

  }
  
  if ((str.equals("射手座")&&item.equals("摩羯座"))||(item.equals("射手座")&&str.equals("摩羯座"))) {
   str = "folder//sheshou_moxie.txt";

   this.readOut(str);

  }
 
  if ((str.equals("射手座")&&item.equals("水瓶座"))||(item.equals("射手座")&&str.equals("水瓶座"))) {
   str = "folder//sheshou_shuiping.txt";

   this.readOut(str);

  }
  
  
 
  if ((str.equals("摩羯座")&&item.equals("双鱼座"))||(item.equals("摩羯座")&&str.equals("双鱼座"))) {
   str = "folder//moxie_shuangyv.txt";

   this.readOut(str);

  }
  
  if ((str.equals("摩羯座")&&item.equals("摩羯座"))||(item.equals("摩羯座")&&str.equals("摩羯座"))) {
   str = "folder//moxie_moxie.txt";

   this.readOut(str);

  }
 
  if ((str.equals("摩羯座")&&item.equals("水瓶座"))||(item.equals("摩羯座")&&str.equals("水瓶座"))) {
   str = "folder//moxie_shuiping.txt";

   this.readOut(str);

  }
  ///
  
  if ((str.equals("水瓶座")&&item.equals("双鱼座"))||(item.equals("水瓶座")&&str.equals("双鱼座"))) {
   str = "folder//shuiping_shuangyv.txt";

   this.readOut(str);

  }
  
 
  if ((str.equals("水瓶座")&&item.equals("水瓶座"))||(item.equals("水瓶座")&&str.equals("水瓶座"))) {
   str = "folder//shuiping_shuiping.txt";

   this.readOut(str);

  }
  
  // /
  
  if ((str.equals("双鱼座")&&item.equals("双鱼座"))||(item.equals("双鱼座")&&str.equals("双鱼座"))) {
   str = "folder//shuangyv_shuangyv.txt";

   this.readOut(str);

  }
  
  
  
 }

 
 
 // 文件读取到textarea的方法。传入文件名直接读取。
 
 public void readOut(String name) {

  File f = new File(name);
  try {
   BufferedReader br = new BufferedReader(new FileReader(f));
   String s = br.readLine();
   String sum = "";
   while (s != null) {
    sum += s + '/n';
    s = br.readLine();
   }
   si.jta.setText(sum);
   br.close();
  } catch (FileNotFoundException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }

 }

}
package Zodiac;
/**
 * @author ${聂传杰}
 *
 * 2010-8-5
 */

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

import javax.swing.JOptionPane;


public class ActionLogin {
 public Login l;
 File f = new File("folder//user.txt");
  public ActionLogin(){
   
  }
 

 public ActionLogin(Login lm) {

  this.l = lm;
 }
 
 public void Action(String name) {
  
       //  登入判断
  
  if (name.equals("登入")) {
   String s = l.jtf.getText() + l.jtf2.getText();
   String names = l.jtf.getText();
   String password = l.jtf2.getText();
   if (names.equals("") || names == null) {
    JOptionPane.showMessageDialog(l.jp, "请输入账号");

   } else if (password.equals("") || password == null) {
    JOptionPane.showMessageDialog(l.jp, "请输入密码");
   } else {
    int i = this.check(f, s, names, password);
    if (i == 0) {
     JOptionPane.showMessageDialog(l.jp, "姓名或密码错误!请重新输入");
     l.jtf.setText("");
     l.jtf2.setText("");
    }
   }

  }
  // 注册判断。
  if (name.equals("注册")) {

   String s = l.jtf.getText() + " " + l.jtf2.getText();
   String names = l.jtf.getText();
   String password = l.jtf2.getText();
   if (names.equals("") || names == null) {
    JOptionPane.showMessageDialog(l.jp, "姓名是空,请输入性名");

   } else if (password.equals("") || password == null) {
    JOptionPane.showMessageDialog(l.jp, "密码是空,请输入密码");
   } else {
    int i = this.checkName(f, s);
    if (i == 0) {
     JOptionPane.showMessageDialog(l.jp, "注册成功");
     l.jtf.setText("");
     l.jtf2.setText("");
     this.writeIn(f, s);
    }

   }

  }

 }

 // 从文件读取信息与文本框的数据做比较,判断,做相应的事件操作。
 public int check(File filename, String h, String name, String password) {
  int i = 0;
  try {
   BufferedReader br = new BufferedReader(new FileReader(filename));

   String s = br.readLine();

   while (s != null) {
    String[] arr = s.split("//s");
    if (arr[0].equals(name) && arr[1].equals(password)) {
     i = 1;
      MainPanel mw = new MainPanel();
     l.setVisible(false);
     l.dispose();

    }
    s = br.readLine();

   }
   br.close();
  } catch (FileNotFoundException e) {

   e.printStackTrace();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  return i;

 }
//    向指定文件写入数据。
 public void writeIn(File f, String s) {

  try {
   BufferedWriter bw = new BufferedWriter(new FileWriter(f, true));
   bw.newLine();
   bw.write(s);

   bw.close();

  } catch (IOException e) {

   e.printStackTrace();
  }

 }

 // 注册时读文件判断用户是否存在。
 public int checkName(File f, String s) {
  int i = 0;
  try {
   BufferedReader br = new BufferedReader(new FileReader(f));
   String sum = br.readLine();
   System.out.println(sum);
   while (sum != null) {
    String[] arr = sum.split("//s");
    if (arr[0].equals(l.jtf.getText())) {
     i = 1;
     JOptionPane.showMessageDialog(l.jp, "此用户已存在,注册失败");
     l.jtf.setText("");
    }

    sum = br.readLine();
   }
   br.close();
  } catch (FileNotFoundException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  } catch (IOException e) {
   // TODO Auto-generated catch block
   e.printStackTrace();
  }
  return i;

 }
}
 

 

 

前天刚做的 发着玩玩

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值