Veja abaixo imagens do programa em execução:
Veja abaixo o código do programa:
Veja abaixo o código do programa:
import javafx.application.Application;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.layout.BorderPane;
import javafx.scene.input.KeyCodeCombination;
import javafx.scene.input.KeyCombination;
import javafx.scene.input.KeyCode;
class NewStage {
NewStage ( ) {
BorderPane root = new BorderPane ( );
Scene scene = new Scene ( root, 360, 265 );
Stage subStage = new Stage ( );
subStage.setTitle ( "JAVAFX - NEW
STAGE" );
Canvas canvas = new Canvas ( 390, 300 );
GraphicsContext ctx = canvas.getGraphicsContext2D ( );
ctx.setFont ( Font.font ( "Arial", FontWeight.NORMAL, 15 ) );
ctx.setFill ( Color.RED );
ctx.fillText ( "JAVAFX - NEW
STAGE", 100, 80 );
ctx.setFill ( Color.BLUE );
ctx.fillText ( "Por: Samuel
Lima", 140, 180 );
ctx.setFill ( Color.GREEN );
ctx.fillText ( "Muito
obrigado", 140, 220 );
// Criando uma moldura na janela
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:
yellow;" );
root.getChildren ( ).add ( canvas );
subStage.setScene ( scene );
subStage.show ( );
////////////////////////////////////////////////////////////////////////
MenuBar m_nu_1 = new MenuBar ( );
Menu m_nu = new Menu ( "Arq" );
MenuItem exd = new MenuItem ( "Sair" );
MenuItem te_d = new MenuItem ( "Pesquisar" );
m_nu.getItems ( ).addAll ( te_d, exd );
/////////////////////////////////////////////
m_nu_1.getMenus ( ).add ( m_nu );
root.setTop ( m_nu_1 );
////////////////////////////////////////////////////////////////////////
exd.setOnAction ( new EventHandler < ActionEvent > ( ) {
@Override
public void handle ( ActionEvent e ) {
System.exit ( 0 );
}
} );
////////////////////////////////////////////////////////////////////////
te_d.setOnAction ( new EventHandler < ActionEvent > ( ) {
@Override
public void handle ( ActionEvent e ) {
new NewStage ( );
}
} );
exd.setAccelerator ( new KeyCodeCombination (
KeyCode.E,
KeyCombination.CONTROL_DOWN ) );
te_d.setAccelerator ( new KeyCodeCombination (
KeyCode.C,
KeyCombination.CONTROL_DOWN ) );
}
}
public class PROJETO extends Application {
Canvas canvas = new Canvas ( 490, 300 );
GraphicsContext ctx = canvas.getGraphicsContext2D
( );
BorderPane root = new BorderPane ( );
Scene scene = new Scene ( root, 490, 300 );
///////////////////////////////////////////////////////////////////////////
public void start ( Stage stage ) {
stage.setTitle ( "JAVAFX -
STAGE PRINCIPAL" );
ctx.setFont ( Font.font ( "Arial", FontWeight.BOLD, 15 ) );
ctx.setFill ( Color.RED );
ctx.fillText ( "JAVAFX -
STAGE PRINCIPAL", 140, 80 );
// Criando uma moldura no texarea
root.setStyle ( "-fx-padding:
5;" + "-fx-border-style: solid inside;"
+ "-fx-border-width:
18;" + "-fx-border-insets: 5;"
+ "-fx-border-radius:
5;" + "-fx-border-color: blue;" );
stage.setScene ( scene );
root.getChildren ( ).add ( canvas );
stage.show ( );
////////////////////////////////////////////////////////////////////////
MenuBar m_nu_1 = new MenuBar ( );
Menu m_nu = new Menu ( "Arq" );
MenuItem exd = new MenuItem ( "Sair" );
MenuItem te_d = new MenuItem ( "Pesquisar" );
m_nu.getItems ( ).addAll ( te_d, exd );
/////////////////////////////////////////////
m_nu_1.getMenus ( ).add ( m_nu );
root.setTop ( m_nu_1 );
///////////////////////////////////////////////////////////////////////
exd.setOnAction ( new EventHandler < ActionEvent > ( ) {
@Override
public void handle ( ActionEvent e ) {
stage.close ( );
}
} );
////////////////////////////////////////////////////////////////////////
te_d.setOnAction ( new EventHandler < ActionEvent > ( ) {
@Override
public void handle ( ActionEvent e ) {
new NewStage ( );
}
} );
exd.setAccelerator ( new KeyCodeCombination (
KeyCode.E,
KeyCombination.CONTROL_DOWN ) );
te_d.setAccelerator ( new KeyCodeCombination (
KeyCode.C,
KeyCombination.CONTROL_DOWN ) );
}
/////////////////////////////////////////////////////////////////////////////
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.