Created
February 20, 2015 21:23
-
-
Save deniscostadsc/3a05fb3ab24fc38dc8b1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package formatandotexto; | |
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.effect.DropShadow; | |
import javafx.scene.effect.Reflection; | |
import javafx.scene.layout.StackPane; | |
import javafx.scene.paint.Color; | |
import javafx.scene.text.Font; | |
import javafx.scene.text.FontPosture; | |
import javafx.scene.text.Text; | |
import javafx.stage.Stage; | |
/** | |
* | |
* @author Aluno_Enfase | |
*/ | |
public class FormatandoTexto extends Application { | |
@Override | |
public void start(Stage primaryStage) { | |
primaryStage.setTitle("Formatando texto"); | |
Group root = new Group(); | |
Scene scene = new Scene(root, 550, 250, Color.WHITE); | |
// primeiro texto | |
Text text1 = new Text(50, 50, "JavaFX 2.0"); | |
Font serif = Font.font("serif", 30); | |
text1.setFont(serif); | |
text1.setFill(Color.RED); | |
// adiciona sombra no primeiro texto | |
DropShadow dropShadow = new DropShadow(); | |
dropShadow.setOffsetX(2.0f); | |
dropShadow.setOffsetY(2.0f); | |
dropShadow.setColor(Color.rgb(50, 50, 50, 0.588)); | |
text1.setEffect(dropShadow); | |
root.getChildren().add(text1); | |
// segundo texto | |
Text text2 = new Text(50, 100, "JavaFX 2.0"); | |
Font sanSerif = Font.font("sanSerif", 30); | |
text2.setFont(sanSerif); | |
text2.setFill(Color.BLUE); | |
root.getChildren().add(text2); | |
// terceiro texto | |
Text text3 = new Text(50, 150, "JavaFX 2.0"); | |
Font dialogFont = Font.font("Dialog", 30); | |
text3.setFont(dialogFont); | |
text3.setFill(Color.rgb(0, 255, 0)); | |
root.getChildren().add(text3); | |
// quarto texto | |
Text text4 = new Text(50, 200, "JavaFX 2.0"); | |
Font monoFont = Font.font("Monospaced", 30); | |
text4.setFont(monoFont); | |
text4.setFill(Color.BLACK); | |
root.getChildren().add(text4); | |
// colocando reflexo no quarto texto | |
Reflection refl = new Reflection(); | |
refl.setFraction(0.8f); | |
text4.setEffect(refl); | |
primaryStage.setScene(scene); | |
primaryStage.show(); | |
} | |
public static void main(String[] args) { | |
launch(args); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment