­čîâ JavaFX ile GUI Tasar─▒m─▒

JavaFX ile javada g├Ârsel aray├╝ze sahip uygulama yap─▒m─▒

├ľnemli Bilgi

  • JavaFX art─▒k JDK 12'n─▒n bir par├žas─▒ de─čildir, buradan gerekli bilgilere eri┼čebilirsin.

  • Java SDK 8 ile depoy edebilmektesin

    • Deploy etme hususunda bilgi almak i├žin buraya bakabilirsin

IntelliJ i├žin JavaFx Kurulumu

JavaFX ve JFhoenix Material UI'─▒ kurulumunu anlatan videom i├žin buraya bakabilrisin ­čĺüÔÇŹÔÖé´ŞĆ

  • ─░lk olarak IntelliJ'yi indirin

  • Resmi sitesinden JavaFX SDK's─▒n─▒ indirin

  • ─░ndirdi─činiz ar┼čivdeki ├ž─▒kart─▒n

  • Ar┼čivdeki javafx-sdk-12.0.1 dosyas─▒n─▒ C:\Program Files\Java dizinine ta┼č─▒y─▒n

  • GUI d├╝zenleme arac─▒ olan Scene Builder'─▒ indirin

  • IntelliJ ├╝zerinden File - Settings - Languages & Frameworks - JavaFx k─▒sm─▒na Scene Builder'─▒n yolunu yaz─▒n.

    • ├ľrn: C:\Program Files\SceneBuilder\SceneBuilder.exe

  • IntelliJ ├╝zerinden File - New - Project - JavaFX - Next - Finish ile projenizi olu┼čturun

  • Son olarak File - Project Structure - Modules

  • A├ž─▒lan ekranda + - Library - Java

  • ├ç─▒kan ekran ile C:\Program Files\Java\javafx-sdk-12.0.1\lib k├╝t├╝phanesini ekleyin

  • Run - Edit Configurations

  • ├ç─▒kan ekranda VM Opitons alan─▒na alttaki metni kopyalay─▒n:

    • --module-path "C:\Program Files\Java\javafx-sdk-12.0.1\lib" --add-modules=javafx.controls,javafx.fxml

  • Art─▒k .fxml uzant─▒l─▒ dosyalarda ekran─▒n sol alt k├Â┼česinden Scene Builder'a t─▒klayarak GUI programlamaya ba┼člayabilirsiniz ÔťĘ

Not sizin s├╝r├╝m├╝n├╝z ve yolunuz farkl─▒ ise ona g├Âre ayalay─▒n <yol>\javafx-sdk-<version>\lib

Maven ile Mod├╝ler JavaFX Kurulumu

Anlat─▒c─▒ video i├žin buraya bakabilrisin

pom.xml i├žeri─či

Maven xml verilerini, pom.xml dosyas─▒nda ge├Âsterilen alana yap─▒┼čt─▒r─▒n.

  • TODO alanlar─▒n─▒ d├╝zenlemeyi unutmay─▒n

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
ÔÇő
<groupId>com.yemreak</groupId> <!-- TODO: Kodlar─▒n bulundu─ču ana package ismi-->
<artifactId>ytoolsfx</artifactId> <!-- TODO: Mod├╝l ismi -->
<version>1.0.0</version> <!-- TODO: S├╝r├╝m numaras─▒ -->
ÔÇő
<!-- Buraya yap─▒┼čt─▒r─▒lacak -->
ÔÇő
</project>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>12</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>12</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<release>12</release>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.openjfx</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>0.0.2</version>
<configuration>
<release>12</release>
<jlinkImageName>ytoolsfx</jlinkImageName> <!-- TODO: Mod├╝l ismi -->
<launcher>launcher</launcher>
<mainClass>ytoolsfx/com.yedhrab.applications.MainApp</mainClass> <!-- TODO: Main class─▒n─▒n yolu -->
</configuration>
</plugin>
</plugins>
</build>

Maven ile Ba┼člang─▒├ž Yap─▒land─▒rmas─▒

Ôçž Shift + F10 ile projeyi ├žal─▒┼čt─▒rman─▒z─▒ sa─člar

  • Edit Configuration + + + maven

  • Command Line alan─▒na javafx:run yaz─▒n

  • Before launch: Activate Tool Windov alan─▒n─▒ndaki + butonuna t─▒klay─▒n

  • Run maven goal'─▒ se├žin

  • javafx:compile yaz─▒p kaydedin

Ana kaynak JavaFX and IntelliJ Moduler with Maven yaz─▒s─▒d─▒r.

  • Project Structures - Libraries k─▒sm─▒nda + butona bas─▒n

  • ├ç─▒kan ekranda From Maven yaz─▒s─▒na t─▒klay─▒n ve org.openjfx:javafx-maven-plugin:0.0.2 yaz─▒p indirin.

JavaFX Scene Builder

  • View - Show Sample Controller Skeleton ile Controller'a yaz─▒lacak kodu g├Ârebiliriz

  • Sol alttaki alandan Controller i├žerisinde

    • Controller Class alan─▒na <package>.Controller yazarak Controller class'─▒n─▒ g├Ârmesini sa─čl─▒yoruz

  • Sol alttaki code alan─▒ndakiler Controller'a aktar─▒lacakt─▒r

  • Her importta javafx.scene olmas─▒ laz─▒md─▒r

    • Image vs..

  • Sa─č taraftaki code alan─▒ndaki fx:id k─▒sm─▒nda ismi yazacak (Controller'dan eri┼čmek i├žin)

Scene Builder Yap─▒land─▒rmas─▒

[JFoenix] framework'├╝ kullan─▒ld─▒─č─▒ndan Scene Builder'─▒n library'lerine dahil edilmesi laz─▒md─▒r.

  • Sol ├╝st k─▒s─▒mda Library sekmesinin en sa─č─▒ndaki ÔÜÖ t─▒klay─▒n

  • JAR/FXML Management - Add Library/FXML from file system linkine t─▒klay─▒n

  • ─░ndirdi─činiz [JFoenix] dosyas─▒n─▒n jar'─▒n─▒ bulup, se├žin.

  • Check All ve Built in ayarlar─▒ ile dahil edin.

FXML dosyas─▒ ile Controller vs Resimlerin ayn─▒ package i├žerisinde olmamas─▒ durumunda Scene Builder ├Âneri yapamaz ­čśó

JavaFX RunTime Images

export PATH_TO_FX_MODS=path/to/javafx-jmods-12.0.1
$JAVA_HOME/bin/jlink --module-path $PATH_TO_FX_MODS:mods/production --add-modules hellofx --output jre
jre/bin/java -m hellofx/org.openjfx.MainApp

Hata Notlar─▒

class com.sun.javafx.fxml.FXMLLoaderHelper (in unnamed module @0x24782c87) cannot access class com.sun.javafx.util.Utils (in module javafx.graphics) because module javafx.graphics:

  • ├ç─▒kan ekranda VM Opitons alan─▒na alttaki metni kopyalay─▒n:

    • --module-path "C:\Program Files\Java\javafx-sdk-12.0.1\lib" --add-modules=javafx.controls,javafx.fxml

Error: Java FX Packager: Can not build artifact - fx: deploy is not available in this JDK

  • IntelliJ ├╝zerinde java ile gelen fx:deploy ├Âzelli─či kald─▒r─▒lm─▒┼čt─▒r (java 11+)

  • Bu y├╝zden buradan veya jpackage ├╝zerinden kurulumlara bakabilirsin

Error:Kotlin: The Kotlin standard library is not found in the module graph. Please ensure you have the 'requires kotlin.stdlib' clause in your module definition

Projeyi Build sekmesinden Rebuild Edin tekrar deneyin.

** has been compiled by a more recent version of Java Runtime(class file version 56.0), this version of Java Runtime only recognizes class file versions up to 52.0

  • Jar dosyalar─▒n─▒ Java 12 JVM ile ├žal─▒┼čt─▒rmaman─▒zdan kaynaklan─▒r

  • Java 12 derleyicisi target 12, bytecode 56 de─čerlerine sahiptir

  • Java 8 bytecode 52 de─čerine sahiptir

  • Bir yerde kalm─▒┼č olan Java 8 JVM'ine sahip olabilirsiniz

That's because you're not running the jars on a Java 12 JVM. You built them with a Java 12 compiler and targeted release 12. Java 12 is bytecode version 56. 52 is Java 8. You have an old Java 8 JVM somewhere and that's what you're running.

Either run with the Java 12 java or recompile using javac --release 8 ...

(And that's not a JNI error)

ÔÇőKaynakÔÇő

Faydal─▒ Ba─člant─▒lar