package paineis;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
/**
*
* @author HENRIQUE
*/
public class BotaoPainel extends Application{
StackPane painel = new StackPane();
@Override
public void start(Stage stage) throws Exception {
painel.getChildren().add(new Button("Clique aqui"));
Scene scene = new Scene(painel, 200, 50);
stage.setTitle("Botão dentro de um painel");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}
![Saída](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjh4t8naEwTyDEYTg3bjUwiBRKqjZ9kWUSmTe-C_WV331XrcTaXP_3QqpFdwq4OFmn9LhI5cNwa-7osKK1TpjWbx9903MTzgwQFvroLXJ6_x2UrYUVC1FMwAS-cbbGsgbwHoW6SvMAK00Yk/w400-h110/Sem+t%25C3%25ADtulo.png)
EXEMPLO 2: Circulo
package paineis;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
/**
*
* @author HENRIQUE
*/
public class Circulo extends Application{
@Override
public void start(Stage stage){
Circle circle = new Circle();
circle.setCenterX(100);//cpordenada
circle.setCenterY(100);//coordenada
circle.setRadius(50);
circle.setStroke(Color.BLACK);
circle.setFill(Color.WHITE);
Pane pane = new Pane();
pane.getChildren().add(circle);
Scene scene = new Scene(pane, 200, 200);
stage.setTitle("Exibindo um circulo");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi1OBTO980yvZtp7pqu5sBJpdAf0HI3hdAYm55jVd8qNRw-sV7hEgjbjOiCL11K2wQxEGWnikol2muwP1QQwvZh67hFS7RktDOq0fQWnVkfsfPsNsigr3xa6hFVgIUEXn2UP4PzOcNW-G1T/d/Sem+t%25C3%25ADtulo.png)
EXEMPLO 3: Circulo centralizado
package paineis;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.stage.Stage;
/**
*
* @author HENRIQUE
*/
public class CirculoCentralizado extends Application{
@Override
public void start(Stage stage){
Pane pane = new Pane();
Circle circle = new Circle();
circle.centerXProperty().bind(pane.widthProperty().divide(2));
circle.centerYProperty().bind(pane.heightProperty().divide(2));
circle.setRadius(50);
circle.setStroke(Color.BLACK);
circle.setFill(Color.WHITE);
//circle.setFill(Color.RED);
pane.getChildren().add(circle);
Scene scene = new Scene(pane, 200, 200);
stage.setTitle("Circulo Sempre Centralizado");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-pMCIfA7SkdBd29iayXAvZyEvsoePB-uwHLwyrP9mh-cE2mj6x9KxHloGwh8iBqXN15bXO2wUryDcaA_Ry3FiP8J0ytWaeVTw0JT7_-swVyc73CKNkYhyphenhyphenbY0BjFtDB4acTLTR-T4qIcYl/w320-h232/Sem+t%25C3%25ADtulo.png)
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh-pMCIfA7SkdBd29iayXAvZyEvsoePB-uwHLwyrP9mh-cE2mj6x9KxHloGwh8iBqXN15bXO2wUryDcaA_Ry3FiP8J0ytWaeVTw0JT7_-swVyc73CKNkYhyphenhyphenbY0BjFtDB4acTLTR-T4qIcYl/w320-h232/Sem+t%25C3%25ADtulo.png)
EXEMPLO 4: Interface com JavaFX
package paineis;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;
/**
*
* @author HENRIQUE
*/
public class MinhaPrimeiraInterface extends Application {
@Override
public void start (Stage primaryStage){
Button btn = new Button("Sou um Botão");
Scene scene = new Scene(btn, 200, 250);
primaryStage.setTitle("Minha Primeira Interface JavaFX");
primaryStage.setScene(scene);
primaryStage.show();
Stage stage = new Stage();
stage.setTitle("Nova janela");
stage.setScene(new Scene(new Button("Mais um botão"),100, 100));
stage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}
EXEMPLO 5: Interface dentro de uma interface
package paineis;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.FlowPane;
import javafx.stage.Stage;
/**
*
* @author HENRIQUE
*/
public class PainelDentroDePainel extends Application{
@Override
public void start(Stage stage) {
BorderPane painelPrincipal = new BorderPane();
FlowPane painelSul = new FlowPane();
painelSul.getChildren().add(new Button("Botão 1"));
painelSul.getChildren().add(new Button("Botão 2"));
painelPrincipal.setBottom(painelSul);
Scene scene = new Scene(painelPrincipal, 400, 400);
stage.setTitle("Painel dentro de um Painel");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
Application.launch(args);
}
}
![Saída](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgN2qU2Vp4uiRATfBZ6h1E2P4nf-NnwrOAcbSKn7zqhFjRNFd8jE1OQ74wRr0LyV-BZCumWojhYuXdVuBG2cK4DsROyyShdjqi9nquFNzcFMvTZqZ6wOVCJnLmpnePsgiFHQn4qw8uIWXc0/w400-h223/Sem+t%25C3%25ADtulo.png)
Nenhum comentário:
Postar um comentário