Programming Tasks
Programming Tasks
Programming Tasks
/*
*/
package javafxapplication1;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.BorderPane;
import javafx.stage.Stage;
/**
* @author ammar---
*/
int i =0;
@Override
"images/image4.jpg"};
imgview.setFitHeight(650);
root.setCenter(imgview);
@Override
try {
while (true) {
Thread.sleep(1000);
imgview.setImage(new Image(arr[i]));
i++;
System.out.println("i = "+i);
if(i==4){
i=0;
});
primaryStage.setTitle("CR7!");
primaryStage.setScene(scene);
primaryStage.show();
t.start();
}
/**
*/
//
//y.bind(x.add(5));
//
//x.setValue(10.0);
launch(args);
}
TASK2
/*
*/
package javafxapplication2;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
/**
* @author ammar---
*/
int i = 0;
@Override
center.getChildren().add(text);
center.setStyle("-fx-border-color: black");
top.setPadding(new Insets(15));
top.getChildren().addAll(label1, textField);
top.setAlignment(Pos.CENTER);
radioButton1.setToggleGroup(toggleGroup);
radioButton2.setToggleGroup(toggleGroup);
radioButton3.setToggleGroup(toggleGroup);
left.setVgap(8);
left.setPadding(new Insets(10));
comboBox.getItems().add(10);
comboBox.getItems().add(12);
comboBox.getItems().add(14);
comboBox.getItems().add(16);
comboBox.getItems().add(18);
comboBox.getItems().add(20);
comboBox.setValue(10);
right.setPadding(new Insets(15));
bottom.setPadding(new Insets(15));
bottom.getChildren().addAll(button1, button2);
bottom.setAlignment(Pos.CENTER);
borderPane.setTop(top);
borderPane.setLeft(left);
borderPane.setRight(right);
borderPane.setBottom(bottom);
borderPane.setCenter(center);
button1.setOnAction(e -> {
text.setX(text.getX() - 10);
});
button2.setOnAction(e -> {
text.setX(text.getX() + 10);
});
textField.setOnAction(e -> {
text.setText(textField.getText());
});
radioButton1.setOnAction(e -> {
text.setFill(Color.RED);
});
radioButton2.setOnAction(e -> {
text.setFill(Color.GREEN);
});
radioButton3.setOnAction(e -> {
text.setFill(Color.BLUE);
});
checkBox1.setOnAction(e -> {
FontPosture.ITALIC, comboBox.getValue()));
FontPosture.REGULAR, comboBox.getValue()));
FontPosture.ITALIC, comboBox.getValue()));
FontPosture.REGULAR, comboBox.getValue()));
});
checkBox2.setOnAction(e -> {
FontPosture.ITALIC, comboBox.getValue()));
FontPosture.REGULAR, comboBox.getValue()));
FontPosture.ITALIC, comboBox.getValue()));
FontPosture.REGULAR, comboBox.getValue()));
});
primaryStage.setTitle("Example 1");
primaryStage.setScene(scene);
primaryStage.show();
}
/**
*/
//
//y.bind(x.add(5));
//
//x.setValue(10.0);
launch(args);
}
TASK3
/*
*/
package task3;
import java.io.IOException;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
/**
*
* @author ammar---
*/
@Override
primaryStage.setScene(scene);
primaryStage.show();
/**
*/
launch(args);
CONTROLLER.JAVA
package task3;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
@FXML
@FXML
count++;
@Override
// TODO
}
TASK4
/*
*/
package task4;
import java.io.*;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
import javax.swing.JOptionPane;
/**
* @author ammar---
*/
@Override
pane.setVgap(10);
pane.setHgap(10);
pane.setPadding(new Insets(20));
pane.add(l1, 0, 0);
pane.add(tf1, 1, 0);
pane.add(l2, 0, 1);
pane.add(tf2, 1, 1);
pane.add(l3, 0, 2);
pane.add(tf3, 1, 2);
pane.add(b1, 0, 3);
pane.add(b2, 1, 3);
pane.setAlignment(Pos.CENTER);
try {
file.close();
} finally {
try {
file.close();
});
b2.setOnAction((ActionEvent event) -> {
tf1.setText("");
tf2.setText("");
tf3.setText("");
});
primaryStage.setTitle("Ammar yasser");
primaryStage.setScene(scene);
primaryStage.show();
launch(args);
}
TASK5
/*
*/
package circledraw;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.shape.Arc;
import javafx.scene.shape.ArcType;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Ellipse;
import javafx.scene.shape.Polygon;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;
/**
* @author ammar---
*/
@Override
circle.setFill(Color.WHITE);
circle.setStroke(Color.BLACK);
circle.setStrokeWidth(10);
root.getChildren().add(circle);
//ellipse
elps.setCenterX(180);
elps.setCenterY(200);
elps.setRadiusX(100);
elps.setRadiusY(40);
elps.setFill(Color.BLUE);
root.getChildren().add(elps);
//
Ellipse elps2=new Ellipse();
elps2.setCenterX(420);
elps2.setCenterY(200);
elps2.setRadiusX(100);
elps2.setRadiusY(40);
elps2.setFill(Color.BLUE);
root.getChildren().add(elps2);
//
190,330,
410,330);
root.getChildren().add(polygon);
arc.setCenterX(200);
arc.setCenterY(400);
arc.setRadiusX(200);
arc.setRadiusY(100);
arc.setLength(40);
arc.setFill(Color.BLACK);
arc.setStartAngle(300);
arc.setType(ArcType.ROUND);
root.getChildren().add(circle2);
//
Rectangle rec=new Rectangle();
rec.setArcHeight(100);
rec.setArcWidth(100);
rec.setFill(Color.WHITE);
rec.setArcHeight(20);
rec.setArcWidth(20);
rec.setX(170);
rec.setY(300);
rec.setWidth(300);
rec.setHeight(100);
root.getChildren().add(rec);
primaryStage.setScene(scene);
primaryStage.show();
/**
*/
launch(args);
}
TASK6
/*
*/
package task6;
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
/**
* @author ammar---
*/
@Override
stage.setTitle("Ammar yasser");
stage.setScene(scene);
stage.show();
launch(args);
DOCUMINT CONTROLLER.JAVA
package task6;
import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.shape.Line;
@FXML
@FXML
@FXML
@FXML
@FXML
@FXML
C1.setFill(Color.YELLOW);
c1.setStroke(Color.GREEN);
c2.setStroke(Color.GREEN);
line.setStroke(Color.GREEN);
line.setLayoutX(290);
line.setLayoutY(323);
line.setStartX(70);
line.setStartY(1);
line.setEndX(94);
line.setEndY(1);
line.setRotate(0);
@FXML
C1.setFill(Color.WHITE);
c1.setStroke(Color.RED);
c2.setStroke(Color.RED);
line.setStroke(Color.RED);
line.setLayoutX(313);
line.setLayoutY(306);
line.setStartX(66);
line.setStartY(-1);
line.setEndX(90);
line.setEndY(-1);
line.setRotate(90);
}
@Override