1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
|
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package xxx.projet;
import java.io.File;
import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
/**
*
* @author xxxx.xxxx
*/
public class BuildHotel extends javax.swing.JFrame {
private static final File f = new File(".");
/**
* Creates new form BuildHotel
*/
public BuildHotel() {
initComponents();
}
/**
* Chargement des informations concernant l'hôtel si elles existent
* @throws javax.xml.parsers.ParserConfigurationException
* @throws java.io.IOException
* @throws org.xml.sax.SAXException */
public static void LoadData() throws SAXException, IOException, ParserConfigurationException{
org.w3c.dom.Document document;
String xmlDoc = f.getAbsolutePath().substring(0, f.getAbsolutePath().length() - 1) + "hoteldata.xml";
javax.xml.parsers.DocumentBuilderFactory builderFactory = javax.xml.parsers.DocumentBuilderFactory.newInstance();
javax.xml.parsers.DocumentBuilder builder = builderFactory.newDocumentBuilder();
document = builder.parse(new org.xml.sax.InputSource(xmlDoc));
HoteldataScanner scanner = new HoteldataScanner(document);
scanner.visitDocument();
jTFNom.setText(scanner.name);
}
/**
* This method 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.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jPanelHotel = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jTFNom = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
setTitle("xxxx- xxxx");
setMaximumSize(new java.awt.Dimension(0, 0));
jPanelHotel.setBorder(javax.swing.BorderFactory.createTitledBorder("Information sur l'hôtel"));
javax.swing.GroupLayout jPanelHotelLayout = new javax.swing.GroupLayout(jPanelHotel);
jPanelHotel.setLayout(jPanelHotelLayout);
jPanelHotelLayout.setHorizontalGroup(
jPanelHotelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelHotelLayout.createSequentialGroup()
.addGroup(jPanelHotelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanelHotelLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addGroup(jPanelHotelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel7)
.addComponent(jLabel5)))
.addGroup(jPanelHotelLayout.createSequentialGroup()
.addGroup(jPanelHotelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelHotelLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(jPanelHotelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addGroup(jPanelHotelLayout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jLabel4))))
.addGroup(jPanelHotelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel3))
.addGroup(jPanelHotelLayout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanelHotelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel8)
.addComponent(jLabel9))))
.addGap(0, 11, Short.MAX_VALUE)))
.addGroup(jPanelHotelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(jPanelHotelLayout.createSequentialGroup()
.addComponent(jTFCP, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTFVille, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jTFClasse, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTFEmail)
.addComponent(jTFNom)
.addComponent(jTFTel)
.addGroup(jPanelHotelLayout.createSequentialGroup()
.addComponent(jTFNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jTFAdresse, javax.swing.GroupLayout.PREFERRED_SIZE, 194, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jTFWeb))
.addGap(26, 26, 26))
);
pack();
}// </editor-fold>
/** FERME LE FORMULAIRE */
private void jBFermerActionPerformed(java.awt.event.ActionEvent evt) {
this.dispose();
}
/**
* @param args the command line arguments
* @throws javax.xml.parsers.ParserConfigurationException
* @throws java.io.IOException
* @throws org.xml.sax.SAXException
*/
public static void main(String args[]) throws ParserConfigurationException, IOException, SAXException {
/** CHARGE LES DONNEES DU FORMULAIRE */
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(BuildHotel.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
/* CREE ET AFFICHE LE FORMULAIRE */
java.awt.EventQueue.invokeLater(() -> {
new BuildHotel().setVisible(true);
});
LoadData();
}
// Variables declaration - do not modify
static javax.swing.JTextField jTFNom;
// End of variables declaration
} |