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 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
|
package jForm;
//import javax.swing.JFileChooser;
import java.io.*;
import javax.swing.*;
/**
*
* @author alexandre
*/
public class jMainForm extends javax.swing.JFrame {
/*
* Fonction utilisable dans tous le programme
*/
//Fonction qui retourne le path du fichier de configuration
public static String pathConf() {
//Retourne le répertoire où sera situer le fichier de configuration
return System.getProperty("user.dir") + "/Rpg-Master/conf.properties";
}
//Fonction qui retourne le nom de l'applcation
public static String titleAppli() {
//Retourne le nom du programme
return "RPG Master";
}
/** Creates new form jMainForm */
public jMainForm() {
initComponents();
initForm();
}
/** 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() {
jToolBar1 = new javax.swing.JToolBar();
jButton1 = new javax.swing.JButton();
jButton2 = new javax.swing.JButton();
jSeparator1 = new javax.swing.JToolBar.Separator();
jButton3 = new javax.swing.JButton();
jSplitPane1 = new javax.swing.JSplitPane();
jPanel1 = new javax.swing.JPanel();
jScrollPane1 = new javax.swing.JScrollPane();
jTree1 = new javax.swing.JTree();
jTabbedPane1 = new javax.swing.JTabbedPane();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenu4 = new javax.swing.JMenu();
jMenuItem2 = new javax.swing.JMenuItem();
jMenu3 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jSeparator2 = new javax.swing.JPopupMenu.Separator();
jMenuItem3 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMenuItem4 = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jToolBar1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jToolBar1.setFloatable(false);
jToolBar1.setRollover(true);
jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icone 16x16/img_029.jpg"))); // NOI18N
jButton1.setToolTipText("Nouveau dossier Rpg");
jButton1.setFocusable(false);
jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jToolBar1.add(jButton1);
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icone 16x16/img_007.png"))); // NOI18N
jButton2.setToolTipText("Ouvrir un dossier Rpg");
jButton2.setFocusable(false);
jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jToolBar1.add(jButton2);
jSeparator1.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
jToolBar1.add(jSeparator1);
jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icone 16x16/img_003.png"))); // NOI18N
jButton3.setToolTipText("Nouvelle carte");
jButton3.setFocusable(false);
jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jToolBar1.add(jButton3);
jSplitPane1.setDividerLocation(200);
javax.swing.tree.DefaultMutableTreeNode treeNode1 = new javax.swing.tree.DefaultMutableTreeNode("Rpg");
jTree1.setModel(new javax.swing.tree.DefaultTreeModel(treeNode1));
jScrollPane1.setViewportView(jTree1);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 200, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 207, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(219, Short.MAX_VALUE))
);
jSplitPane1.setLeftComponent(jPanel1);
jSplitPane1.setRightComponent(jTabbedPane1);
jMenuBar1.setBorder(new javax.swing.border.SoftBevelBorder(javax.swing.border.BevelBorder.RAISED));
jMenu1.setText("Fichier");
jMenu1.setToolTipText("Fichier");
jMenu4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icone 16x16/img_011.png"))); // NOI18N
jMenu4.setText("Créer");
jMenu4.setToolTipText("Créer");
jMenuItem2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icone 16x16/img_002.png"))); // NOI18N
jMenuItem2.setText("Dossier Rpg");
jMenuItem2.setToolTipText("Créer un dossier Rpg");
jMenuItem2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenuItem2ActionPerformed(evt);
}
});
jMenu4.add(jMenuItem2);
jMenu1.add(jMenu4);
jMenu3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icone 16x16/img_007.png"))); // NOI18N
jMenu3.setText("Importer");
jMenu3.setToolTipText("Importer");
jMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icone 16x16/img_016.png"))); // NOI18N
jMenuItem1.setText("Dossier Rpg");
jMenuItem1.setToolTipText("Ouvrir un dossier Rpg");
jMenu3.add(jMenuItem1);
jMenu1.add(jMenu3);
jMenu1.add(jSeparator2);
jMenuItem3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icone 16x16/img_006.png"))); // NOI18N
jMenuItem3.setText("Enregistrer");
jMenuItem3.setToolTipText("Enregistrer le travail en cours");
jMenu1.add(jMenuItem3);
jMenuBar1.add(jMenu1);
jMenu2.setText("Gestion Rpg");
jMenu2.setToolTipText("Gestion d'un RPG");
jMenuItem4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Icone 16x16/img_003.png"))); // NOI18N
jMenuItem4.setText("Nouvelle carte");
jMenuItem4.setToolTipText("Nouvelle carte");
jMenu2.add(jMenuItem4);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 709, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 685, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(12, 12, 12)
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 426, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>
private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {
/*
* Bouton du menu Fichier -> Créer -> Dossier Rpg
*/
//******** /!\ /!\ /!\ /!\ ICI C'EST LA OU RIEN NE FONCTIONNE /!\ /!\ /!\ /!\ ********
//Ouvre le jFileChooser.
//Si le bouton enregistrer est appuyer, au retour on prends la valeur
//Et on affiche ce qui est dans le répertoire dans le jTree.
//Pour aller chercher la valeur, j'ai mis au point une fonction
//jFileSelect() qui retourne un File().
//System.out.println(jFileSelect());
}
//Initialisation des carractéristiques de la form
private void initForm() {
//Change l'icône de l'application
String pathIcon = "../Icone 32x32/img_01.png";
this.setIconImage(java.awt.Toolkit.getDefaultToolkit().getImage(getClass().getResource(pathIcon)));
//Change le titre de l'application
this.setTitle(titleAppli());
}
/*
* Les autres fontions
*/
public static File jFileSelect() {
//Crée une instance File()
File pathSelect = new File("null");
//Instancie un JFileChooser()
final JFileChooser choix = new JFileChooser();
//Applique des options
choix.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
choix.setMultiSelectionEnabled(false);
//Instancie une action manuelle
final int action = choix.showSaveDialog(null);
//Si le bouton enregistrer est cliqué
if(action == JFileChooser.APPROVE_OPTION) {
//Enregistre le chemin dans un objet File()
pathSelect = choix.getSelectedFile();
}
//Retourne le chemin sélectionné
return pathSelect;
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new jMainForm().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton3;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenu jMenu4;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuItem jMenuItem1;
private javax.swing.JMenuItem jMenuItem2;
private javax.swing.JMenuItem jMenuItem3;
private javax.swing.JMenuItem jMenuItem4;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JToolBar.Separator jSeparator1;
private javax.swing.JPopupMenu.Separator jSeparator2;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JToolBar jToolBar1;
private javax.swing.JTree jTree1;
// End of variables declaration
} |
Partager