81 lines
4.2 KiB
HTML
81 lines
4.2 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
|
|
<html>
|
|
<head>
|
|
<title>FontDemo2.java</title>
|
|
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
|
<style type="text/css">
|
|
<!--
|
|
body {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
|
pre {color: #a9b7c6; background-color: #2b2b2b; font-family: monospace; font-weight: bold}
|
|
table {color: #888888; background-color: #313335; font-family: monospace; font-weight: bold}
|
|
.literal {color: #cc7832}
|
|
.string {color: #6a8759}
|
|
.number {color: #6897bb}
|
|
.comment {color: #808080}
|
|
.whitespace {color: #505050}
|
|
-->
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<table width="100%"><tr><td align="center">/home/caleb/ASDV-Java/Semester 3/Assignments/lab2_FX2_F22_part1/src/lab2_fx2_f22_part1/FontDemo2.java</td></tr></table>
|
|
<pre>
|
|
<span class="comment">/*</span>
|
|
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license</span>
|
|
<span class="comment"> * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template</span>
|
|
<span class="comment"> */</span>
|
|
<span class="literal">package</span> lab2_fx2_f22_part1;
|
|
|
|
<span class="literal">import</span> javafx.application.Application;
|
|
<span class="literal">import</span> javafx.scene.Scene;
|
|
<span class="literal">import</span> javafx.scene.control.*;
|
|
<span class="literal">import</span> javafx.scene.layout.*;
|
|
<span class="literal">import</span> javafx.scene.text.*;
|
|
<span class="literal">import</span> javafx.scene.paint.Color;
|
|
<span class="literal">import</span> javafx.scene.shape.Circle;
|
|
<span class="literal">import</span> javafx.stage.Stage;
|
|
|
|
<span class="comment">/**</span>
|
|
<span class="comment"> *</span>
|
|
<span class="comment"> * </span><span class="comment">@author</span> <span class="comment">caleb</span>
|
|
<span class="comment">*/</span>
|
|
<span class="literal">public</span> <span class="literal">class</span> FontDemo2 <span class="literal">extends</span> Application {
|
|
@Override <span class="comment">// Override the start method in the Application class</span>
|
|
<span class="literal">public</span> <span class="literal">void</span> start(Stage primaryStage) {
|
|
<span class="comment">// Create a pane to hold the circle and label</span>
|
|
Pane pane = <span class="literal">new</span> StackPane();
|
|
<span class="comment">// Create a scene and place it in the stage</span>
|
|
Scene scene = <span class="literal">new</span> Scene(pane);
|
|
<span class="comment">// Add the scene to the stage</span>
|
|
primaryStage.setScene(scene);
|
|
<span class="comment">//Set the stage title</span>
|
|
primaryStage.setTitle(<span class="string">"</span><span class="string">FontDemo2</span><span class="string">"</span>);
|
|
|
|
<span class="comment">// Create Node circle and add to the Pane</span>
|
|
Circle circle = <span class="literal">new</span> Circle();
|
|
circle.setRadius(<span class="number">300</span>);
|
|
circle.setStroke(Color.BLACK);
|
|
circle.setFill(Color.GRAY);
|
|
<span class="comment">//new Color(0.9, 0.1, 0.1, 0.1)</span>
|
|
<span class="comment">// Add circle to the pane</span>
|
|
pane.getChildren().add(circle);
|
|
|
|
<span class="comment">// Create node label and add to Pane</span>
|
|
Label label = <span class="literal">new</span> Label(<span class="string">"</span><span class="string">JavaFX</span><span class="string">"</span>);
|
|
label.setRotate(<span class="number">90.0</span>);
|
|
<span class="comment">// Font created via static method font() and set the font into the label</span>
|
|
label.setFont(Font.font(<span class="string">"</span><span class="string">Comic Sans MS</span><span class="string">"</span>,
|
|
FontWeight.NORMAL, FontPosture.ITALIC, <span class="number">96</span>));
|
|
label.setTextFill(Color.YELLOW);
|
|
pane.getChildren().add(label);
|
|
<span class="comment">// Display the stage</span>
|
|
primaryStage.show();
|
|
}
|
|
<span class="literal">public</span> <span class="literal">static</span> <span class="literal">void</span> main(String[] args)
|
|
{
|
|
launch(args);
|
|
}
|
|
}
|
|
|
|
</pre></body>
|
|
</html>
|