JavaFX에서 텍스트 노드는 Javafx.scene.text.Text 수업. JavaFx 창에 텍스트를 삽입/표시하려면 다음을 수행해야 합니다. -
-
Text 클래스를 인스턴스화합니다.
-
setter 메서드를 사용하거나 생성자의 인수로 무시하여 위치 및 텍스트 문자열과 같은 기본 속성을 설정합니다.
-
생성된 노드를 Group 개체에 추가합니다.
취소선 javafx.scene.text.Text 속성 클래스는 텍스트의 각 줄에 중간을 통과하는 직선이 있어야 하는지 여부를 결정합니다. setStrikeThrough()를 사용하여 이 속성에 값을 설정할 수 있습니다. 방법. 부울 값을 허용합니다. 이 메서드에 대한 인수로 true를 전달하여 텍스트(노드)를 공격할 수 있습니다.
밑줄 javafx.scene.text.Text 속성 클래스는 텍스트의 각 줄 아래에 직선이 있어야 하는지 여부를 결정합니다. setUnderline()을 사용하여 이 속성에 값을 설정할 수 있습니다. 방법. 부울 값을 허용합니다. 이 메소드에 대한 인수로 true를 전달하여 텍스트(노드) 아래에 행을 가질 수 있습니다.
예
import java.io.FileNotFoundException;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
public class Underline_StrikeThrough extends Application {
public void start(Stage stage) throws FileNotFoundException {
//Creating a text object
String str = "Welcome to Tutorialspoint";
Text text = new Text(30.0, 80.0, str);
//Setting the font
Font font = Font.font("Brush Script MT", FontWeight.BOLD, FontPosture.REGULAR, 65);
text.setFont(font);
//Setting the color of the text
text.setFill(Color.DARKCYAN);
//Setting the width and color of the stroke
text.setStrokeWidth(2);
text.setStroke(Color.DARKSLATEGRAY);
//Underlining the text
text.setUnderline(true);
//Striking through the text
text.setStrikethrough(true);
//Setting the stage
Group root = new Group(text);
Scene scene = new Scene(root, 595, 150, Color.BEIGE);
stage.setTitle("Underline And Strike-through");
stage.setScene(scene);
stage.show();
}
public static void main(String args[]){
launch(args);
}
} 출력
