Skip to content

Commit 66ca7da

Browse files
committed
fdg
0 parents  commit 66ca7da

13 files changed

+365
-0
lines changed

Diff for: .classpath

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src"/>
4+
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
5+
<classpathentry kind="con" path="at.bestsolution.efxclipse.tooling.jdt.core.JAVAFX_CONTAINER"/>
6+
<classpathentry kind="output" path="bin"/>
7+
</classpath>

Diff for: .project

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>JavaFX-Exercises</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.xtext.ui.shared.xtextBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.xtext.ui.shared.xtextNature</nature>
21+
<nature>org.eclipse.jdt.core.javanature</nature>
22+
</natures>
23+
</projectDescription>

Diff for: README.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
JavaFX
2+
================
3+
4+
Java FX Exercises

Diff for: build.fxbuild

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<anttasks:AntTask xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:anttasks="http://at.bestsolution.efxclipse.tooling.jdt/1.0" buildDirectory="${project}/">
3+
<deploy>
4+
<application name="JavaFX-Exercises" mainclass="malc.Main" version="Version 1"/>
5+
<info vendor="John Malc"/>
6+
</deploy>
7+
<signjar/>
8+
</anttasks:AntTask>

Diff for: src/malc/Main.java

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package malc;
2+
3+
import java.io.IOException;
4+
5+
import javafx.application.Application;
6+
import javafx.stage.Stage;
7+
import javafx.scene.Group;
8+
import javafx.scene.Scene;
9+
import javafx.scene.paint.Color;
10+
import javafx.scene.shape.Ellipse;
11+
12+
public class Main extends Application {
13+
14+
@Override
15+
public void start(Stage primaryStage) throws IOException {
16+
Group root = new Group();
17+
// describes the window itself: name, size
18+
primaryStage.setTitle(" Aufgabe 10 by John Malc ");
19+
primaryStage.setScene(new Scene(root));
20+
// say: center on screen, user can resize, and it will in general exists
21+
primaryStage.centerOnScreen();
22+
primaryStage.setResizable(true);
23+
primaryStage.show();
24+
25+
// Ellipse alone
26+
Ellipse a = new Ellipse();
27+
a.setFill(Color.RED);
28+
a.setCenterX(205);
29+
a.setCenterY(150);
30+
a.setRadiusX(80);
31+
a.setRadiusY(30);
32+
33+
// shows Ellipse and it will add it to the group
34+
root.getChildren().add(new Group(a));
35+
}
36+
37+
public static void main(String[] args) {
38+
launch(args);
39+
}
40+
}

Diff for: src/malc/layout.fxml

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import java.lang.*?>
4+
<?import java.util.*?>
5+
<?import javafx.scene.control.*?>
6+
<?import javafx.scene.layout.*?>
7+
<?import javafx.scene.paint.*?>
8+
<?import javafx.scene.shape.*?>
9+
<?import javafx.scene.web.*?>
10+
11+
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="442.0" prefWidth="654.0" xmlns:fx="http://javafx.com/fxml">
12+
<children>
13+
<TabPane layoutX="100.0" layoutY="48.0" prefHeight="200.0" prefWidth="200.0" tabClosingPolicy="UNAVAILABLE" />
14+
<TitledPane alignment="CENTER" animated="true" blendMode="SRC_OVER" layoutX="2.0" layoutY="0.0" text="Pane">
15+
<content>
16+
<AnchorPane id="Content" minHeight="0.0" minWidth="0.0" prefHeight="180.0" prefWidth="200.0">
17+
<children>
18+
<Polygon fill="#009918" layoutX="108.0" layoutY="94.0" stroke="BLACK" strokeType="OUTSIDE">
19+
<points>
20+
<Double fx:value="-50.0" />
21+
<Double fx:value="40.0" />
22+
<Double fx:value="50.0" />
23+
<Double fx:value="40.0" />
24+
<Double fx:value="0.0" />
25+
<Double fx:value="-60.0" />
26+
</points>
27+
</Polygon>
28+
</children>
29+
</AnchorPane>
30+
</content>
31+
</TitledPane>
32+
<ToolBar layoutX="300.0" layoutY="347.0">
33+
<items>
34+
<Button mnemonicParsing="false" text="ok" />
35+
</items>
36+
</ToolBar>
37+
<CheckBox layoutX="135.0" layoutY="331.0" mnemonicParsing="false" text="CheckBox" />
38+
<HTMLEditor htmlText="&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body contenteditable=&quot;true&quot;&gt;&lt;/body&gt;&lt;/html&gt;" layoutX="150.0" layoutY="78.0" prefHeight="200.0" prefWidth="500.0" />
39+
<Pane layoutX="0.0" layoutY="221.0" prefHeight="200.0" prefWidth="200.0" />
40+
</children>
41+
</AnchorPane>

Diff for: src/malc2/Main.java

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
package malc2;
2+
3+
import java.io.IOException;
4+
import java.net.MalformedURLException;
5+
6+
import javafx.application.Application;
7+
import javafx.fxml.FXMLLoader;
8+
import javafx.scene.Group;
9+
import javafx.scene.Parent;
10+
import javafx.scene.Scene;
11+
import javafx.scene.control.Button;
12+
import javafx.scene.control.ListView;
13+
import javafx.scene.control.TextArea;
14+
import javafx.scene.text.Text;
15+
import javafx.stage.Stage;
16+
17+
public class Main extends Application {
18+
19+
/*
20+
* Display text from a method, Whether a webpage is 404 - yes or not
21+
* (non-Javadoc) taken from
22+
* http://java-buddy.blogspot.de/2012/01/javafx-exercise
23+
* -display-text-on-scene.html
24+
*
25+
* @see javafx.application.Application#start(javafx.stage.Stage)
26+
*/
27+
28+
@Override
29+
public void start(Stage primaryStage) throws MalformedURLException,
30+
IOException {
31+
32+
Button bu1;
33+
34+
TextArea textArea1;
35+
36+
ListView list1;
37+
38+
Parent root = FXMLLoader.load(getClass().getResource("UI.fxml"));
39+
40+
Methods cl = new Methods();
41+
String sit = "http://www.google.com/";
42+
// int ado = cl.getResponseCode(sit);
43+
String bobob = cl.getImp(cl.getResponseCode(sit)); // then ado
44+
45+
Text t = new Text(10, 20, bobob);
46+
47+
Group ab = new Group(t, root);
48+
Scene sc = new Scene(ab, 600, 300);
49+
50+
primaryStage.setScene(sc);
51+
primaryStage.setTitle("Maly Test");
52+
primaryStage.setResizable(true);
53+
primaryStage.centerOnScreen();
54+
primaryStage.show();
55+
56+
}
57+
58+
public static void main(String[] args) {
59+
launch(args);
60+
}
61+
62+
}

Diff for: src/malc2/Methods.java

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package malc2;
2+
3+
import java.io.IOException;
4+
import java.net.HttpURLConnection;
5+
import java.net.MalformedURLException;
6+
import java.net.URL;
7+
8+
public class Methods {
9+
// http://stackoverflow.com/questions/1378199/how-to-check-if-a-url-exists-or-returns-404-with-java
10+
public int getResponseCode(String sit) throws MalformedURLException,
11+
IOException {
12+
URL u = new URL(sit);
13+
HttpURLConnection huc = (HttpURLConnection) u.openConnection();
14+
huc.setRequestMethod("HEAD");
15+
huc.connect();
16+
return huc.getResponseCode();
17+
}
18+
19+
public String getImp(int papa) {
20+
if (papa == 404) {
21+
return "wrong";
22+
} else {
23+
return "good";
24+
}
25+
}
26+
27+
}

Diff for: src/malc2/UI.fxml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import java.lang.*?>
4+
<?import java.util.*?>
5+
<?import javafx.scene.control.*?>
6+
<?import javafx.scene.layout.*?>
7+
<?import javafx.scene.paint.*?>
8+
9+
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml">
10+
<children>
11+
<TextArea fx:id="textArea1" blendMode="DARKEN" cache="false" layoutX="312.0" layoutY="86.0" prefWidth="200.0" promptText="" text="&#10;" wrapText="true" />
12+
<Button fx:id="Bu1" cancelButton="true" defaultButton="true" layoutX="312.0" layoutY="279.0" mnemonicParsing="false" text="Button" />
13+
<ListView fx:id="List1" layoutX="30.0" layoutY="56.0" orientation="VERTICAL" prefHeight="200.0" prefWidth="200.0" />
14+
</children>
15+
</AnchorPane>

Diff for: src/malc3/DemoShowHide.java

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package malc3;
2+
3+
import javafx.application.Application;
4+
import javafx.fxml.FXMLLoader;
5+
import javafx.scene.Parent;
6+
import javafx.scene.Scene;
7+
import javafx.stage.Stage;
8+
9+
/**
10+
* http://www.e-zest.net/blog/javafx-2-x-development-using-fxml/
11+
* @author amol.hingmire
12+
*/
13+
public class DemoShowHide extends Application {
14+
15+
private Stage stage;
16+
17+
public static void main(String[] args) {
18+
Application.launch(args);
19+
}
20+
21+
@Override
22+
public void start(Stage mainStage) throws Exception {
23+
stage = mainStage;
24+
Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml")); // zde proste jenom zmenit na TextArea
25+
Scene scene = stage.getScene();
26+
if (scene == null) {
27+
scene = new Scene(root);
28+
stage.setScene(scene);
29+
} else {
30+
stage.getScene().setRoot(root);
31+
}
32+
stage.sizeToScene();
33+
stage.show();
34+
}
35+
36+
public Stage getStage() {
37+
return stage;
38+
}
39+
40+
}

Diff for: src/malc3/Sample.fxml

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import java.lang.*?>
4+
<?import java.util.*?>
5+
<?import javafx.geometry.*?>
6+
<?import javafx.scene.control.*?>
7+
<?import javafx.scene.effect.*?>
8+
<?import javafx.scene.image.*?>
9+
<?import javafx.scene.layout.*?>
10+
<?import javafx.scene.paint.*?>
11+
<?import javafx.scene.shape.*?>
12+
13+
<AnchorPane id="AnchorPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" prefWidth="600.0" xmlns:fx="http://javafx.com/fxml" fx:controller="malc3.Sample">
14+
<children>
15+
<StackPane id="stackPane1" fx:id="parentStack" layoutX="68.0" layoutY="193.0" prefHeight="147.0" prefWidth="419.0">
16+
<children>
17+
<fx:include source="TextArea.fxml" />
18+
<TreeView id="treeView" fx:id="tree" prefHeight="200.0" prefWidth="200.0" visible="false">
19+
<TreeItem value="Case Full Name">
20+
<children>
21+
<TreeItem>
22+
<value>
23+
<CheckBox id="checkBox1" prefWidth="180.0" text="ONE" />
24+
</value>
25+
</TreeItem>
26+
<TreeItem>
27+
<value>
28+
<CheckBox id="checkBox2" prefWidth="180.0" text="TWO" />
29+
</value>
30+
</TreeItem>
31+
<TreeItem>
32+
<value>
33+
<CheckBox id="checkBox3" prefWidth="180.0" text="THREE" />
34+
</value>
35+
</TreeItem>
36+
</children>
37+
</TreeItem>
38+
</TreeView>
39+
</children>
40+
</StackPane>
41+
<HBox id="hBox1" layoutX="102.0" layoutY="36.0" prefHeight="37.0" prefWidth="343.0" spacing="30.0">
42+
<children>
43+
<Button id="areaBtn" onAction="#loadTextArea" text="SHOW TEXT AREA" />
44+
<Button id="treeBtn" onAction="#loadTree" text="SHOW TREE VIEW" />
45+
</children>
46+
</HBox>
47+
</children>
48+
</AnchorPane>

Diff for: src/malc3/Sample.java

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
package malc3;
2+
3+
import java.net.URL;
4+
import java.util.ResourceBundle;
5+
6+
import javafx.event.ActionEvent;
7+
import javafx.fxml.FXML;
8+
import javafx.fxml.Initializable;
9+
import javafx.scene.control.TextArea;
10+
import javafx.scene.control.TreeView;
11+
import javafx.scene.layout.StackPane;
12+
13+
/**
14+
*
15+
* @author amol.hingmire
16+
*/
17+
public class Sample implements Initializable {
18+
19+
@FXML
20+
private TreeView tree;
21+
@FXML
22+
private TextArea area;
23+
@FXML
24+
private StackPane parentStack;
25+
26+
@FXML
27+
private void loadTree(ActionEvent event) {
28+
tree.setVisible(true);
29+
area.setVisible(false);
30+
}
31+
32+
@FXML
33+
private void loadTextArea(ActionEvent event) {
34+
area.setVisible(true);
35+
tree.setVisible(false);
36+
}
37+
38+
@Override
39+
public void initialize(URL url, ResourceBundle rb) {
40+
area = (TextArea) parentStack.lookup("#textArea");
41+
}
42+
}

Diff for: src/malc3/TextArea.fxml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<?import java.lang.*?>
4+
<?import javafx.scene.*?>
5+
<?import javafx.scene.control.*?>
6+
<?import javafx.scene.layout.*?>
7+
8+
<TextArea id="textArea" xmlns:fx="http://javafx.com/fxml" fx:id="area" prefWidth="200.0" text="This is demo application ....text area control..." wrapText="true" />

0 commit comments

Comments
 (0)