import javafx.application.Application;
import javafx.collections.ObservableList;
import javafx.concurrent.Task;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.layout.Pane;
public class PROJETO extends Application {
static String str = "";
static String str_2;
static Stage stage;
Scene scene;
static Pane root = new Pane ( );
static Canvas canvas = new Canvas ( 660, 460 );
static GraphicsContext ctx = canvas.getGraphicsContext2D ( );
//Chamando uma função
depois de um certo tempo
//Chamada
Sleep ( 1800, k );
public static Node Teste_3 ( ) {
Group y = new Group ( );
ctx.setFill ( Color.RED );
ctx.fillText ( "MUITO
OBRIGADO", 280, 420 );
return y;
}
public static Node Teste_2 ( ) {
Group y = new Group ( );
ctx.setFill ( Color.BLUE );
ctx.fillText ( "Por: Samuel
Lima", 225, 150 );
return y;
}
public static Node Teste_1 ( ) {
Group y = new Group ( );
ctx.setFill ( Color.BLACK );
ctx.fillText ( "Veja abaixo
as chamadas temporizadas", 200, 100 );
return y;
}
public static int Sleep ( int x, int k ){
Task < Integer > close = new Task < Integer > ( ) {
@Override
protected Integer call ( ) throws Exception {
Thread.sleep ( x );
return null;
}
};
close.setOnSucceeded ( c -> {
if ( k == 1 )
Teste_1 ( );
if ( k == 2 )
Teste_2 ( );
if ( k == 3 )
Teste_3 ( );
} );
new Thread ( close ).start ( );
return 0;
}
//
//////////////////////////////////////////////////////////////////////////
@Override
public void start ( Stage stage ) {
ctx.setLineWidth ( 22.0 );
ctx.strokeRoundRect ( 10, 10, 640, 440, 10, 10 );
root.getChildren ( ).add ( canvas );
Scene scene = new Scene ( root );
stage.setTitle ( "CHAMANDO FUNÇÃO
EM TEMPOS DETERMINADOS" );
ctx.setFont ( Font.font ( "Arial", FontWeight.BOLD, 15 ) );
ctx.setFill ( Color.RED );
ctx.fillText ( "CHAMANDO FUNÇÃO
EM TEMPOS DETERMINADOS", 150, 60 );
ObservableList < Node > content = ( ( Pane ) scene.getRoot ( ) )
.getChildren ( );
stage.setScene ( scene );
stage.show ( );
content.add ( Tempo ( ) );
}
//
//////////////////////////////////////////////////////////////////////////
public static Node Tempo ( ) {
Group y = new Group ( );
int k = 1;
Sleep ( 1800, k );
k = 2;
Sleep ( 2800, k );
k = 3;
Sleep ( 3800, k );
return y;
}
//
//////////////////////////////////////////////////////////////////////////
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.