Nantes Université

Skip to content
Extraits de code Groupes Projets
Valider b6061be6 rédigé par Tristan MAISONNEUVE's avatar Tristan MAISONNEUVE
Parcourir les fichiers

Class Boutons + fenetre

parent bc2f4ab1
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
package modele.info1.ships;
import javax.swing.*;
public class Bouttons {
JButton bouton;
String co;
public Bouttons(JButton bouton,String co){
this.bouton = bouton;
this.co = co;
}
public JButton getButton(){
return bouton;
}
public String getString(){
return co;
}
}
\ No newline at end of file
......@@ -2,6 +2,8 @@ package vue;
import PremiereFenetre.PremiereFenetre;
import info1.network.Player;
import modele.info1.ships.Bouttons;
import modele.info1.ships.Coord;
import javax.swing.*;
import java.awt.*;
......@@ -42,27 +44,38 @@ public class FenetreConnexion extends JFrame {
JPanel grille = new JPanel();
grille.setLayout(new GridLayout(11,11));
for (int i=0; i<11;i++){
String[] lettres={" ","A","B","C","D","E","F","G","H","I","J"};
final JLabel labellettre = new JLabel(lettres[i],SwingConstants.CENTER);
for (int i = 0; i < 11; i++) {
String[] lettres = {" ", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J"};
final JLabel labellettre = new JLabel(lettres[i], SwingConstants.CENTER);
labellettre.setBorder(BorderFactory.createLineBorder(Color.BLACK));
grille.add(labellettre);
}
int j=0;
for (int i =0; i<(11*10); i++){
String[] nombres={"1","2","3","4","5","6","7","8","9","10"};
final JButton label = new JButton(" ");
if(i%11==0) {
final JLabel labelchiffres = new JLabel(nombres[j],SwingConstants.CENTER);
int j = 0;
int chiffre = 1;
char lettre = 'A';
final String[] co = {null};
final Coord[] cord1 = new Coord[1];
for (int i = 0; i < (11 * 10); i++) {
String[] nombres = {"1", "2", "3", "4", "5", "6", "7", "8", "9", "10"};
if (i % 11 == 0) {
final JLabel labelchiffres = new JLabel(nombres[j], SwingConstants.CENTER);
labelchiffres.setBorder(BorderFactory.createLineBorder(Color.BLACK));
grille.add(labelchiffres);
j++;
} else {
if (i % 11 == 1) {
lettre = 'A';
if (i != 1)
chiffre++;
}
final Bouttons boutton = new Bouttons(new JButton(), lettre + String.valueOf(chiffre));
boutton.getButton().setBorder(BorderFactory.createLineBorder(Color.BLACK));
grille.add(boutton.getButton());
}
else{
label.setBorder(BorderFactory.createLineBorder(Color.BLACK));
grille.add(label);
}
lettre++;
}
principal.add(grille,BorderLayout.CENTER);
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter