From 65b9fb31dddbefc7df5d898b3f73c27e8c0aec61 Mon Sep 17 00:00:00 2001 From: philippe lhardy Date: Sat, 18 Nov 2017 21:01:06 +0100 Subject: [PATCH] =?UTF-8?q?actions=20en=20fran=C3=A7ais=20bouton=20quitter?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.xml | 1 + java/org/artisanlogiciel/games/Display.java | 46 ++++++++++++++------- lang/LabelsBundle_fr.properties | 11 +++++ 3 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 lang/LabelsBundle_fr.properties diff --git a/build.xml b/build.xml index 45a7d77..205793d 100644 --- a/build.xml +++ b/build.xml @@ -32,6 +32,7 @@ + diff --git a/java/org/artisanlogiciel/games/Display.java b/java/org/artisanlogiciel/games/Display.java index 8fa390a..28b1a5a 100644 --- a/java/org/artisanlogiciel/games/Display.java +++ b/java/org/artisanlogiciel/games/Display.java @@ -5,6 +5,7 @@ import java.awt.image.BufferedImage; import java.awt.Color; import java.awt.Container; import java.awt.Dimension; +import java.awt.FlowLayout; import java.awt.Graphics; import java.awt.Rectangle; import java.awt.event.ActionEvent; @@ -16,7 +17,9 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.LinkedList; +import java.util.Locale; import java.util.Scanner; +import java.util.ResourceBundle; import javax.imageio.ImageIO; @@ -36,6 +39,7 @@ import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import org.artisanlogiciel.games.stl.Wall3d; +import org.artisanlogiciel.util.UTF8Control; /** * Display is Main JFrame for this tool @@ -45,6 +49,8 @@ public class Display extends JFrame // to please eclipse, not supposed to be serialized private static final long serialVersionUID = 8500214871372184418L; + final static ResourceBundle labels = ResourceBundle.getBundle("LabelsBundle", Locale.FRENCH, Display.class.getClassLoader(), new UTF8Control()); + MazeComponent maze; MazeControler controler; LabyModel model; @@ -181,7 +187,7 @@ public class Display extends JFrame void createSettingsGui() { - JButton buttonCreate = new JButton("Create"); + JButton buttonCreate = new JButton(labels.getString("create")); buttonCreate.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) @@ -192,15 +198,15 @@ public class Display extends JFrame add(buttonCreate); if ( params != null ) { - JLabel widthLabel = new JLabel("width"); + JLabel widthLabel = new JLabel(labels.getString("width")); textWidth = new JTextField("0" + params.getWidth()); add(widthLabel); add(textWidth); - JLabel heightLabel = new JLabel("height"); + JLabel heightLabel = new JLabel(labels.getString("height")); textHeight = new JTextField("0" + params.getHeight()); add(heightLabel); add(textHeight); - JLabel depthLabel = new JLabel("depth"); + JLabel depthLabel = new JLabel(labels.getString("depth")); textDepth = new JTextField("0" + params.getMaxDepth()); add(depthLabel); add(textDepth); @@ -295,7 +301,7 @@ public class Display extends JFrame super(new BorderLayout()); controlPanel = new JPanel(new BorderLayout()); settings = new MazeSettings(params); - JButton button = new JButton("Resolve"); + JButton button = new JButton(labels.getString("resolve")); button.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) @@ -316,7 +322,7 @@ public class Display extends JFrame goNorth(); } }; - JButton north = addDirection(this, "North", "UP", goNorth); + JButton north = addDirection(this, labels.getString("north"), "UP", goNorth); @SuppressWarnings("serial") Action goEast = new AbstractAction() @@ -329,7 +335,7 @@ public class Display extends JFrame } }; - JButton east = addDirection(this, "East", "RIGHT", goEast); + JButton east = addDirection(this, labels.getString("east"), "RIGHT", goEast); @SuppressWarnings("serial") Action goWest = new AbstractAction() @@ -341,7 +347,7 @@ public class Display extends JFrame goWest(); } }; - JButton west = addDirection(this, "West", "LEFT", goWest); + JButton west = addDirection(this, labels.getString("west"), "LEFT", goWest); @SuppressWarnings("serial") Action goSouth = new AbstractAction() @@ -353,7 +359,7 @@ public class Display extends JFrame goSouth(); } }; - JButton south = addDirection(this, "South", "DOWN", goSouth); + JButton south = addDirection(this, labels.getString("south"), "DOWN", goSouth); controlPanel.add(button, BorderLayout.CENTER); controlPanel.add(north, BorderLayout.NORTH); @@ -381,7 +387,7 @@ public class Display extends JFrame setAutoSize( autoSlide.isSelected()); } }); - final JButton savePngButton = new JButton("Save png"); + final JButton savePngButton = new JButton(labels.getString("save") +" png"); Action savePngAction = new AbstractAction() { public void actionPerformed(ActionEvent evt) { @@ -392,10 +398,22 @@ public class Display extends JFrame }; savePngButton.addActionListener(savePngAction); - resizecontrol = new JPanel(); - resizecontrol.add(slider, BorderLayout.WEST); - resizecontrol.add(autoSlide, BorderLayout.EAST); - resizecontrol.add(savePngButton, BorderLayout.SOUTH); + final JButton quitButton = new JButton(labels.getString("quit")); + Action quitAction = new AbstractAction() { + public void actionPerformed(ActionEvent evt) + { + // + System.out.println("quit"); + System.exit(0); + } + }; + quitButton.addActionListener(quitAction); + + resizecontrol = new JPanel(new FlowLayout()); + resizecontrol.add(slider); + resizecontrol.add(autoSlide); + resizecontrol.add(savePngButton); + resizecontrol.add(quitButton); add(controlDisplayPanel, BorderLayout.SOUTH); add(resizecontrol,BorderLayout.WEST); diff --git a/lang/LabelsBundle_fr.properties b/lang/LabelsBundle_fr.properties new file mode 100644 index 0000000..635bf8a --- /dev/null +++ b/lang/LabelsBundle_fr.properties @@ -0,0 +1,11 @@ +width = largeur +height = hauteur +depth = profondeur +north = nord +south = sud +east = est +west = ouest +resolve = résoudre +create = créer +save = sauver +quit = quitter \ No newline at end of file