Java Bookstore system graduate design user module (3) _java

Source: Internet
Author: User
Tags gettext uuid

This example for you to share the Java Bookstore System graduate design 3rd, for your reference, the specific content as follows

Import java.util.List;
Import Javax.swing.JFrame;

Import Javax.swing.JOptionPane;
Import Cn.hncu.bookStore.user.business.factory.UserEbiFactory;

Import Cn.hncu.bookStore.user.vo.UserModel; /** * * @author __user__/public class Listpanel extends Javax.swing.JPanel {private static final long Serialversi
 Onuid = 1L;

 Private JFrame mainFrame = null;
 Public Listpanel (JFrame mainFrame) {//Initialize this.mainframe = MainFrame;
 Initcomponents ();
 Myinitdate (); @SuppressWarnings ("unchecked") public Listpanel (JFrame mainFrame, list<usermodel> List) {this.mainframe = Mai
 Nframe;
 Initcomponents ();
 Jlist.setlistdata (List.toarray ()); @SuppressWarnings ("unchecked") private void Myinitdate () {list<usermodel> List = Userebifactory.getuserebi ().
 GetAll ();

 Jlist.setlistdata (List.toarray ());
 //*** This section is automatically generated, the following will no longer be written * * */** This is called from within the constructor to * initialize the form. * Warning:do not modify this code. The content of this method IS * Always regenerated by the Form Editor. *///gen-begin:initcomponents//<editor-fold defaultstate= "collapsed" desc= "generated Code" > private void InitCo
 Mponents () {jLabel1 = new Javax.swing.JLabel ();
 JScrollPane1 = new Javax.swing.JScrollPane ();
 JList = new Javax.swing.JList ();
 Btntodelete = new Javax.swing.JButton ();
 Btntoupdate = new Javax.swing.JButton ();
 Btntoquery = new Javax.swing.JButton ();

 Btntoadd = new Javax.swing.JButton ();
 SetBackground (New Java.awt.Color (0, 153, 51));
 Setminimumsize (New Java.awt.Dimension (800, 600));

 SetLayout (NULL);
 Jlabel1.setfont (New Java.awt.Font ("Microsoft Yahei UI", 1, 36));
 Jlabel1.setforeground (New Java.awt.Color (204, 0, 204));
 Jlabel1.settext ("\u7528\u6237\u7ba1\u7406");
 Add (JLABEL1);

 Jlabel1.setbounds (330, 100, 190, 60);
 Jscrollpane1.setforeground (New Java.awt.Color (0, 51, 153));

 Jscrollpane1.setfont (New Java.awt.Font ("Microsoft Yahei UI", 1, 18)); Jlist.setfont (New Java.awt.Font ("Microsoft Yahei UI", 1, 24));

  Jlist.setmodel (New Javax.swing.AbstractListModel () {string[] strings = {""};
  public int GetSize () {return strings.length;
  Public Object getelementat (int i) {return strings[i];
 }
 });

 Jscrollpane1.setviewportview (jList);
 Add (JSCROLLPANE1);

 Jscrollpane1.setbounds (190, 170, 410, 220);
 Btntodelete.setfont (New Java.awt.Font ("Microsoft Yahei UI", 1, 18));
 Btntodelete.settext ("\u5220\u9664\u7528\u6237"); Btntodelete.addactionlistener (New Java.awt.event.ActionListener () {public void actionperformed (
  Java.awt.event.ActionEvent evt) {btntodeleteactionperformed (evt);
 }
 });
 Add (Btntodelete);

 Btntodelete.setbounds (240, 470, 110, 40);
 Btntoupdate.setfont (New Java.awt.Font ("Microsoft Yahei UI", 1, 18));
 Btntoupdate.settext ("\u4fee\u6539\u7528\u6237"); Btntoupdate.addactionlistener (New Java.awt.event.ActionListener () {public void actionperformed (
  Java.awt.event.ActionEvent evt) {btntoupdateactionperformed (evt);
 }
 });
 Add (btntoupdate); BtntoupdAte.setbounds (430, 470, 110, 40);
 Btntoquery.setfont (New Java.awt.Font ("Microsoft Yahei UI", 1, 18));
 Btntoquery.settext ("\u67e5\u627e\u7528\u6237"); Btntoquery.addactionlistener (New Java.awt.event.ActionListener () {public void actionperformed (
  Java.awt.event.ActionEvent evt) {btntoqueryactionperformed (evt);
 }
 });
 Add (Btntoquery);

 Btntoquery.setbounds (600, 470, 110, 40);
 Btntoadd.setfont (New Java.awt.Font ("Microsoft Yahei UI", 1, 18));
 Btntoadd.settext ("\u6dfb\u52a0\u7528\u6237"); Btntoadd.addactionlistener (New Java.awt.event.ActionListener () {public void actionperformed (
  Java.awt.event.ActionEvent evt) {btntoaddactionperformed (evt);
 }
 });
 Add (Btntoadd);
 Btntoadd.setbounds (60, 470, 110, 40); }//</editor-fold>//gen-end:initcomponents private void btntoqueryactionperformed (java.awt.event.ActionEvent
 EVT) {Mainframe.setcontentpane (new Querypanel (MainFrame));
 Mainframe.validate (); } private void Btntoupdateactionperformed (Java.awt.event.ActionEVent evt) {if (jlist.getselectedvalue () = null) {Joptionpane.showmessagedialog (this, select the user to modify);
 Return
 String uuid = Jlist.getselectedvalue (). toString (). Split (",") [0];
 Mainframe.setcontentpane (New UpdatePanel (MainFrame, uuid));
 Mainframe.validate (); } private void Btntodeleteactionperformed (Java.awt.event.ActionEvent evt) {if (jlist.getselectedvalue () = null) {J
  Optionpane.showmessagedialog (this, select the user to delete);
 Return
 String uuid = Jlist.getselectedvalue (). toString (). Split (",") [0];
 Mainframe.setcontentpane (New Deletepanel (MainFrame, uuid));
 Mainframe.validate (); } private void Btntoaddactionperformed (Java.awt.event.ActionEvent evt) {Mainframe.setcontentpane (New AddPanel (
 MainFrame));
 Mainframe.validate (); //*** This section is automatically generated, the following will no longer write * * *//gen-begin:variables//variables declaration-do not modify private Javax.swing.JButton
 Btntoadd;
 Private Javax.swing.JButton Btntodelete;
 Private Javax.swing.JButton btntoquery; Private Javax.swing.JButton BTntoupdate;
 Private Javax.swing.JLabel JLabel1;
 Private Javax.swing.JList JList;
 Private Javax.swing.JScrollPane jScrollPane1;

 End of Variables Declaration//gen-end:variables}

Import Javax.swing.JFrame;

Import Javax.swing.JOptionPane;
Import Cn.hncu.bookStore.user.business.factory.UserEbiFactory;
Import Cn.hncu.bookStore.user.common.UserTypeEnum;

Import Cn.hncu.bookStore.user.vo.UserModel; /** * * @author __user__/public class AddPanel extends Javax.swing.JPanel {private static final long Serialversio
 nuID = 1L;

 Private JFrame mainFrame = null;
 /** creates new form AddPanel */public AddPanel (JFrame mainFrame) {this.mainframe = MainFrame;
 Initcomponents ();
 Myinitdate ();
 @SuppressWarnings ("unchecked") private void Myinitdate () {combtype.removeallitems ();
 For (Usertypeenum utm:UserTypeEnum.values ()) {Combtype.additem (Utm.getname ()); //*** automatically generates code SKIP * * *//</editor-fold>//gen-end:initcomponents private void btncancelactionperformed (java.awt . event.
 ActionEvent evt) {Mainframe.setcontentpane (new Listpanel (MainFrame));
 Mainframe.validate (); } private void Btnaddactionperformed (Java.awt.event.ActionEvent evt) {StRing StrName = Tfdname.gettext (). Trim ();
 String Struuid = Tfduuid.gettext (). Trim ();
 String strpwd = new String (Tfdpwd.getpassword ());
 String StrPwd2 =new string (Tfdpwd2.getpassword ()); if (!strpwd.equals (STRPWD2)) {Joptionpane.showmessagedialog (this, "wrong password!)
  ");
 Return

 String Strcombtype = Combtype.getselecteditem (). toString ();
 Usermodel um = new Usermodel ();
 Um.setname (StrName);
 Um.setuuid (STRUUID);
 Um.setpwd (STRPWD);

 Um.settype (Usertypeenum.gettypebyname (Strcombtype));

 Boolean boo = Userebifactory.getuserebi (). Create (UM);
 if (boo) {btncancelactionperformed (null); else {Joptionpane.showmessagedialog (this, "User already exists!")
  ");
 Return

 }//*** automatically generate code skip * * *//gen-begin}

Import Javax.swing.JFrame;

Import Javax.swing.JOptionPane;
Import Cn.hncu.bookStore.user.business.ebi.UserEbi;
Import Cn.hncu.bookStore.user.business.factory.UserEbiFactory;
Import Cn.hncu.bookStore.user.common.UserTypeEnum;

Import Cn.hncu.bookStore.user.vo.UserModel; /** * * @author __user__/public class Deletepanel extends Javax.swing.JPanel {private static final long Serialver
 Sionuid = 1L;
 Private JFrame mainFrame = null;
 Private String uuid;

 Userebi ebi = Userebifactory.getuserebi ();
 /** creates new form AddPanel/public Deletepanel (JFrame mainFrame, String uuid) {this.mainframe = MainFrame;
 This.uuid = UUID;
 Initcomponents ();
 Myinitdate ();
 @SuppressWarnings ("unchecked") private void Myinitdate () {Usermodel um = Ebi.getsingle (UUID);
 Tfduuid.settext (UUID);
 Tfduuid.setenabled (FALSE);
 Tfdname.settext (Um.getname ());
 Tfdname.setenabled (FALSE);
 Tfdpwd.settext (Um.getpwd ());
 Tfdpwd.setenabled (FALSE);
 Tfdpwd2.settext (Um.getpwd ()); Tfdpwd2.setenabled (FALSE);
 Combtype.removeallitems ();
 For (Usertypeenum utm:UserTypeEnum.values ()) {Combtype.additem (Utm.getname ());
 } combtype.setselectedindex (Um.gettype ());

 Combtype.setenabled (FALSE); //*** automatically generates code SKIP * * *//</editor-fold>//gen-end:initcomponents private void btncancelactionperformed (Java.awt.ev Ent.
 ActionEvent evt) {Mainframe.setcontentpane (new Listpanel (MainFrame));
 Mainframe.validate ();

 private void Btndeleteactionperformed (Java.awt.event.ActionEvent evt) {Boolean boo = Ebi.delete (UUID);
 if (boo) {btncancelactionperformed (null); else {Joptionpane.showmessagedialog (this, "Delete user failed, user no longer exists!")
  ");
 Return

 }//*** automatically generate code skip * * *//gen-begin}

Import Javax.swing.JFrame;

Import Javax.swing.JOptionPane;
Import Cn.hncu.bookStore.user.business.ebi.UserEbi;
Import Cn.hncu.bookStore.user.business.factory.UserEbiFactory;
Import Cn.hncu.bookStore.user.common.UserTypeEnum;

Import Cn.hncu.bookStore.user.vo.UserModel; /** * * @author __user__/public class UpdatePanel extends Javax.swing.JPanel {private static final long Serialver
 Sionuid = 1L;
 Private JFrame mainFrame = null;
 Private String uuid;

 Userebi ebi = Userebifactory.getuserebi ();
 /** creates new form AddPanel/public UpdatePanel (JFrame mainFrame, String uuid) {this.mainframe = MainFrame;
 This.uuid = UUID;
 Initcomponents ();
 Myinitdate ();
 @SuppressWarnings ("unchecked") private void Myinitdate () {Usermodel um = Ebi.getsingle (UUID);
 Tfduuid.settext (UUID);
 Tfduuid.setenabled (FALSE);
 Tfdname.settext (Um.getname ());
 Tfdpwd.settext (Um.getpwd ());
 Tfdpwd2.settext (Um.getpwd ());
 Combtype.removeallitems (); For (Usertypeenum utm:UserTypeEnum.values ()) {Combtype.additem (Utm.getname ());

 } combtype.setselectedindex (Um.gettype ()); //*** automatically generates code SKIP * * *//</editor-fold>//gen-end:initcomponents private void btncancelactionperformed (Java.awt.ev Ent.
 ActionEvent evt) {Mainframe.setcontentpane (new Listpanel (MainFrame));
 Mainframe.validate ();
 private void Btnupdateactionperformed (Java.awt.event.ActionEvent evt) {String strName = Tfdname.gettext (). Trim ();
 String Struuid = Tfduuid.gettext (). Trim ();
 String strpwd = new String (Tfdpwd.getpassword ());
 String StrPwd2 =new string (Tfdpwd2.getpassword ()); if (!strpwd.equals (STRPWD2)) {Joptionpane.showmessagedialog (this, "wrong password!)
  ");
 Return

 String Strcombtype = Combtype.getselecteditem (). toString ();
 Usermodel um = new Usermodel ();
 Um.setname (StrName);
 Um.setuuid (STRUUID);
 Um.setpwd (STRPWD);

 Um.settype (Usertypeenum.gettypebyname (Strcombtype));

 Boolean boo = Userebifactory.getuserebi (). Update (UM);
 if (boo) {btncancelactionperformed (null); else {JoptiOnpane.showmessagedialog (This, "User already exists!")
  ");
 Return

 }//*** automatically generate code skip * * *//gen-begin}

Import java.util.List;

Import Javax.swing.JFrame;
Import Cn.hncu.bookStore.user.business.factory.UserEbiFactory;
Import Cn.hncu.bookStore.user.common.UserTypeEnum;
Import Cn.hncu.bookStore.user.vo.UserModel;

Import Cn.hncu.bookStore.user.vo.UserQueryModel; /** * * @author __user__/public class Querypanel extends Javax.swing.JPanel {private static final long serialvers
 Ionuid = 1L;

 Private JFrame mainFrame = null;
 /** creates new form AddPanel */public Querypanel (JFrame mainFrame) {this.mainframe = MainFrame;
 Initcomponents ();
 Myinitdate ();
 @SuppressWarnings ("unchecked") private void Myinitdate () {combtype.removeallitems ();
 Combtype.additem ("Please choose");
 For (Usertypeenum utm:UserTypeEnum.values ()) {Combtype.additem (Utm.getname ()); //*** automatically generates code SKIP * * *//</editor-fold>//gen-end:initcomponents private void btncancelactionperformed (Java.aw
 T.event.actionevent evt) {Mainframe.setcontentpane (new Listpanel (MainFrame));
 Mainframe.validate ();
}
 private void Btnqueryactionperformed (Java.awt.event.ActionEvent evt) {String strName = Tfdname.gettext (). Trim ();
 String Struuid = Tfduuid.gettext (). Trim ();

 String Strcombtype = Combtype.getselecteditem (). toString ();
 Userquerymodel uqm=new Userquerymodel ();
 Uqm.setname (StrName);
 Uqm.setuuid (STRUUID);
 int type=0;
 if (Combtype.getselectedindex () >0) {type=usertypeenum.gettypebyname (strcombtype);

 } uqm.settype (type);
  List<usermodel> list= Userebifactory.getuserebi (). Getbycondition (UQM);
  Mainframe.setcontentpane (New Listpanel (mainframe,list));


 Mainframe.validate ();

 //*** automatically generate code skip * * *//gen-begin}

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.