menu jeu fini

Début du menu : ??
This commit is contained in:
emile.malcuit 2025-02-12 17:28:36 +01:00
parent 2dea86f195
commit 2e6e772c8b
5 changed files with 772 additions and 31 deletions

View File

@ -0,0 +1,297 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<NonVisualComponents>
<Menu class="javax.swing.JMenuBar" name="jMenuBar1">
<SubComponents>
<Menu class="javax.swing.JMenu" name="jMenuJeu">
<Properties>
<Property name="text" type="java.lang.String" value="Jeu"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMInewGame">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+N"/>
</Property>
<Property name="text" type="java.lang.String" value="New Game"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMInewGameActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMInewPlayer">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="ADD"/>
</Property>
<Property name="text" type="java.lang.String" value="New Player"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMInewPlayerActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMIopenGame">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+O"/>
</Property>
<Property name="text" type="java.lang.String" value="Open Game"/>
</Properties>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMIsave">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+S"/>
</Property>
<Property name="text" type="java.lang.String" value="Save"/>
</Properties>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMIquit">
<Properties>
<Property name="accelerator" type="javax.swing.KeyStroke" editor="org.netbeans.modules.form.editors.KeyStrokeEditor">
<KeyStroke key="Ctrl+Q"/>
</Property>
<Property name="text" type="java.lang.String" value="Exit"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMIquitActionPerformed"/>
</Events>
</MenuItem>
</SubComponents>
</Menu>
<Menu class="javax.swing.JMenu" name="jMenu2">
<Properties>
<Property name="text" type="java.lang.String" value="Edit"/>
</Properties>
</Menu>
</SubComponents>
</Menu>
</NonVisualComponents>
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel1">
<Properties>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="66" type="rgb"/>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="36" max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" pref="40" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="17" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jTFnomPerso" alignment="0" min="-2" pref="86" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jCBoximagePerso" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jCBoxChoixType" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="57" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jSptsEnergie" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jSptsVie" min="-2" max="-2" attributes="0"/>
<Component id="jLabel6" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jTFarme" alignment="0" min="-2" pref="113" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="37" max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="100" max="-2" attributes="0"/>
<Component id="jLnewPlayer" min="-2" pref="114" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="93" max="-2" attributes="0"/>
<Component id="jBcreer" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="47" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
<Component id="jLnewPlayer" min="-2" pref="16" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jCBoxChoixType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jTFarme" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="23" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jTFnomPerso" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jSptsVie" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="5" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jCBoximagePerso" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jSptsEnergie" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jBcreer" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="25" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLnewPlayer">
<Properties>
<Property name="text" type="java.lang.String" value="New Player"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="jCBoxChoixType">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jCBoxChoixTypeActionPerformed"/>
</Events>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JTextField" name="jTFnomPerso">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jTFnomPersoActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Type"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Nom"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="jCBoximagePerso">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
<AuxValues>
<AuxValue name="JavaCodeGenerator_TypeParameters" type="java.lang.String" value="&lt;String&gt;"/>
</AuxValues>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="Image"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="jSptsVie">
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="text" type="java.lang.String" value="poits de vie"/>
</Properties>
<Events>
<EventHandler event="componentAdded" listener="java.awt.event.ContainerListener" parameters="java.awt.event.ContainerEvent" handler="jLabel4ComponentAdded"/>
</Events>
</Component>
<Component class="javax.swing.JSpinner" name="jSptsEnergie">
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="text" type="java.lang.String" value="poits d&apos;&#xe9;nergie"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="text" type="java.lang.String" value="Arme"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="jTFarme">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jTFarmeActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="jBcreer">
<Properties>
<Property name="text" type="java.lang.String" value="create"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jBcreerActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View File

@ -0,0 +1,382 @@
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template
*/
package Presentation;
import java.util.Vector;
import javax.swing.DefaultComboBoxModel;
import metier.Guerrier;
import metier.Jeu;
/**
*
* @author emile.lalorcey
*/
public class Ajout_Perso extends javax.swing.JFrame {
Jeu leJeu;
/**
* Creates new form Ajout_Perso
*/
public Ajout_Perso(Jeu jeu) {
initComponents();
jCBoxChoixType.setModel(new DefaultComboBoxModel(typePerso ()));
jCBoximagePerso.setModel(new DefaultComboBoxModel(imagePerso()));
leJeu = jeu;
}
/**
* 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">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLnewPlayer = new javax.swing.JLabel();
jCBoxChoixType = new javax.swing.JComboBox<>();
jTFnomPerso = new javax.swing.JTextField();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jCBoximagePerso = new javax.swing.JComboBox<>();
jLabel3 = new javax.swing.JLabel();
jSptsVie = new javax.swing.JSpinner();
jLabel4 = new javax.swing.JLabel();
jSptsEnergie = new javax.swing.JSpinner();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jTFarme = new javax.swing.JTextField();
jBcreer = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenuJeu = new javax.swing.JMenu();
jMInewGame = new javax.swing.JMenuItem();
jMInewPlayer = new javax.swing.JMenuItem();
jMIopenGame = new javax.swing.JMenuItem();
jMIsave = new javax.swing.JMenuItem();
jMIquit = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBackground(new java.awt.Color(102, 0, 0));
jLnewPlayer.setText("New Player");
jCBoxChoixType.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jCBoxChoixType.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCBoxChoixTypeActionPerformed(evt);
}
});
jTFnomPerso.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTFnomPersoActionPerformed(evt);
}
});
jLabel1.setText("Type");
jLabel2.setText("Nom");
jCBoximagePerso.setModel(new javax.swing.DefaultComboBoxModel<>(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jLabel3.setText("Image");
jLabel4.setText("poits de vie");
jLabel4.addContainerListener(new java.awt.event.ContainerAdapter() {
public void componentAdded(java.awt.event.ContainerEvent evt) {
jLabel4ComponentAdded(evt);
}
});
jLabel5.setText("poits d'énergie");
jLabel6.setText("Arme");
jTFarme.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jTFarmeActionPerformed(evt);
}
});
jBcreer.setText("create");
jBcreer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jBcreerActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(36, 36, 36)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(17, 17, 17)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTFnomPerso, javax.swing.GroupLayout.PREFERRED_SIZE, 86, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(20, 20, 20)
.addComponent(jLabel2))
.addComponent(jCBoximagePerso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jCBoxChoixType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(57, 57, 57)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSptsEnergie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel4)
.addComponent(jLabel5)
.addComponent(jSptsVie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6)
.addComponent(jTFarme, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(jLabel3))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(100, 100, 100)
.addComponent(jLnewPlayer, javax.swing.GroupLayout.PREFERRED_SIZE, 114, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(93, 93, 93)
.addComponent(jBcreer)))
.addContainerGap(47, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(25, 25, 25)
.addComponent(jLnewPlayer, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jCBoxChoixType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jTFarme, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(23, 23, 23)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jLabel4))
.addGap(12, 12, 12)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jTFnomPerso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSptsVie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jLabel5))
.addGap(5, 5, 5)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jCBoximagePerso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jSptsEnergie, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jBcreer)
.addContainerGap(25, Short.MAX_VALUE))
);
jMenuJeu.setText("Jeu");
jMInewGame.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_DOWN_MASK));
jMInewGame.setText("New Game");
jMInewGame.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMInewGameActionPerformed(evt);
}
});
jMenuJeu.add(jMInewGame);
jMInewPlayer.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ADD, 0));
jMInewPlayer.setText("New Player");
jMInewPlayer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMInewPlayerActionPerformed(evt);
}
});
jMenuJeu.add(jMInewPlayer);
jMIopenGame.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_DOWN_MASK));
jMIopenGame.setText("Open Game");
jMenuJeu.add(jMIopenGame);
jMIsave.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_DOWN_MASK));
jMIsave.setText("Save");
jMenuJeu.add(jMIsave);
jMIquit.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Q, java.awt.event.InputEvent.CTRL_DOWN_MASK));
jMIquit.setText("Exit");
jMIquit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMIquitActionPerformed(evt);
}
});
jMenuJeu.add(jMIquit);
jMenuBar1.add(jMenuJeu);
jMenu2.setText("Edit");
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(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jMInewGameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMInewGameActionPerformed
Plateau_de_jeu bidul = new Plateau_de_jeu();
}//GEN-LAST:event_jMInewGameActionPerformed
private void jMInewPlayerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMInewPlayerActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jMInewPlayerActionPerformed
private void jMIquitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMIquitActionPerformed
System.exit(0);
}//GEN-LAST:event_jMIquitActionPerformed
private void jCBoxChoixTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCBoxChoixTypeActionPerformed
}//GEN-LAST:event_jCBoxChoixTypeActionPerformed
private void jTFnomPersoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTFnomPersoActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTFnomPersoActionPerformed
private void jLabel4ComponentAdded(java.awt.event.ContainerEvent evt) {//GEN-FIRST:event_jLabel4ComponentAdded
// TODO add your handling code here:
}//GEN-LAST:event_jLabel4ComponentAdded
private void jTFarmeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTFarmeActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jTFarmeActionPerformed
private void jBcreerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBcreerActionPerformed
switch(jCBoxChoixType.getSelectedItem().toString()){
case "Guerrier":
leJeu.getmesPersonnages().add(new Guerrier(jTFnomPerso.getText(),
("/img/"+jCBoximagePerso.toString()),
(Integer) jSptsEnergie.getValue(),
(Integer) jSptsVie.getValue(),
jTFarme.getText()));
break;
case "Sorcier":
leJeu.getmesPersonnages().add(new Guerrier(jTFnomPerso.getText(),
("/img/"+jCBoximagePerso.toString()),
(Integer) jSptsEnergie.getValue(),
(Integer) jSptsVie.getValue(),
jTFarme.getText()));
break;
case "Voleur":
leJeu.getmesPersonnages().add(new Guerrier(jTFnomPerso.getText(),
("/img/"+jCBoximagePerso.toString()),
(Integer) jSptsEnergie.getValue(),
(Integer) jSptsVie.getValue(),
jTFarme.getText()));
break;
}
System.out.println(leJeu);
}//GEN-LAST:event_jBcreerActionPerformed
//---------Initialisation Combo Box
private Vector<String> typePerso (){
Vector<String> type = new Vector<>();
type.add("Guerrier");
type.add("Sorcier");
type.add("Voleur");
return type;
}
private Vector<String> imagePerso(){
Vector<String> image = new Vector<>();
image.add("Barbare04.jpg");
image.add("Guerrier05.jpg");
image.add("Guerrier08.jpg");
image.add("Guerrier10.jpg");
image.add("Guerrier12.jpg");
image.add("Simone.jpg");
image.add("Sorcier02.jpg");
image.add("Sorciere1.jpg");
return image;
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* 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 ex) {
java.util.logging.Logger.getLogger(Ajout_Perso.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Ajout_Perso.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Ajout_Perso.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Ajout_Perso.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
Jeu leJeu = new Jeu();
new Ajout_Perso(leJeu).setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jBcreer;
private javax.swing.JComboBox<String> jCBoxChoixType;
private javax.swing.JComboBox<String> jCBoximagePerso;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLnewPlayer;
private javax.swing.JMenuItem jMInewGame;
private javax.swing.JMenuItem jMInewPlayer;
private javax.swing.JMenuItem jMIopenGame;
private javax.swing.JMenuItem jMIquit;
private javax.swing.JMenuItem jMIsave;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenu jMenuJeu;
private javax.swing.JPanel jPanel1;
private javax.swing.JSpinner jSptsEnergie;
private javax.swing.JSpinner jSptsVie;
private javax.swing.JTextField jTFarme;
private javax.swing.JTextField jTFnomPerso;
// End of variables declaration//GEN-END:variables
}

View File

@ -62,8 +62,28 @@
</Menu>
<Menu class="javax.swing.JMenu" name="jMenu2">
<Properties>
<Property name="text" type="java.lang.String" value="Edit"/>
<Property name="text" type="java.lang.String" value="??"/>
</Properties>
<SubComponents>
<MenuItem class="javax.swing.JMenuItem" name="jMIaide">
<Properties>
<Property name="text" type="java.lang.String" value="Aide"/>
</Properties>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMIobjectif">
<Properties>
<Property name="text" type="java.lang.String" value="Objectif"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMIobjectifActionPerformed"/>
</Events>
</MenuItem>
<MenuItem class="javax.swing.JMenuItem" name="jMIapropos">
<Properties>
<Property name="text" type="java.lang.String" value="A propos"/>
</Properties>
</MenuItem>
</SubComponents>
</Menu>
</SubComponents>
</Menu>
@ -252,16 +272,16 @@
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Component id="jLChoixPersoText" min="-2" pref="134" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="jPCHoixPersoFond" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
<Component id="jLChoixPersoText" min="-2" pref="250" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
@ -279,6 +299,9 @@
<SubComponents>
<Component class="javax.swing.JLabel" name="jLChoixPersoText">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Wide Latin" size="12" style="2"/>
</Property>
<Property name="text" type="java.lang.String" value="Choix Des personnages"/>
</Properties>
</Component>
@ -420,6 +443,9 @@
<Color blue="0" green="0" red="66" type="rgb"/>
</Property>
<Property name="columns" type="int" value="20"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Showcard Gothic" size="12" style="2"/>
</Property>
<Property name="rows" type="int" value="5"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Text Cursor"/>
@ -484,6 +510,9 @@
<Color blue="0" green="0" red="66" type="rgb"/>
</Property>
<Property name="columns" type="int" value="20"/>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Showcard Gothic" size="12" style="2"/>
</Property>
<Property name="rows" type="int" value="5"/>
</Properties>
</Component>

View File

@ -65,6 +65,9 @@ public class Plateau_de_jeu extends javax.swing.JFrame {
jMIsave = new javax.swing.JMenuItem();
jMIquit = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
jMIaide = new javax.swing.JMenuItem();
jMIobjectif = new javax.swing.JMenuItem();
jMIapropos = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
@ -87,6 +90,7 @@ public class Plateau_de_jeu extends javax.swing.JFrame {
jLChoixPerso.setIcon(new javax.swing.ImageIcon(getClass().getResource("/img/famille_1.jpg"))); // NOI18N
jLChoixPersoText.setFont(new java.awt.Font("Wide Latin", 2, 12)); // NOI18N
jLChoixPersoText.setText("Choix Des personnages");
jPCHoixPersoFond.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
@ -119,6 +123,7 @@ public class Plateau_de_jeu extends javax.swing.JFrame {
jTAAttaquantCaracteristiques.setBackground(new java.awt.Color(102, 0, 0));
jTAAttaquantCaracteristiques.setColumns(20);
jTAAttaquantCaracteristiques.setFont(new java.awt.Font("Showcard Gothic", 2, 12)); // NOI18N
jTAAttaquantCaracteristiques.setRows(5);
jTAAttaquantCaracteristiques.setCursor(new java.awt.Cursor(java.awt.Cursor.TEXT_CURSOR));
jScrollPane3.setViewportView(jTAAttaquantCaracteristiques);
@ -153,6 +158,7 @@ public class Plateau_de_jeu extends javax.swing.JFrame {
jTADefenseurCaracteristiques.setBackground(new java.awt.Color(102, 0, 0));
jTADefenseurCaracteristiques.setColumns(20);
jTADefenseurCaracteristiques.setFont(new java.awt.Font("Showcard Gothic", 2, 12)); // NOI18N
jTADefenseurCaracteristiques.setRows(5);
jScrollPane4.setViewportView(jTADefenseurCaracteristiques);
@ -214,14 +220,14 @@ public class Plateau_de_jeu extends javax.swing.JFrame {
jPChoixPerso.setLayout(jPChoixPersoLayout);
jPChoixPersoLayout.setHorizontalGroup(
jPChoixPersoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPChoixPersoLayout.createSequentialGroup()
.addGap(26, 26, 26)
.addComponent(jLChoixPersoText, javax.swing.GroupLayout.PREFERRED_SIZE, 134, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPChoixPersoLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPCHoixPersoFond, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
.addGroup(jPChoixPersoLayout.createSequentialGroup()
.addGap(26, 26, 26)
.addComponent(jLChoixPersoText, javax.swing.GroupLayout.PREFERRED_SIZE, 250, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPChoixPersoLayout.setVerticalGroup(
jPChoixPersoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -334,7 +340,22 @@ public class Plateau_de_jeu extends javax.swing.JFrame {
jMenuBar1.add(jMenuJeu);
jMenu2.setText("Edit");
jMenu2.setText("??");
jMIaide.setText("Aide");
jMenu2.add(jMIaide);
jMIobjectif.setText("Objectif");
jMIobjectif.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMIobjectifActionPerformed(evt);
}
});
jMenu2.add(jMIobjectif);
jMIapropos.setText("A propos");
jMenu2.add(jMIapropos);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
@ -404,17 +425,23 @@ public class Plateau_de_jeu extends javax.swing.JFrame {
}//GEN-LAST:event_jCBoxAttaquantInputMethodTextChanged
private void jMInewPlayerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMInewPlayerActionPerformed
// TODO add your handling code here:
Ajout_Perso perso = new Ajout_Perso(leJeu);
perso.setVisible(true);
}//GEN-LAST:event_jMInewPlayerActionPerformed
private void jMInewGameActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMInewGameActionPerformed
Plateau_de_jeu bidul = new Plateau_de_jeu();
bidul.setVisible(true);
}//GEN-LAST:event_jMInewGameActionPerformed
private void jMIquitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMIquitActionPerformed
System.exit(0);
}//GEN-LAST:event_jMIquitActionPerformed
private void jMIobjectifActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMIobjectifActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jMIobjectifActionPerformed
private void majStatistiquesPersos(){
@ -483,8 +510,11 @@ public class Plateau_de_jeu extends javax.swing.JFrame {
private javax.swing.JLabel jLImageAttaquant;
private javax.swing.JLabel jLImageDefenseur;
private javax.swing.JLabel jLImageListePerso;
private javax.swing.JMenuItem jMIaide;
private javax.swing.JMenuItem jMIapropos;
private javax.swing.JMenuItem jMInewGame;
private javax.swing.JMenuItem jMInewPlayer;
private javax.swing.JMenuItem jMIobjectif;
private javax.swing.JMenuItem jMIopenGame;
private javax.swing.JMenuItem jMIquit;
private javax.swing.JMenuItem jMIsave;

View File

@ -4,6 +4,7 @@
*/
package metier;
import java.util.ArrayList;
import java.util.Vector;
/**
@ -12,8 +13,7 @@ import java.util.Vector;
*/
public class Jeu {
String nomJeu = "Jeu de Role" ;
Personnage[] mesPersonnages = new Personnage[7];
private ArrayList<Personnage> mesPersonnages;
/********* Constructeurs ********/
@ -33,8 +33,8 @@ public class Jeu {
* Getteur de mes personnages
* @return mes personnages
*/
public Personnage[] getmesPersonnages(){
return this.mesPersonnages;
public ArrayList<Personnage> getmesPersonnages(){
return mesPersonnages;
}
/********* Setteurs ********/
@ -46,14 +46,14 @@ public class Jeu {
* Crée les personnages
*/
private void chargerLesPersonnages(){
mesPersonnages = new Personnage[7];
mesPersonnages[0] = new Guerrier("Barbare", "", 6, 4, "Hache");
mesPersonnages[5] = new Guerrier("Garren","Guerrier08.jpg" , 0, 0, "Gourdin");
mesPersonnages[6] = new Guerrier("Hellen","Guerrier08.jpg" , 0, 0, "Gourdin");
mesPersonnages[3] = new Personnage("Gaelle", "Barbare04.jpg", 0, 0);
mesPersonnages[1] = new Voleur("Raptout", "", 2, 4, "Marteau");
mesPersonnages[2] = new Sorcier("Panoramix", "", 10, 5, "Baguette de laurier");
mesPersonnages[4] = new Sorcier("Jinx","Barbare04.jpg",0,0, "Bâton");
mesPersonnages = new ArrayList<Personnage>();
mesPersonnages.add(new Guerrier("Barbare", "", 6, 4, "Hache"));
mesPersonnages.add(new Guerrier("Garren","Guerrier08.jpg" , 2, 8, "Gourdin"));
mesPersonnages.add(new Guerrier("Hellen","Guerrier08.jpg" , 8, 6, "Gourdin"));
mesPersonnages.add(new Personnage("Gaelle", "Barbare04.jpg", 5, 3));
mesPersonnages.add(new Voleur("Raptout", "", 2, 4, "Marteau"));
mesPersonnages.add(new Sorcier("Panoramix", "", 10, 5, "Baguette de laurier"));
mesPersonnages.add(new Sorcier("Jinx","Barbare04.jpg",0,0, "Bâton"));
}
/**
@ -63,8 +63,8 @@ public class Jeu {
@Override
public String toString(){
String mesPersos = "";
for (int i = 0; i < mesPersonnages.length; i++){
mesPersos += mesPersonnages[i] + "\n" + "\n";
for (int i = 0; i < mesPersonnages.size(); i++){
mesPersos += mesPersonnages.get(i) + "\n" + "\n";
}
return mesPersos;
}
@ -77,13 +77,13 @@ public class Jeu {
public Personnage rechercherPerso(String n){
int indice = 0;
boolean trouver = false;
while(indice < this.mesPersonnages.length && !trouver){
trouver = (this.mesPersonnages[indice].getNom().equals(n));
while(indice < this.mesPersonnages.size() && !trouver){
trouver = (this.mesPersonnages.get(indice).getNom().equals(n));
indice++;
}
if(trouver){
indice--;
return this.mesPersonnages[indice];
return this.mesPersonnages.get(indice);
}
return null;
}
@ -111,4 +111,7 @@ public class Jeu {
}
return LesPersonnagesVivants;
}
}