JavaFX: Comment mettre un label avec un nombre...
Résolu
Debutant.EXE
-
Debutant.EXE -
Debutant.EXE -
Bonjours mon problème est simple je code le JavaFX et que je veux faire un système d'argent SIMPLE ex.:
Quelqu'un peux m'aider.
Voici mon code complet:
long money = 150; Label lb1 = new Label(); lb1.setText(money);
Quelqu'un peux m'aider.
Voici mon code complet:
package test;
import java.awt.Cursor;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
public class test extends Application {
public static void main(String[] args) {
Application.launch(args);
}
@Override
public void start(Stage primaryStage) {
Group root = new Group();
Scene scene = new Scene(root, 800, 600, Color.LIGHTBLUE);
primaryStage.setScene(scene);
Button btn = new Button("Set your money to 15000000");
btn.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
// TODO Auto-generated method stub
long money = 15000000;
System.out.println("Vous avez maintenant " + money + "$");
}
});
Circle cercle = new Circle();
cercle.setCenterX(400);
cercle.setCenterY(250);
cercle.setRadius(100);
cercle.setFill(Color.YELLOW);
cercle.setStroke(Color.ORANGE);
cercle.setStrokeWidth(5);
Label lb1 = new Label();
lb1.setText(money);
root.getChildren().addAll(cercle, btn);
primaryStage.show();
primaryStage.centerOnScreen();
primaryStage.setResizable(false);
primaryStage.setTitle("Button");
}
}
A voir également:
- Erreur : des composants dexécution javafx obligatoires pour exécuter cette application sont manquants.
- Connaitre les composants de son pc - Guide
- Nommez une application d'appel vidéo ou de visioconférence - Guide
- Desinstaller application windows - Guide
- Application pour apprendre à coder - Guide
- Windows application démarrage - Guide