Skip to content
Snippets Groups Projects
Commit 124ac497 authored by Vesa Lappalainen's avatar Vesa Lappalainen :bicyclist:
Browse files

fxexamples

parents
Branches master
No related tags found
No related merge requests found
Showing
with 454 additions and 0 deletions
##############################
## Java
##############################
.mtj.tmp/
*.class
*.jar
*.war
*.ear
*.nar
hs_err_pid*
.svn/
##############################
## Maven
##############################
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
pom.xml.next
release.properties
dependency-reduced-pom.xml
buildNumber.properties
.mvn/timing.properties
.mvn/wrapper/maven-wrapper.jar
##############################
## Gradle
##############################
bin/
build/
.gradle
.gradletasknamecache
gradle-app.setting
!gradle-wrapper.jar
##############################
## IntelliJ
##############################
out/
.idea/
.idea_modules/
*.iml
*.ipr
*.iws
##############################
## Eclipse
##############################
.settings/
bin/
tmp/
.metadata
*.tmp
*.bak
*.swp
*~.nib
local.properties
.loadpath
##############################
## NetBeans
##############################
nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml
##############################
## OS X
##############################
.DS_Store
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>FXContainers</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Containers/AnchorPaneLayout.png

6.97 KiB

<?xml version="1.0" encoding="ASCII"?>
<anttasks:AntTask xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:anttasks="http://org.eclipse.fx.ide.jdt/1.0" buildDirectory="${project}/build">
<deploy>
<application name="FXContainers"/>
<info/>
</deploy>
<signjar/>
</anttasks:AntTask>
package containers.borderPaneEx;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
/**
* Pohjelma BorderPanen esittelyyn. Mallilomake
* luodaan ohjelmallisesti
* @author vesal
* @version 24.12.2015
*/
public class BorderPaneCode extends Application {
/**
* Esimerkki miten BorderPanea kytetn ohjelmasta
*/
@Override
public void start(Stage stage) {
try {
BorderPane root = new BorderPane();
Scene scene = new Scene(root, 400, 400);
stage.setScene(scene);
stage.setTitle("BorderPane");
stage.show();
root.setLeft(CenterText("vasen", "red"));
root.setRight(CenterText("oikea", "green"));
root.setTop(CenterText("ylosa", "yellow"));
root.setBottom(CenterText("alaosa", "lightblue"));
root.setCenter(CenterText("keskiosa", "lightgray"));
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Kynnistetn sovellus
* @param args kutsun parametrit, kytt riippuu Application luokasta
*/
public static void main(String[] args) {
launch(args);
}
/**
* Luodaan Pane, jonka keskell on teksti
* @param teksti mik teksti keskelle
* @param taustavari mill vrill tausta
* @return Pane, jonka keskell on teksti
*/
public static Pane CenterText(String teksti, String taustavari) {
BorderPane bp = new BorderPane();
bp.setCenter(new Label(teksti));
bp.setStyle("-fx-background-color: " + taustavari + ";");
return bp;
}
}
package containers.borderPaneEx;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
/**
* Pohjelma BorderPanen esittelyyn. Mallilomake
* luodaan FXML-tiedostosta lukemalla.
* @author vesal
* @version 24.12.2015
*/
public class BorderPaneController extends Application {
@Override
public void start(Stage primaryStage) {
try {
Pane root = (Pane) FXMLLoader.load(getClass().getResource("BorderPaneView.fxml"));
Scene scene = new Scene(root, 400, 400);
primaryStage.setScene(scene);
primaryStage.setTitle("BorderPane");
primaryStage.show();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Kynnistetn sovellus
* @param args kutsun parametrit, kytt riippuu Application luokasta
*/
public static void main(String[] args) {
launch(args);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.text.*?>
<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.BorderPane?>
<BorderPane prefHeight="300.0" prefWidth="300.0" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
<left>
<BorderPane style="-fx-background-color: red;">
<center>
<Label text="vasen" />
</center>
</BorderPane>
</left>
<right>
<BorderPane style="-fx-background-color: green;">
<center>
<Label text="oikea" />
</center>
</BorderPane>
</right>
<bottom>
<BorderPane style="-fx-background-color: lightblue;">
<center>
<Label text="alaosa" />
</center>
</BorderPane>
</bottom>
<top>
<BorderPane style="-fx-background-color: yellow;">
<center>
<Label text="yläosa" />
</center>
</BorderPane>
</top>
<center>
<BorderPane style="-fx-background-color: lightgray;">
<center>
<Label text="keskiosa" />
</center>
</BorderPane>
</center>
</BorderPane>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>fxgui</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="ASCII"?>
<anttasks:AntTask xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:anttasks="http://org.eclipse.fx.ide.jdt/1.0" buildDirectory="${project}/build">
<deploy>
<application name="FXGUI"/>
<info/>
</deploy>
<signjar/>
</anttasks:AntTask>
<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
<jardesc>
<jar path="fxgui/fxgui.jar"/>
<options buildIfNeeded="true" compress="true" descriptionLocation="/fxgui/fxgui.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
<selectedProjects/>
<manifest generateManifest="true" manifestLocation="" manifestVersion="1.0" reuseManifest="false" saveManifest="false" usesManifest="true">
<sealing sealJar="false">
<packagesToSeal/>
<packagesToUnSeal/>
</sealing>
</manifest>
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
<file path="/fxgui/build.fxbuild"/>
<file path="/fxgui/.classpath"/>
<file path="/fxgui/.project"/>
<javaElement handleIdentifier="=fxgui/src"/>
</selectedElements>
</jardesc>
<?xml version="1.0" encoding="UTF-8"?>
<?import java.lang.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafx.scene.layout.AnchorPane?>
<fx:root type="AnchorPane" xmlns="http://javafx.com/javafx/8.0.40" xmlns:fx="http://javafx.com/fxml/1">
<!-- fx:controller="fi.jyu.mit.fxgui.sEditPanel"> -->
<children>
<Label layoutY="4.0" text="Nimi" />
<TextField fx:id="edit" promptText="kirjoita" AnchorPane.leftAnchor="60.0" AnchorPane.rightAnchor="0.0" />
</children>
</fx:root>
package fi.jyu.mit.fxgui;
import java.io.IOException;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
public class EditPanel extends AnchorPane {
private final String resourcePath = "EditPanel.fxml";
@FXML private Label label;
@FXML private TextField edit;
public EditPanel() {
/*
FXMLLoader loader = new FXMLLoader();
loader.setController(this);
URL n = this.getViewURL();
loader.setLocation(n);
try {
Node root = (Node) loader.load();
this.getChildren().add(root);
}
catch (IOException ex) {
throw new RuntimeException(ex);
}
*/
super();
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource(resourcePath));
fxmlLoader.setRoot(this);
fxmlLoader.setController(this);
try {
fxmlLoader.load();
} catch (IOException exception) {
throw new RuntimeException(exception);
}
}
public String getText() {
return edit.getText();
}
public void setText(String t) {
edit.setText(t);
}
public TextField getEdit() {
return edit;
}
public void setEdit(TextField edit) {
this.edit = edit;
}
public double getLabelWidth() {
return AnchorPane.getLeftAnchor(edit);
}
public void setLabelWidth(double w) {
AnchorPane.setLeftAnchor(edit,w);
}
}
package fi.jyu.mit.fxgui;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
@Override
public void start(Stage stage) throws Exception {
EditPanel customControl = new EditPanel();
customControl.setText("Hello!");
stage.setScene(new Scene(customControl));
stage.setTitle("Custom Control");
stage.setWidth(300);
stage.setHeight(100);
stage.show();
}
public static void main(String[] args) {
launch(args);
}
}
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
\ No newline at end of file
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.fx.ide.jdt.core.JAVAFX_CONTAINER"/>
<classpathentry combineaccessrules="false" kind="src" path="/FXGui"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Examples</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
Examples/NimiJaVuosi.png

7.81 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment