2021-08-15

This commit is contained in:
2021-08-15 00:35:53 +09:00
parent eeae8f2806
commit 62360c41a3
10 changed files with 216 additions and 3 deletions

View File

@@ -22,8 +22,8 @@ repositories {
java {
withSourcesJar()
withJavadocJar()
sourceCompatibility = org.gradle.api.JavaVersion.VERSION_1_8
targetCompatibility = org.gradle.api.JavaVersion.VERSION_1_8
sourceCompatibility = org.gradle.api.JavaVersion.VERSION_11
targetCompatibility = org.gradle.api.JavaVersion.VERSION_11
}
configurations {

25
java-fx/build.gradle.kts Normal file
View File

@@ -0,0 +1,25 @@
/*
* Examples for Java
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
plugins {
id("elex-java")
id("application")
id("org.openjfx.javafxplugin") version "0.0.10"
id("org.beryx.jlink") version "2.23.1"
}
application {
mainClass.set("kr.pe.elex.examples.FxmlApplication")
mainModule.set("kr.pe.elex.examples")
}
javafx {
version = "11.0.2"
modules = listOf("javafx.controls", "javafx.fxml")
}
dependencies {
//implementation("org.openjfx:javafx-controls:11.0.2")
//implementation("org.openjfx:javafx-fxml:11.0.2")
}

20
java-fx/logback.xml Normal file
View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Examples for Java
~
~ Copyright (c) 2021. Elex. All Rights Reserved.
~ https://www.elex-project.com/
-->
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="TRACE">
<appender-ref ref="CONSOLE" />
</root>
</configuration>

View File

@@ -0,0 +1,33 @@
/*
* Examples for Java
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package kr.pe.elex.examples;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
public class FxmlApplication extends Application {
public static void main(String... args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setTitle("Hello!");
primaryStage.setWidth(800);
primaryStage.setHeight(600);
//GridPane root = new GridPane();
Parent root = FXMLLoader.load(getClass().getResource ("/fxml/root.fxml"));
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
}

View File

@@ -0,0 +1,6 @@
module kr.pe.elex.examples {
requires javafx.graphics;
requires javafx.fxml;
exports kr.pe.elex.examples;
}

View File

@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<!--
~ Examples for Java
~
~ Copyright (c) 2021. Elex. All Rights Reserved.
~ https://www.elex-project.com/
-->
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/11.0.2" xmlns:fx="http://javafx.com/fxml/1">
<center>
<Button mnemonicParsing="false" text="Button" BorderPane.alignment="CENTER" />
</center>
<bottom>
</bottom>
<top>
<MenuBar BorderPane.alignment="CENTER">
<menus>
<Menu mnemonicParsing="false" text="File">
<items>
<MenuItem mnemonicParsing="false" text="Close" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Edit">
<items>
<MenuItem mnemonicParsing="false" text="Delete" />
</items>
</Menu>
<Menu mnemonicParsing="false" text="Help">
<items>
<MenuItem mnemonicParsing="false" text="About" />
</items>
</Menu>
</menus>
</MenuBar>
</top>
</BorderPane>

View File

@@ -12,5 +12,6 @@ include(
"ssh",
"web-socket-servlet", "web-socket-client",
"thread", "hibernate", "jdbc-sqlite",
"xml", "jackson", "jsoup", "markdown", "network", "httpd"
"xml", "jackson", "jsoup", "markdown", "network", "httpd",
"swing", "java-fx"
)

14
swing/build.gradle.kts Normal file
View File

@@ -0,0 +1,14 @@
/*
* Examples for Java
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
plugins {
id("elex-java")
}
dependencies {
}

20
swing/logback.xml Normal file
View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Examples for Java
~
~ Copyright (c) 2021. Elex. All Rights Reserved.
~ https://www.elex-project.com/
-->
<configuration>
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
</encoder>
</appender>
<root level="TRACE">
<appender-ref ref="CONSOLE" />
</root>
</configuration>

View File

@@ -0,0 +1,53 @@
/*
* Examples for Java
*
* Copyright (c) 2021. Elex. All Rights Reserved.
* https://www.elex-project.com/
*/
package kr.pe.elex.examples;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpServer;
import lombok.extern.slf4j.Slf4j;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.time.LocalDateTime;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Slf4j
public class HttpD {
public static void main(String... args) throws IOException {
final ExecutorService threadPool = Executors.newCachedThreadPool();
HttpServer httpServer = HttpServer.create(new InetSocketAddress(18080), 0);
httpServer.setExecutor(threadPool);
httpServer.createContext("/", new HttpHandler() {
@Override
public void handle(final HttpExchange httpExchange) {
try {
httpExchange.getResponseHeaders().add("X-Datetime", LocalDateTime.now().toString());
String message = "<html><body><h1>Hello, world!</h1></body></html>";
//message += httpExchange.getRequestMethod();
//BufferedReader reader = new BufferedReader(new InputStreamReader(httpExchange.getRequestBody()));
//message += reader.readLine();
httpExchange.sendResponseHeaders(200, message.getBytes().length);
OutputStream os = httpExchange.getResponseBody();
os.write(message.getBytes());
os.flush();
os.close();
} catch (IOException e) {
}
}
});
httpServer.start();
}
}