seus programas precisaram conter
mais de uma janela, isto porque
as informações passadas ao usuário,
serão muitas para serem exibidas em uma só.
Pensando nisto, criei este programa
que contém três janelas diferentes,
num belo designer e com imagens no fundo.
As janelas são chamadas por botões,
e nada impede os mais experientes em java
e que tenham bons conhecimentos em javaFx,
editar e modificar este programa para
adequá-lo as sua pretensões.
Veja abaixo imagens do programa em execução:
Veja abaixo um vídeo com o funcionamento do programa:
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.control.Button;
import javafx.scene.effect.DropShadow;
import javafx.stage.Stage;
import javafx.scene.paint.Color;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.Pane;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.application.Application;
import javafx.scene.effect.*;
class Janela_3 {
PROJETO pro = new PROJETO ( );
Pane root = new Pane ( );
Scene scene = new Scene ( root, 600, 320 );
Canvas canvas = new Canvas ( 600, 320 );
GraphicsContext ctx = canvas.getGraphicsContext2D ( );
Button btn_1 = new Button ( "1" );
Button btn_2 = new Button ( "2" );
Text t_1 = new Text ( );
Text t_2 = new Text ( );
Text t_3 = new Text ( );
DropShadow ds = new DropShadow ( );
Group g = new Group ( );
//
/////////////////////////////////////////////////////////////////////////
public Node Mensagem_1 ( ) {
t_1.setFont ( Font.font ( null, FontWeight.BOLD, 26 ) );
String Msg = "Programa
criado por: ";
ds.setOffsetY ( 3.0f );
ds.setColor ( Color.color ( 0.4f, 0.4f, 0.4f ) );
t_1.setEffect ( ds );
t_1.setCache ( true );
t_1.setX ( 180.0f );
t_1.setY ( 190.0f );
t_1.setFill ( Color.BLUE );
t_1.setText ( Msg );
g.setCache ( true );
g.setEffect ( new Bloom ( ) );
g.getChildren ( ).add ( t_1 );
return g;
}
//
/////////////////////////////////////////////////////////////////////////
public Node Mensagem_2 ( ) {
t_2.setFont ( Font.font ( null, FontWeight.BOLD, 26 ) );
String Msg = "SAMUEL
LIMA";
ds.setOffsetY ( 3.0f );
ds.setColor ( Color.color ( 0.4f, 0.4f, 0.4f ) );
t_2.setEffect ( ds );
t_2.setCache ( true );
t_2.setX ( 225.0f );
t_2.setY ( 230.0f );
t_2.setFill ( Color.BLACK );
t_2.setText ( Msg );
g.setCache ( true );
g.setEffect ( new Bloom ( ) );
g.getChildren ( ).add ( t_2 );
return g;
}
//
/////////////////////////////////////////////////////////////////////////
public Node Mensagem_3 ( ) {
String Msg = "MUITO
OBRIGADO";
t_3.setFont ( Font.font ( null, FontWeight.BOLD, 26 ) );
ds.setOffsetY ( 3.0f );
ds.setColor ( Color.color ( 0.4f, 0.4f, 0.4f ) );
t_3.setEffect ( ds );
t_3.setCache ( true );
t_3.setX ( 200.0f );
t_3.setY ( 270.0f );
t_3.setFill ( Color.RED );
t_3.setText ( Msg );
g.setCache ( true );
g.setEffect ( new Bloom ( ) );
g.getChildren ( ).add ( t_3 );
return g;
}
//
/////////////////////////////////////////////////////////////////////////
public Node Button_1 ( Stage stage ) {
btn_1.setPrefWidth ( 20 );// Largura do botão
btn_1.setLayoutX ( 267 );// Posição do botão
coluna
btn_1.setPrefHeight ( 20 );// altura do botão
btn_1.setLayoutY ( 280 );// //Posição do botão
linha
btn_1.setStyle ( "-fx-padding:
1;" + "-fx-border-style: solid inside;"
+ "-fx-border-width:
2;" + "-fx-border-insets: 1;"
+ "-fx-border-radius:
1;" + "-fx-border-color: blue;"
+ "-fx-font-style:
italic;"
+ "-fx-font-family:
Consolas;"
);
btn_1.setOnAction ( new EventHandler < ActionEvent > ( ) {
@Override
public void handle ( ActionEvent event ) {
//System.exit ( 0 );
try {
pro.start ( stage );
} catch ( FileNotFoundException e ) {
// TODO Auto-generated catch
block
e.printStackTrace();
}
}
} );
return btn_1;
}
//
/////////////////////////////////////////////////////////////////////////
public Node Button_2 ( Stage stage ) {
btn_2.setPrefWidth ( 20 );// Largura do botão
btn_2.setLayoutX ( 300 );// Posição do botão
coluna
btn_2.setPrefHeight ( 20 );// altura do botão
btn_2.setLayoutY ( 280 );// //Posição do botão
linha
btn_2.setStyle ( "-fx-padding:
1;"
+ "-fx-border-style:
solid inside;"
+ "-fx-border-width:
2;"
+ "-fx-border-insets:
1;"
+ "-fx-border-radius:
1;"
+ "-fx-border-color:
blue;"
+ "-fx-font-style:
italic;"
+ "-fx-font-family:
Consolas;");
btn_2.setOnAction ( new EventHandler < ActionEvent > ( ) {
@Override
public void handle ( ActionEvent event ) {
try {
new Janela_2 ( stage );
} catch ( FileNotFoundException e ) {
// TODO Auto-generated catch
block
e.printStackTrace();
}
}
} );
return btn_2;
}
//
/////////////////////////////////////////////////////////////////////////
Janela_3 ( Stage stage ) throws FileNotFoundException {
// Usando fonte em italic
ctx.setFont ( Font.font ( "Helvetica", FontWeight.BOLD,
FontPosture.ITALIC, 15 ) );
//stage.setTitle ( "JAVAFX - NAVEGANDO
ENTRE JANELAS" );
//Criando moldura e dando efeitos
root.setStyle ( "-fx-padding:
5;"
+ "-fx-border-style:
solid inside;"
+ "-fx-border-width:
10;"
+ "-fx-border-insets:
5;"
+ "-fx-border-radius:
5;"
+ "-fx-border-color:
blue;");
ctx.setFill ( Color.RED );
ctx.fillText ( "JAVAFX -
NAVEGANDO ENTRE JANELAS", 170, 40 );
Button_1 ( stage );
Button_2 ( stage );
Mensagem_1 ( );
Mensagem_2 ( );
Mensagem_3 ( );
Image imagem = new Image (
new FileInputStream (
"H:\\eclipse
luna_two\\" + "PROJETO\\PROJETO\\src\\"
+ "Foto\\java_5.png" ) );
ImageView imageView = new ImageView ( imagem );
imageView.setX ( 150 );
imageView.setY ( 35 );
imageView.setFitHeight ( 600 );
imageView.setFitWidth ( 325 );
imageView.setPreserveRatio ( true );
root.getChildren ( ).add ( imageView );
root.getChildren ( ).addAll ( canvas, btn_1, btn_2, g );
stage.setScene ( scene );
stage.show ( );
}
}
////////////////////////////////////////////////////////////////////////////////
class Janela_2 {
PROJETO pro = new PROJETO ( );
Pane root = new Pane ( );
Scene scene = new Scene ( root, 600, 320 );
Canvas canvas = new Canvas ( 600, 320 );
GraphicsContext ctx = canvas.getGraphicsContext2D
( );
Button btn_1 = new Button ( "1" );
Button btn_2 = new Button ( "3" );
//
/////////////////////////////////////////////////////////////////////////
public Node Button_1 ( Stage stage ) {
btn_1.setPrefWidth ( 20 );// Largura do botão
btn_1.setLayoutX ( 267 );// Posição do botão
coluna
btn_1.setPrefHeight ( 20 );// altura do botão
btn_1.setLayoutY ( 280 );// //Posição do botão
linha
btn_1.setStyle ( "-fx-padding:
1;"
+ "-fx-border-style:
solid inside;"
+ "-fx-border-width:
2;"
+ "-fx-border-insets:
1;"
+ "-fx-border-radius:
1;"
+ "-fx-border-color:
blue;"
+ "-fx-font-style:
italic;"
+ "-fx-font-family:
Consolas;");
btn_1.setOnAction ( new EventHandler < ActionEvent > ( ) {
@Override
public void handle ( ActionEvent event ) {
//System.exit ( 0 );
try {
pro.start ( stage );
} catch ( FileNotFoundException e ) {
// TODO Auto-generated catch
block
e.printStackTrace();
}
}
} );
return btn_1;
}
//
/////////////////////////////////////////////////////////////////////////
public Node Button_2 ( Stage stage ) {
btn_2.setPrefWidth ( 20 );// Largura do botão
btn_2.setLayoutX ( 300 );// Posição do botão
coluna
btn_2.setPrefHeight ( 20 );// altura do botão
btn_2.setLayoutY ( 280 );// //Posição do botão
linha
btn_2.setStyle ( "-fx-padding:
1;"
+ "-fx-border-style:
solid inside;"
+ "-fx-border-width:
2;"
+ "-fx-border-insets:
1;"
+ "-fx-border-radius:
1;"
+ "-fx-border-color:
blue;"
+ "-fx-font-style:
italic;"
+ "-fx-font-family:
Consolas;");
btn_2.setOnAction ( new EventHandler < ActionEvent > ( ) {
@Override
public void handle ( ActionEvent event ) {
try {
new Janela_3 ( stage );
} catch ( FileNotFoundException e ) {
// TODO Auto-generated catch
block
e.printStackTrace();
}
}
} );
return btn_2;
}
//
/////////////////////////////////////////////////////////////////////////
Janela_2 ( Stage stage ) throws FileNotFoundException {
// Usando fonte em italic
ctx.setFont ( Font.font ( "Helvetica", FontWeight.BOLD,
FontPosture.ITALIC, 15 ) );
//stage.setTitle ( "JAVAFX - NAVEGANDO
ENTRE JANELAS" );
//Criando moldura e dando efeitos
root.setStyle ( "-fx-padding:
5;"
+ "-fx-border-style:
solid inside;"
+ "-fx-border-width:
10;"
+ "-fx-border-insets:
5;"
+ "-fx-border-radius:
5;"
+ "-fx-border-color:
darkgreen;");
ctx.setFill ( Color.RED );
ctx.fillText ( "JAVAFX -
NAVEGANDO ENTRE JANELAS", 170, 40 );
Button_1 ( stage );
Button_2 ( stage );
Image imagem = new Image (
new FileInputStream (
"H:\\eclipse
luna_two\\" + "PROJETO\\PROJETO\\src\\"
+ "Foto\\java_2.png" ) );
ImageView imageView = new ImageView ( imagem );
imageView.setX ( 130 );
imageView.setY ( 40 );
imageView.setFitHeight ( 600 );
imageView.setFitWidth ( 325 );
imageView.setPreserveRatio ( true );
root.getChildren ( ).add ( imageView );
root.getChildren ( ).addAll ( canvas, btn_1, btn_2 );
stage.setScene ( scene );
stage.show ( );
}
}
////////////////////////////////////////////////////////////////////////////////
public class PROJETO extends Application {
Button btn_1 = new Button ( "2" );
Button btn_2 = new Button ( "3" );
Canvas canvas = new Canvas ( 600, 320 );
GraphicsContext ctx = canvas.getGraphicsContext2D
( );
Pane ro_ot = new Pane ( );
Scene sce_ne = new Scene ( ro_ot, 600, 320 );
//
/////////////////////////////////////////////////////////////////////////
public void Informe ( ) {
ctx.setFont ( Font.font ( "Arial", FontWeight.NORMAL, 13 ) );
ctx.setFill ( Color.RED );
ctx.fillText ( "Por: ", 250, 275 );
ctx.setFill ( Color.BLUE );
ctx.fillText ( "Samuel
Lima", 280, 275 );
ctx.setFill ( Color.BLACK );
ctx.fillText ( "sa_sp10@hotmail.com", 250, 290 );
}
//
////////////////////////////////////////////////////////////////////////
public Node Button_2 ( Stage stage ) {
btn_2.setPrefWidth ( 20 );// Largura do botão
btn_2.setLayoutX ( 300 );// Posição do botão
coluna
btn_2.setPrefHeight ( 20 );// altura do botão
btn_2.setLayoutY ( 280 );// //Posição do botão
linha
btn_2.setStyle ( "-fx-padding:
1;"
+ "-fx-border-style:
solid inside;"
+ "-fx-border-width:
2;"
+ "-fx-border-insets:
1;"
+ "-fx-border-radius:
1;"
+ "-fx-border-color:
blue;"
+ "-fx-font-style:
italic;"
+ "-fx-font-family:
Consolas;");
btn_2.setOnAction ( new EventHandler < ActionEvent > ( ) {
@Override
public void handle ( ActionEvent event ) {
try {
new Janela_3 ( stage );
} catch ( FileNotFoundException e ) {
// TODO Auto-generated catch
block
e.printStackTrace();
}
}
} );
return btn_2;
}
//
/////////////////////////////////////////////////////////////////////////
public Node Button_1 ( Stage stage ) {
btn_1.setPrefWidth ( 20 );// Largura do botão
btn_1.setLayoutX ( 267 );// Posição do botão
coluna
btn_1.setPrefHeight ( 20 );// altura do botão
btn_1.setLayoutY ( 280 );// //Posição do botão
linha
btn_1.setStyle ( "-fx-padding:
1;"
+ "-fx-border-style:
solid inside;"
+ "-fx-border-width:
2;"
+ "-fx-border-insets:
1;"
+ "-fx-border-radius:
1;"
+ "-fx-border-color:
blue;"
+ "-fx-font-style:
italic;"
+ "-fx-font-family:
Consolas;");
btn_1.setOnAction ( new EventHandler < ActionEvent > ( ) {
@Override
public void handle ( ActionEvent event ) {
//System.exit ( 0 );
try {
new Janela_2 ( stage );
} catch ( FileNotFoundException e ) {
// TODO Auto-generated catch
block
e.printStackTrace();
}
}
} );
return btn_1;
}
//
/////////////////////////////////////////////////////////////////////////
public void start ( Stage stage ) throws FileNotFoundException {
// Usando fonte em italic
ctx.setFont ( Font.font ( "Helvetica", FontWeight.BOLD,
FontPosture.ITALIC, 15 ) );
stage.setTitle ( "JAVAFX -
NAVEGANDO ENTRE JANELAS" );
//Criando moldura e dando efeitos
ro_ot.setStyle ( "-fx-padding:
5;"
+ "-fx-border-style:
solid inside;"
+ "-fx-border-width:
10;"
+ "-fx-border-insets:
5;"
+ "-fx-border-radius:
5;"
+ "-fx-border-color:
pink;");
ctx.setFill ( Color.RED );
ctx.fillText ( "JAVAFX -
NAVEGANDO ENTRE JANELAS", 170, 40 );
Button_1 ( stage );
Button_2 ( stage );
Image imagem = new Image (
new FileInputStream (
"H:\\eclipse
luna_two\\" + "PROJETO\\PROJETO\\src\\"
+ "Foto\\java_4.png" ) );
ImageView imageView = new ImageView ( imagem );
imageView.setX ( 80 );
imageView.setY ( -35 );
imageView.setFitHeight ( 900 );
imageView.setFitWidth ( 625 );
imageView.setPreserveRatio ( true );
ro_ot.getChildren ( ).add ( imageView );
ro_ot.getChildren ( ).addAll ( canvas, btn_1, btn_2 );
stage.setScene ( sce_ne );
stage.show ( );
}
//
/////////////////////////////////////////////////////////////////////////
public static void main ( String [ ] args ) {
Application.launch ( args );
}
}
Nenhum comentário:
Postar um comentário
Observação: somente um membro deste blog pode postar um comentário.