public JPanel createLaneController() { JPanel controller = new JPanel(); IntTextField northSouthGREENTimer = new IntTextField(); IntTextField northSouthREDTimer = new IntTextField(); JButton validate = new JButton("Valider"); JLabel message = new JLabel(); validate.addActionListener( (e) -> { int greenValue = northSouthGREENTimer.getValue() * 1000; int redValue = northSouthREDTimer.getValue() * 1000; if (greenValue > 0 && redValue > 0) { fNorth.configure(Feu.State.VERT, greenValue, redValue); fSouth.configure(Feu.State.VERT, greenValue, redValue); fEast.configure(Feu.State.ROUGE, redValue, greenValue); fWest.configure(Feu.State.ROUGE, redValue, greenValue); message.setText("Modifications prises en compte."); } else { message.setText("Erreur : valeurs invalides."); } }); controller.setLayout(new BoxLayout(controller, BoxLayout.Y_AXIS)); controller.add(new JLabel("Temps Vert")); controller.add(northSouthGREENTimer); controller.add(new JLabel("Temps Rouge")); controller.add(northSouthREDTimer); controller.add(validate); controller.add(message); return controller; }
public void defaultFeuConfiguration() { fNorth.configure(Feu.State.VERT, DEFAULT_GREEN_TIME, DEFAULT_RED_TIME); fSouth.configure(Feu.State.VERT, DEFAULT_GREEN_TIME, DEFAULT_RED_TIME); fEast.configure(Feu.State.ROUGE, DEFAULT_RED_TIME, DEFAULT_GREEN_TIME); fWest.configure(Feu.State.ROUGE, DEFAULT_RED_TIME, DEFAULT_GREEN_TIME); }