Java implémente le carnet d'adresses des élèves, utilise des fichiers XML comme stockage de données et met en œuvre les fonctions d'ajout, de supprimer, de modifier, de rechercher, de sauvegarder, de restaurer, de rechercher une classification professionnelle des numéros d'étudiants, des noms, des âges, des adresses, des majors, des anniversaires et d'autres informations.
Le projet doit importer le package Dom4j.jar.
/ * Ajouter un enregistrement étudiant * / Importer java.awt.borderlayout; import java.awt.eventqueue; import javax.swing.buttongroup; import javax.swing.jframe; import javax.swing.jpanel; java.awt.font; importer java.awt.event.actionEvent; import java.awt.event.actionListener; import javax.swing.jtextfield; import javax.swing.jradiobutton; import javax.swing.jbutton; import javax.swing.jcombox; addition de classe publique étend jaframe {privily jpanelpane; JTEXFIED JTET PRIVÉ; JTEXFIELD JTED JT2; JTEXFIED JTET PRIVÉ; JTEXFIED JTET privé; JTEXFIEL PRIVÉ JT5; JTEXFIELD JTED JT6; JTEXFIELD JTEND JT7; public addSerson () {setDefaultCloseOperation (jframe.exit_on_close); Setbounds (100, 100, 450, 489); contentPane = new JPanel (); ContentPane.SetBorder (New videBorder (5, 5, 5, 5)); contentPane.SetLayout (null); setContentPane (contentPane); JLABEL JL1 = New JLabel ("Student Address Book"); jl1.setfont (New Font ("Songyi", Font.Plain, 16)); JL1.SetBounds (10, 0, 95, 29); contentPane.add (JL1); JLabel jl2 = new JLabel ("numéro d'étudiant"); JL2.Setfont (New Font ("Songyi", Font.Plain, 16)); JL2.SetBounds (51, 39, 65, 29); contentPane.add (jl2); JLabel jl3 = new JLabel ("Nom de l'étudiant"); JL3.Setfont (New Font ("Songyi", Font.Plain, 16)); JL3.SetBounds (51, 78, 65, 29); contentPane.add (JL3); JLabel JL4 = new JLabel ("Student Gender"); JL4.Setfont (New Font ("Songyi", Font.Plain, 16)); JL4.SetBounds (51, 117, 65, 29); contentPane.add (JL4); JLABEL JL5 = New JLabel ("Age étudiant"); JL5.Setfont (New Font ("Songyi", Font.Plain, 16)); JL5.SetBounds (51, 163, 65, 29); contentPane.add (JL5); JLABEL JL6 = New JLabel ("Date de naissance"); jl6.setfont (new Font ("宋体", font.plain, 16)); JL6.SetBounds (51, 202, 65, 29); contentPane.add (JL6); JLABEL JL7 = new JLABEL ("宋体"); jl7.setfont (new Font ("宋体", font.plain, 16)); JL7.SetBounds (51, 250, 65, 29); ContentPane.Add (JL7); JLabel jl8 = new JLabel ("e-mail"); jl8.setfont (nouvelle police ("zongyi", font.plain, 16)); JL8.SetBounds (51, 296, 65, 29); ContentPane.Add (JL8); JLABEL JL9 = new JLABEL ("Adresse personnelle"); JL9.Setfont (New Font ("Zongyi", Font.Plain, 16)); JL9.SetBounds (51, 345, 65, 29); contentPane.add (jl9); JLABEL JL9 = new JLABEL ("Adresse personnelle"); JL9.Setfont (New Font ("Zongyi", Font.Plain, 16)); JL9.SetBounds (51, 345, 65, 29); contentPane.add (jl9); JLABEL JL10 = new JLABEL ("Nom professionnel"); jl10.setfont (new Font ("宋体", font.plain, 16)); JL10.SetBounds (51, 389, 65, 29); contentPane.add (JL10); jt1 = new JTextField (); JT1.SetBounds (129, 38, 150, 34); contentPane.add (JT1); jt1.setColumns (10); jt2 = new JTextField (); JT2.SetColumns (10); JT2.SetBounds (129, 83, 150, 34); contentPane.add (jt2); jt3 = new JTextField (); jt3.setColumns (10); JT3.SetBounds (129, 163, 150, 34); contentPane.add (JT3); jt4 = new JTextField (); JT4.SetColumns (10); JT4.SetBounds (129, 201, 150, 34); contentPane.add (JT4); jt5 = new JTextField (); JT5.SetColumns (10); JT5.SetBounds (129, 250, 150, 34); contentPane.add (JT5); jt6 = new JTextField (); jt6.setColumns (10); JT6.SetBounds (129, 301, 150, 34); contentPane.add (JT6); jt7 = new JTextField (); jt7.setColumns (10); JT7.SetBounds (129, 350, 150, 34); contentPane.add (JT7); Jradiobutton Radiobutton = new Jradiobutton ("masculin", vrai); radiobutton.setbounds (139, 121, 65, 23); ContentPane.Add (Radiobutton); Jradiobutton radiobutton_1 = new Jradiobutton ("femelle"); radiobutton_1.setbounds (221, 121, 121, 23); contentPane.add (radiobutton_1); Buttongroup BB = new Buttongroup (); BB.ADD (RADIOBUTTON); BB.ADD (RADIOBUTTON_1); JBUTTON JB1 = NEW JBUTTON ("ADD"); JB1.SETFONT (NOUVEAU FONT ("Zongyi", Font.Plain, 16)); JB1.SetBounds (Jb1); New Jbutton ("Close"); JB2.Setfont (New Font ("Zongyi", Font.plain, 16)); JB2.SetBounds (314, 167, 110, 61); ContentPane.Add (JB2); Jbutton JB3 = New Jbutton ("Clear"); JB3 16)); JB3.SetBounds (314, 265, 110, 61); contentPane.add (JB3); String str1 [] = {"Computer Science and Technology", "Information Security", "Electronic Information Science and Technology", "Network Engineering"}; JCombobox Combobox = New JComboBox (STR1); ; combobox.setbounds (126, 400, 155, 29); contenuPane.add (combobox); JB1.AddactionListener (new ActionListener () {public void ActionPerformed (ActionEvent Arg0) {personoperatordome PPP = new personoperatordome (); if (Ppp.SerachPersonBool (jt1.getText ())) {joptionpane.showMesseSageDialog (null, "this id exists, s'il vous plaît ne l'ajoutait pas"); PP = new Personne (); PP.SetSex (Sex); pp.setmajor (string.valueof (comboBox.getSelectedItem ()); JB3.AddactionListener (new ActionListener () {@Override public void ActionPerformed (ActionEvent Arg0) {// TODO Méthode générée automatiquement Stub JT1.SeTText (""); JT2.SETText (""); JT3.SeTText (""); JT6.SeTText (");" "" "" ""); "" ");" "" "" ""); "" ");" "" jt7.setText ("");}}); JB2.AddActionListener (new ActionListener () {@Override public void ActionPerformed (ActionEvent Arg0) {// TODO Méthode générée automatique Stub Dissose ();}}); }} / * Classe d'informations de personne * / classe publique Personne {ID de chaîne privée; nom de chaîne privé; Sexe à cordes privées; âge des cordes privées; anniversaire de cordes privées; téléphone de chaîne privé; e-mail de chaîne privée; adresse de chaîne privée; Major à cordes privées; public String getID () {return id; } public void setid (String id) {this.id = id; } public String getName () {Nom de retour; } public void setName (string name) {this.name = name; } public String getSEX () {return sexe; } public void setSex (String Sex) {this.sex = sexe; } public String Getage () {return Age; } public void Setage (String Age) {this.age = age; } public String getBirthday () {return anniversaire; } public void SetBirthday (anniversaire de chaîne) {this.birthday = anniversaire; } public String gephone () {return téléphone; } public void setphone (String Phone) {this.phone = téléphone; } public String getEmail () {return e-mail; } public void setEmail (chaîne e-mail) {this.email = e-mail; } public String getAddress () {return adresse; } public void setAddress (adresse de chaîne) {this.address = adresse; } public String getMajor () {return major; } public void setmajor (String Major) {this.major = major; }} / * Interface de fonctionnement de la personne * / import org.dom4j.document; interface publique personoperator {public void addPerson (personne personne); Public Void UpdateSerson (personne personne); public void Deleteperson (String ID); Public Serachperson (ID de chaîne); Boolean Serachpersonbool public (ID de chaîne); public void beifen (); public void huifu ();} import java.io.file; import java.io.fileoutputStream; import java.util.iterator; import java.util.list; import org.dom4j.document; import org.dom4j.documenthelper; import org.dom4j.element; import org.dom4j.ioTutformat; import org.dom4j.io.saxreader; org.dom4j.io.xmlwriter; classe publique PersonoperatorDome {public void addSerson (personne personne) {try {file file = new File ("e: /person.xml"); Document doc = null; Élément rootelem = null; if (! file.exists ()) {doc = documentHelper.CreateDocument (); rootElem = doc.addelement ("PersonList"); } else {doc = new saxReader (). read (fichier); rootElem = doc.getrootelement (); } Élément personElem = rootElem.addelement ("personne"); personElem.addattribute ("id", personne.getId ()); personElem.addelement ("name"). setText (personne.getName ()); personElem.Addelement ("Sex"). SetText (Person.getSex ()); personElem.Addelement ("Age"). SetText (Person.getage ()); personElem.Addelement ("anniversaire"). setText (Person.getBirthday ()); personElem.addelement ("téléphone"). setText (personne.getphone ()); personElem.addelement ("téléphone"). setText (personne.getphone ()); personElem.addelement ("téléphone"). setText (personne.getphone ()); personElem.Addelement ("e-mail"). setText (personne.getEmail ()); personElem.addelement ("adresse"). setText (personne.getAddress ()); personElem.Addelement ("Major"). SetText (Person.getMajor ()); Xml.writexml (doc); } catch (exception e) {e.printStackTrace (); }} public void updateSerson (personne personne) {document doc = xml.getDocument (); Élément root = doc.getrootelement (); Liste des personnes = root.Elements (); for (int i = 0; i <Persons.size (); i ++) {élément test = (élément) Persons.get (i); if (personne.getId (). equals (test.AttributeValue ("id"))) {for (iterator it = test.elementIterator (); it.hasnext ();) {element node = (élément) it.next (); String type = node.getName (); if ("name" .equals (type)) {node.setText (personne.getName ()); } if ("sex" .equals (type)) {node.setText (personne.getSEx ()); } if ("Age" .Equals (type)) {node.setText (personne.getage ()); } if ("anniversaire" .equals (type)) {node.setText (personne.getBirthday ()); } if ("phone" .equals (type)) {node.setText (personne.getphone ()); } if ("e-mail" .equals (type)) {node.setText (personne.getEmail ()); } if ("adresse" .equals (type)) {node.setText (personne.getAddress ()); } if ("major" .equals (type)) {node.setText (personne.getMajor ()); }}}} Xml.writexml (doc); } public void beifen () {document doc1 = xml.getDocument (); try {file file = new file ("e: /persondome.xml"); Document doc = null; Élément rootelem = null; if (! file.exists ()) {doc = documentHelper.CreateDocument (); rootElem = doc.addelement ("PersonList"); } else {doc = new saxReader (). read (fichier); rootElem = doc.getrootelement (); }} catch (exception e) {e.printStackTrace (); } essayez {// 3. Écrivez un document dans XML File FileOutputStream Out = new FileOutputStream ("E: /Persondome.xml"); // Format d'écriture (beau format) Format de sortie de sortie = OutputFormat.CreatePreTTyprint (); format.SetEncoding ("UTF-8"); Xmlwriter writer = new XMLWriter (out, format); écrivain.write (doc1); écrivain.close (); } catch (exception e) {e.printStackTrace (); lancer un nouveau runtimeException (); }} public void huifu () {document doc1 = xml.getDocument1 (); try {fileoutputStream out = new FileOutputStream ("e: /person.xml"); OutputFormat Format = outputFormat.CreatePreretTyprint (); format.SetEncoding ("UTF-8"); Xmlwriter writer = new XMLWriter (out, format); écrivain.write (doc1); écrivain.close (); } catch (exception e) {e.printStackTrace (); lancer un nouveau runtimeException (); }} public void Deleteperson (String id) {document doc = xml.getDocument (); Élément root = doc.getrootelement (); Liste des personnes = root.Elements (); for (int i = 0; i <Persons.size (); i ++) {élément test = (élément) Persons.get (i); if (id.equals (test.attributeValue ("id"))) {test.detach (); casser; }} Xml.writexml (doc); } public boolean SerachPersonbool (String id) {document doc = xml.getDocument (); Élément root = doc.getrootelement (); Liste des personnes = root.Elements (); Personne personne = new personne (); for (int i = 0; i <Persons.size (); i ++) {élément test = (élément) Persons.get (i); if (id.equals (test.attributeValue ("id"))) {return true; }} return false; } Personne publique SerachPerson (String id) {document doc = xml.getDocument (); Élément root = doc.getrootelement (); Liste des personnes = root.Elements (); Personne personne = new personne (); for (int i = 0; i <Persons.size (); i ++) {élément test = (élément) Persons.get (i); if (id.equals (test.attributeValue ("id"))) {for (iterator it = test.elementIterator (); it.hasnext ();) {element node = (élément) it.next (); String type = node.getName (); if ("name" .equals (type)) {personne.setName (node.getText ()); } if ("sex" .equals (type)) {personne.setSEx (node.getText ()); } if ("age" .equals (type)) {Person.Setage (node.getText ()); } if ("anniversaire" .equals (type)) {Person.setBirthday (node.getText ()); } if ("phone" .equals (type)) {Person.SetEmail (node.getText ()); } if ("phone" .equals (type)) {Person.SetEmail (node.getText ()); } if ("adresse" .equals (type)) {personne.setAddress (node.getText ()); } if ("major" .equals (type)) {personne.setmajor (node.getText ()); }}}} Personne de retour; }} / * Finir * / Importer java.awt.borderLayout; import java.awt.eventqueue; import javax.swing.buttongroup; importer javax.swing.jframe; import javax.swing.jpanel; java.awt.font; importer java.awt.event.actionEvent; import java.awt.event.actionListener; import javax.swing.jtextfield; import javax.swing.jradiobutton; import javax.swing.jbutton; import javax.swing.jcombox; la classe publique serathponse étend jaframe {privilégié jpanel; JTEXFIED JTET PRIVÉ; JTEXFIELD JTED JT2; JTEXFIED JTET PRIVÉ; JTEXFIED JTET privé; JTEXFIEL PRIVÉ JT5; JTEXFIELD JTED JT6; JTEXFIELD JTEND JT7; public Serachperson () {setDefaultCloseOperation (jframe.exit_on_close); Setbounds (100, 100, 450, 489); contentPane = new JPanel (); ContentPane.SetBorder (New videBorder (5, 5, 5, 5)); contentPane.SetLayout (null); setContentPane (contentPane); JLABEL JL1 = New JLabel ("Student Address Book"); jl1.setfont (New Font ("Songyi", Font.Plain, 16)); JL1.SetBounds (10, 0, 95, 29); contentPane.add (JL1); JLabel jl2 = new JLabel ("numéro d'étudiant"); JL2.Setfont (New Font ("Songyi", Font.Plain, 16)); JL2.SetBounds (51, 39, 65, 29); contentPane.add (jl2); JLabel jl3 = new JLabel ("Nom de l'étudiant"); JL3.Setfont (New Font ("Songyi", Font.Plain, 16)); JL3.SetBounds (51, 78, 65, 29); contentPane.add (JL3); JLabel JL4 = new JLabel ("Student Gender"); JL4.Setfont (New Font ("Songyi", Font.Plain, 16)); JL4.SetBounds (51, 117, 65, 29); contentPane.add (JL4); JLABEL JL5 = New JLabel ("Age étudiant"); JL5.Setfont (New Font ("Songyi", Font.Plain, 16)); JL5.SetBounds (51, 163, 65, 29); contentPane.add (JL5); JLABEL JL6 = New JLabel ("Date de naissance"); jl6.setfont (new Font ("宋体", font.plain, 16)); JL6.SetBounds (51, 202, 65, 29); contentPane.add (JL6); JLABEL JL7 = new JLABEL ("宋体"); jl7.setfont (new Font ("宋体", font.plain, 16)); JL7.SetBounds (51, 250, 65, 29); ContentPane.Add (JL7); JLabel jl8 = new JLabel ("e-mail"); jl8.setfont (nouvelle police ("zongyi", font.plain, 16)); JL8.SetBounds (51, 296, 65, 29); ContentPane.Add (JL8); JLABEL JL9 = new JLABEL ("Adresse personnelle"); JL9.Setfont (New Font ("Zongyi", Font.Plain, 16)); JL9.SetBounds (51, 345, 65, 29); contentPane.add (jl9); JLABEL JL9 = new JLABEL ("Adresse personnelle"); JL9.Setfont (New Font ("Zongyi", Font.Plain, 16)); JL9.SetBounds (51, 345, 65, 29); contentPane.add (jl9); JLABEL JL10 = new JLABEL ("Nom professionnel"); jl10.setfont (new Font ("宋体", font.plain, 16)); JL10.SetBounds (51, 389, 65, 29); contentPane.add (JL10); jt1 = new JTextField (); JT1.SetBounds (129, 38, 150, 34); contentPane.add (JT1); jt1.setColumns (10); jt2 = new JTextField (); JT2.SetColumns (10); JT2.SetBounds (129, 83, 150, 34); contentPane.add (jt2); jt3 = new JTextField (); jt3.setColumns (10); JT3.SetBounds (129, 163, 150, 34); contentPane.add (JT3); jt4 = new JTextField (); JT4.SetColumns (10); JT4.SetBounds (129, 201, 150, 34); contentPane.add (JT4); jt5 = new JTextField (); JT5.SetColumns (10); JT5.SetBounds (129, 250, 150, 34); contentPane.add (JT5); jt6 = new JTextField (); jt6.setColumns (10); JT6.SetBounds (129, 301, 150, 34); contentPane.add (JT6); jt7 = new JTextField (); jt7.setColumns (10); JT7.SetBounds (129, 350, 150, 34); contentPane.add (JT7); Jradiobutton Radiobutton = new Jradiobutton ("masculin", vrai); radiobutton.setbounds (139, 121, 65, 23); ContentPane.Add (Radiobutton); Jradiobutton radiobutton_1 = new Jradiobutton ("femelle"); RadioButton_1.setBounds (221, 121, 79, 23); contentPane.add (radiobutton_1); Buttongroup BB = new Buttongroup (); bb.add (radiobutton); bb.add (radiobutton_1); jbutton jb1 = new Jbutton ("find"); jb1.setfont (nouvelle police ("宋体", font.plain, 16)); jb1.setbounds (314, 78, 110, 61); contenu. JBUTTON ("宋体"); jb2.setfont (new Font ("宋体", font.plain, 16)); jb2.setBounds (314, 280, 110, 61); contentPane.add (jb2); jbutton jb3 = new JBUTTON ("Clear"); jb3.setfont (New Font ("" "chengyi", font. 16)); JB3.SetBounds (314, 357, 110, 61); contentPane.add (JB3); Jbutton JB4 = new JButton ("Modify"); JB4.Setfont (New Font ("Chengyi", Font. Plain, 16)); JB4.SetBounds (314, 174, 110, 110, 61); contentPane.add (JB4); String Str1 [] = {"Computer Science and Technology", "Information Security", "Electronic Information Science and Technology", "Network Engineering"}; JCombobox ComboBox = New Jcombobox (STR1); ComboBox.SetBounds (126, 394, 153, 29); ContentPane.Addd (combobox); jb1.addactionListener (new ActionListener () {public void ActionPerformed (ActionEvent arg0) {personoperatordome personne = new personoperArordome (); string id = jt1.getText (); personne pp = personne.serachPerson (id); jt2.settext (pp.getName ()); if (radiobutton.getText (). JT6.setText (pp.getEmail ()); if (pp.getmajor (). JB3.AddactionListener (new ActionListener () {@Override public void ActionPerformed (ActionEvent e) {// TODO Méthode générée automatiquement Stub jt1.seTText (""); JT2.SeTText (""); JT3.SeTText (""); JT4.SeTTEXT ("); JT5.SETTEXT (" "); JT6.SeTText ("); jt7.setText ("");}}); JB2.AddActionListener (new ActionListener () {@Override public void ActionPerformed (ActionEvent Arg0) {// TODO Méthode générée automatique Stub Dissose ();}}); JB4.AddactionListener (new ActionListener () {public void ActionPerformed (ActionEvent Arg0) {personne pp = new personne (); personAratordome personne = new personoperatordome (); String Sex; if (radiobutton.isselected ()) {sexe = radiobutton.gettex pp.setId (jt1.getText (); PP.SetAddress (jt7.getText ()); }} import java.io.file; import java.io.fileoutputStream; import org.dom4j.document; import org.dom4j.io.outputformat; import org.dom4j.io.saxreader; import org.dom4j.io.xmlwriter; public class xml {public static document getDocument () {try {Document Doc SaxReader (). Read (nouveau fichier ("e: /person.xml")); retour doc; } catch (exception e) {e.printStackTrace (); Jetez une nouvelle RuntimeException (E); }} document statique public getDocument1 () {try {document doc = new saxReader (). read (nouveau fichier ("e: /persondome.xml")); retour doc; } catch (exception e) {e.printStackTrace (); Jetez une nouvelle RuntimeException (E); }} / * * Écrivez le fichier XML * / public static void writexml (document doc) {try {// 3. Écrivez un document dans le fichier XML FileOutputStream out = new FileOutputStream ("e: /person.xml"); // Format d'écriture (beau format) Format de sortie de sortie = OutputFormat.CreatePreTTyprint (); format.SetEncoding ("UTF-8"); Xmlwriter writer = new XMLWriter (out, format); écrivain.write (doc); écrivain.close (); } catch (exception e) {e.printStackTrace (); lancer un nouveau runtimeException (); }}} import java.awt.borderlayout; import java.awt.eventqueue; import javax.swing.jframe; import javax.swing.jpanel; import javax.swing.border.emptyborder; import javax.swing.buttongroup; import javax.swing.jbutton; import java.awt.font; java.awt.event.actionEvent; import java.awt.event.actionListener; import java.util.list; import javax.swing.jtextarea; import javax.swing.jscrollbar; import javax.swing.jscrollpane; import javax.swing.jlist; import javax.swing.joptionpane; javax.swing.jradiobutton; import javax.swing.jtable; import javax.swing.table.defaulttableModel; import org.dom4j.document; import org.dom4j.element; classe publique MainContral étend Jframe {privé jpanel contenu; table JTable privée; public MainContral () {setDefaultCloseOperation (jframe.exit_on_close); Setbounds (100, 100, 1200, 392); contentPane = new JPanel (); contentPane.SetLayout (null); setContentPane (contentPane); Jbutton jb1 = new JButton ("add"); JB1.Setfont (New Font ("Zongyi", Font.Plain, 16)); JB1.SetBounds (23, 10, 101, 48); contentPane.add (JB1); JBUTTON JB3 = new JBUTTON ("Delete"); jb3.setfont (new Font ("宋体", font.plain, 16)); JB3.SetBounds (134, 10, 101, 48); contentPane.add (JB3); JBUTTON JB4 = NOUVEAU JBUTTON ("/ U67E5 / U627E / U4E0E / U4FEE / U6539"); JB4.SetFont (nouveau Font ("宋体", font.plaain, 16)); JB4.SetBounds (245, 10, 139, 48); contentPane.add (JB4); JBUTTON JB5 = new JBUTTON ("Show All"); JB5.Setfont (New Font ("Songyi", Font.Plain, 16)); JB5.SetBounds (394, 10, 126, 48); ContentPane.Add (JB5); Jradiobutton Radiobutton = New Jradiobutton ("Informatique et technologie"); Radiobutton.setfont (New Font ("Songyi", Font.Plain, 16)); Radiobutton.setbounds (23, 89, 161, 23); ContentPane.Add (Radiobutton); Jradiobutton radiobutton_1 = new Jradiobutton ("sécurité de l'information"); radiobutton_1.setfont (new Font ("zongyi", font.plain, 16)); RadioButton_1.setBounds (186, 89, 101, 23); contentPane.add (radiobutton_1); Jradiobutton Radiobutton_2 = New Jradiobutton ("Electronic Information Science and Technology"); RadioButton_2.Setfont (New Font ("Zongyi", Font.Plain, 16)); RADIOBUTTON_2.SetBounds (289, 89, 174, 23); contentPane.add (radioobutton_2); Jradiobutton radiobutton_3 = new Jradiobutton ("Engineering réseau"); RadioButton_3.Setfont (New Font ("Zongyi", Font.Plain, 16)); RadioButton_3.SetBounds (465, 89, 101, 23); contentPane.add (radiobutton_3); Jradiobutton radiobutton_4 = new Jradiobutton ("all"); radiobutton_4.setfont (new Font ("宋体", font.plain, 16)); RadioButton_4.SetBounds (568, 89, 121, 23); contentPane.add (radiobutton_4); Buttongroup BB = new Buttongroup (); BB.Add (Radiobutton); bb.add (radiobutton_3); bb.add (radiobutton_2); bb.add (radiobutton_1); bb.add (radiobutton_4); table = new JTable (); table.setfont (new Font ("宋体", font.plaain, 16)); Table "/ u7535 / u8bdd", "/ u90ae / u7bb1", "/ u5730 / u5740", "/ u4e13 / u4e1a"})); DefaultTableModel modèle = (defaultTableModel) table.getModel (); Objet [] rowdata = {"numéro", "nom", "genre", "âge", "anniversaire", "téléphone", "e-mail", "addrow (rowdata); // jscrollpane scroll = new JscrollPane (table); table.setbounds (23, 131, 1100, 212); contenu.Addd (table); jbutton jb6 = nouveau JBUTTON (BACKUP "); JB7.SetBounds (641, 10, 101, 48); Joptionpane.showMessageDialog (null, "Backup Success");}}); Joptionpane.showMessageDialog (null, "Success");}}); ActionListener () {@Override public void ActionPerformed (ActionEvent e) {// TODO Méthode générée automatique "Supprimer avec succès");}}); ActionPerformed (ActionEvent Arg0) {// TODO Méthode générée par Auto While (Model.getRowCount ()> 1) {Model.ReMoverow (Model.getRowCount () - 1); Person1.SetName (test.ElementText (nom "); Person1.SetBirthday (test.ElementText ("anniversaire"); Person1.getphone (), Person1.getEmail (), Person1.getAddress (), Person1.getMajor (); Méthode générée automatiquement document Doc = xml.getDocument (); Model.ReMoverow (Model.GetRowCount () - 1);} pour (int i = 0; i <Persons.Size (); i ++) {élément test = (élément) Persons.get (i); Person1.SetName (test.ElementText (nom "); Person1.SetAddress (Test.ElementText (adresse "); {Person1.getId (), Person1.getName (), Person1.getSex (), Person1.getage (), Person1.getBirthday (), Person1.getphone (), Person1.getEmail (), Person1.getAddress (), Person1.getmajor ()}; radiobutton_1.addactionListener (new ActionListener () {@Override public void ActionPerformed (actionevent arg0) {// todo meto-généré par le document de stub doc = xml.getDocument (); élément root = doc.getrootellement (); list Persons = root.elements (); string str = radiobutton_1.getText (); Person1 =); DefaultTableModel modèle = (defaultTableModel) Tableau.GetModel (); if (str.equals (test.Element ("Major"). GetText ())) {Person1.SetId (test.attributeValue ("id"); Person1.setphone (test.ElementText (téléphone ")); Objet [] rowData = {personne1.getId (), personne1.getName (), personne1.getSEx (), personne1.getage (), personne1.getBirtday (), Person1.getphone (), Person1.getEmail (), Person1.getAddress (), Person1.getMajor (); radiobutton_2.addactionListener (new ActionListener () {@Override public void ActionPerformed (actionevent arg0) {// todo meto-généré par le document de stub doc = xml.getDocument (); élément root = doc.getRootelement (); list Persons = root.elements (); string str = radiobutton_2.get DefaultTableModel modèle = (defaultTableModel) Tableau.GetModel (); if (str.equals (test.Element ("Major"). GetText ())) {Person1.SetId (test.attributeValue ("id"); Person1.Setphone (test.ElementText ("téléphone"); Objet [] rowData = {personne1.getId (), personne1.getName (), personne1.getSEx (), personne1.getage (), personne1.getBirtday (), Person1.getphone (), Person1.getEmail (), Person1.getAddress (), Person1.getMajor (); radiobutton_3.AddactionListener (new ActionListener () {@Override public void ActionPerformed (ActionEvent arg0) {// todo meto-généré par le document de stub doc = xml.getDocument (); élément root = doc.getRootelement (); list Persons = root.elements (); string sttr = radiobutton_3.get (); person1 = newelements;); DefaultTableModel modèle = (defaultTableModel) Tableau.GetModel (); if (str.equals (test.Element ("Major"). GetText ())) {Person1.SetId (test.attributeValue ("id"); Person1.Setage (Test.ElementText ("Age")); Objet [] rowData = {personne1.getId (), personne1.getName (), personne1.getSEx (), personne1.getage (), Person1.getBirtday (), Person1.getphone () public static void main (String [] args) {MainContral Test1 = new MainContral ();Ce qui précède est tout le contenu de cet article. J'espère que cela sera utile à l'apprentissage de tous et j'espère que tout le monde soutiendra davantage Wulin.com.