개발 환경 설정
- JavaFX 개발 환경 설정(넷빈즈 8.2, 오라클 JDK 1.8, Scene Builder)
- Scene Builder에 라이브러리 추가 하는 방법(JFoeniX, FontAwesomeFX)
- 넷빈즈 프로젝트 외부 라이브러리(jar) 등록하는 방법
프로그램의 제목표시줄(타이블바)을 제거하는 예제입니다.
결과
프로젝트 다운로드
프로젝트 구조
소스 코드
Main.java
package com.ozxexe;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
public class Main extends Application {
@Override
public void start(Stage stage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("MainFXML.fxml"));
Scene scene = new Scene(root);
stage.initStyle(StageStyle.UNDECORATED);
stage.setScene(scene);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
MainFXML.fxml
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<AnchorPane id="AnchorPane" prefHeight="200" prefWidth="320" xmlns:fx="http://javafx.com/fxml/1" fx:controller="com.ozxexe.MainFXMLController">
<children>
<Button layoutX="126" layoutY="90" text="Click Me!" onAction="#handleButtonAction" fx:id="button" />
<Label layoutX="126" layoutY="120" minHeight="16" minWidth="69" fx:id="label" />
</children>
</AnchorPane>
MainFXMLController.java
package com.ozxexe;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Label;
public class MainFXMLController implements Initializable {
@FXML
private Label label;
@FXML
private void handleButtonAction(ActionEvent event) {
System.out.println("You clicked me!");
label.setText("Hello World!");
}
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}
}
참고사이트
Stage (JavaFX 8)
Defines whether the Stage is resizable or not by the user. Programatically you may still change the size of the Stage. This is a hint which allows the implementation to optionally make the Stage resizable by the user. Warning: Since 8.0 the property cannot
docs.oracle.com
Learn JavaFX 8
Learn JavaFX 8 shows you how to start developing rich-client desktop applications using your Java skills and provides comprehensive coverage of JavaFX 8's features. Each chapter starts with an introduction to the topic at hand, followed by a step-by-step d
books.google.co.kr
'Java | JavaFX' 카테고리의 다른 글
JavaFX 윈도우(stage) 드래그 창 이동 및 최대화, 최소화, 닫기 기능 구현 예제 (0) | 2019.12.27 |
---|---|
JavaFX AnimateFX 데모 예제 (0) | 2019.12.26 |
JavaFX 마우스 오버 시, 슬라이드 메뉴 예제 (0) | 2019.12.26 |
JavaFX 탭을 활용한 메뉴 및 화면 전환 예제(JFXTabPane) (0) | 2019.12.26 |
JavaFX 웹 스타일 네이게이션 메뉴 예제(TranslateTransition) (0) | 2019.12.26 |