-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zonski
authored and
zonski
committed
Nov 4, 2012
1 parent
5b1087b
commit c2de86b
Showing
7 changed files
with
255 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?xml version="1.0"?> | ||
<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.zenjava</groupId> | ||
<artifactId>hello-javafx-maven-example</artifactId> | ||
<name>JavaFX Example Maven Project</name> | ||
|
||
<packaging>jar</packaging> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<slf4j.version>1.6.1</slf4j.version> | ||
</properties> | ||
|
||
<pluginRepositories> | ||
<pluginRepository> | ||
<id>zen-java</id> | ||
<name>Zen Java Maven Repo</name> | ||
<url>http://zenjava.com/maven-repo/</url> | ||
</pluginRepository> | ||
</pluginRepositories> | ||
|
||
<build> | ||
<plugins> | ||
|
||
<plugin> | ||
<groupId>com.zenjava</groupId> | ||
<artifactId>javafx-maven-plugin</artifactId> | ||
<version>1.1</version> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>package</goal> | ||
</goals> | ||
</execution> | ||
</executions> | ||
<configuration> | ||
<mainClass>com.zenjava.examples.hellojfxmaven.HelloJavaFxAndMavenApp</mainClass> | ||
<bundleType>ALL</bundleType> | ||
</configuration> | ||
</plugin> | ||
|
||
</plugins> | ||
</build> | ||
|
||
|
||
<dependencies> | ||
|
||
<!-- MigLayout --> | ||
|
||
<dependency> | ||
<groupId>com.miglayout</groupId> | ||
<artifactId>miglayout-javafx</artifactId> | ||
<version>4.2</version> | ||
</dependency> | ||
|
||
<!-- Apache Commons --> | ||
|
||
<dependency> | ||
<groupId>commons-lang</groupId> | ||
<artifactId>commons-lang</artifactId> | ||
<version>2.6</version> | ||
</dependency> | ||
|
||
<!-- Logging --> | ||
|
||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-api</artifactId> | ||
<version>${slf4j.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>jcl-over-slf4j</artifactId> | ||
<version>${slf4j.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.slf4j</groupId> | ||
<artifactId>slf4j-log4j12</artifactId> | ||
<version>${slf4j.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>log4j</groupId> | ||
<artifactId>log4j</artifactId> | ||
<version>1.2.16</version> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |
46 changes: 46 additions & 0 deletions
46
src/main/java/com/zenjava/examples/hellojfxmaven/HelloController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.zenjava.examples.hellojfxmaven; | ||
|
||
import javafx.fxml.FXML; | ||
import javafx.scene.control.Label; | ||
import javafx.scene.control.TextField; | ||
import org.apache.commons.lang.StringUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class HelloController | ||
{ | ||
private static final Logger log = LoggerFactory.getLogger(HelloController.class); | ||
|
||
@FXML private TextField firstNameField; | ||
@FXML private TextField lastNameField; | ||
@FXML private Label messageLabel; | ||
|
||
public void sayHello() { | ||
|
||
String firstName = firstNameField.getText(); | ||
String lastName = lastNameField.getText(); | ||
|
||
StringBuilder builder = new StringBuilder(); | ||
|
||
if (!StringUtils.isEmpty(firstName)) { | ||
builder.append(firstName); | ||
} | ||
|
||
if (!StringUtils.isEmpty(lastName)) { | ||
if (builder.length() > 0) { | ||
builder.append(" "); | ||
} | ||
builder.append(lastName); | ||
} | ||
|
||
if (builder.length() > 0) { | ||
String name = builder.toString(); | ||
log.debug("Saying hello to " + name); | ||
messageLabel.setText("Hello " + name); | ||
} else { | ||
log.debug("Neither first name nor last name was set, saying hello to anonymous person"); | ||
messageLabel.setText("Hello mysterious person"); | ||
} | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/com/zenjava/examples/hellojfxmaven/HelloJavaFxAndMavenApp.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.zenjava.examples.hellojfxmaven; | ||
|
||
import javafx.application.Application; | ||
import javafx.fxml.FXMLLoader; | ||
import javafx.scene.Parent; | ||
import javafx.scene.Scene; | ||
import javafx.stage.Stage; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class HelloJavaFxAndMavenApp extends Application { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(HelloJavaFxAndMavenApp.class); | ||
|
||
public static void main(String[] args) throws Exception { | ||
launch(args); | ||
} | ||
|
||
public void start(Stage stage) throws Exception { | ||
|
||
log.info("Starting Hello JavaFX and Maven demonstration application"); | ||
|
||
String fxmlFile = "/fxml/hello.fxml"; | ||
log.debug("Loading FXML for main view from: {}", fxmlFile); | ||
FXMLLoader loader = new FXMLLoader(); | ||
Parent rootNode = (Parent) loader.load(getClass().getResourceAsStream(fxmlFile)); | ||
|
||
log.debug("Showing JFX scene"); | ||
Scene scene = new Scene(rootNode, 400, 200); | ||
scene.getStylesheets().add("/styles/styles.css"); | ||
|
||
stage.setTitle("Hello JavaFX and Maven"); | ||
stage.setScene(scene); | ||
stage.show(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<?import java.lang.*?> | ||
<?import javafx.scene.*?> | ||
<?import javafx.scene.control.*?> | ||
<?import org.tbee.javafx.scene.layout.fxml.MigPane?> | ||
<?import layouttests.migfxml.sample1.*?> | ||
|
||
<MigPane id="rootPane" fx:controller="com.zenjava.examples.hellojfxmaven.HelloController" | ||
styleClass="main-panel" | ||
layout="insets 20" | ||
cols="[label, pref!][grow, 50::]" | ||
rows="" | ||
xmlns:fx="http://javafx.com/fxml"> | ||
|
||
<Label text="First Name:" /> <TextField fx:id="firstNameField" prefColumnCount="30" MigPane.cc="growx, wrap" /> | ||
<Label text="Last Name:" /> <TextField fx:id="lastNameField" prefColumnCount="30" MigPane.cc="growx, wrap" /> | ||
|
||
<Button text="Say Hello" onAction="#sayHello" MigPane.cc="skip, gap :push, gaptop 15, wrap" /> | ||
|
||
<Label fx:id="messageLabel" styleClass="hello-message" MigPane.cc="span, growx, gaptop 15" /> | ||
|
||
</MigPane > |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8" ?> | ||
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> | ||
|
||
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"> | ||
|
||
<appender name="console" class="org.apache.log4j.ConsoleAppender"> | ||
<param name="Target" value="System.out"/> | ||
<layout class="org.apache.log4j.PatternLayout"> | ||
<param name="ConversionPattern" value="%-5p %c{1} - %m%n"/> | ||
</layout> | ||
</appender> | ||
|
||
<logger name="com.zenjava.examples"> | ||
<level value="DEBUG"/> | ||
</logger> | ||
|
||
<root> | ||
<priority value ="WARN" /> | ||
<appender-ref ref="console" /> | ||
</root> | ||
|
||
</log4j:configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* Application wide styles */ | ||
|
||
.label { | ||
-fx-font-size: 12px; | ||
-fx-font-weight: bold; | ||
-fx-text-fill: #333333; | ||
-fx-effect: dropshadow( gaussian , rgba(255,255,255,0.5) , 0,0,0,1 ); | ||
} | ||
|
||
.button { | ||
-fx-text-fill: white; | ||
-fx-font-family: "Arial Narrow"; | ||
-fx-font-weight: bold; | ||
-fx-background-color: linear-gradient(#61a2b1, #2A5058); | ||
-fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0 , 1 ); | ||
} | ||
|
||
.button:hover{ | ||
-fx-base: #395bae; | ||
} | ||
|
||
/* Component specific styles */ | ||
|
||
|
||
.main-panel { | ||
-fx-background-image: url("../images/background.jpg"); | ||
} | ||
|
||
.hello-message { | ||
-fx-text-fill: #AA0000; | ||
-fx-font-weight: bold; | ||
-fx-effect: dropshadow( gaussian , rgba(255,255,255,0.5) , 0,0,0,1 ); | ||
} | ||
|