Posts

Blog overview and remarks.

I have been a java software developer for about three years now.About a year ago i have been using javafx to develop software applications.The amazing thing about javafx it embraces the philosophy in which Java was built upon,which is WORA(write once,run anywhere)this means java can run on any platform and system architecure.Using Javafx you can write amazing software applications for a variety of platforms mobile included; this has been made possible by the Java developer community.The code snippets am going to post on this blog are just but a few tips that may appear confusing to newbies.You can run and test them.If you want to use them in a production environment you notice you will have to optimize the code.You can do that or contact me so that i can optimize the code for you.For questions or interactions mail me at:kelvinkagia@gmail.com.Thanks in advance.

Javafx database driven login script demo.

Image
import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.*; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; import javafx.scene.control.Button; import javafx.stage.Stage; import javafx.scene.control.TextField; import javafx.scene.control.PasswordField; import javafx.scene.control.Label; import javafx.scene.layout.GridPane; import javafx.scene.layout.BorderPane; import javafx.scene.layout.HBox; import javafx.scene.paint.Color; import javafx.scene.text.Font; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; public class LoginScript extends Application {     PreparedStatement ps;     Connection conn;     ResultSet rs;     public static

Javafx displaying image from database.

Image
import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.*; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.control.Button; import javafx.scene.layout.BorderPane; public class PhotoFromDatabase extends Application {     PreparedStatement ps;     Connection conn;     ResultSet rs;           public static void main(String[]args)     {         Application.launch(args);     }     @Override     public void start(Stage primaryStage)     {         BorderPane bp = new BorderPane();         Scene scene = new S

Javafx inserting uploaded image into database.

Image
import java.awt.image.BufferedImage; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.logging.Level; import java.util.logging.Logger; import javafx.application.Application; import java.sql.*; import javafx.embed.swing.SwingFXUtils; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.stage.Stage; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.Scene; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; import javafx.scene.layout.BorderPane; import javafx.scene.control.Button; import javafx.stage.FileChooser; import javax.imageio.ImageIO; public class ImageToDatabase extends Application {      PreparedStatement ps;     Connection conn;     ResultSet rs;                public static void main(

Javafx fetching data from database to a table.

Image
import javafx.application.Application; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.scene.layout.BorderPane; import java.sql.*; import java.util.logging.Level; import java.util.logging.Logger; import javafx.beans.property.SimpleStringProperty; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Insets; import javafx.scene.control.Button; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; import javafx.scene.control.cell.PropertyValueFactory; public class ValuesFromDatabaseToTable extends Application {     PreparedStatement ps;     Connection conn;     ResultSet rs;      String usernameSession;      private final TableView<Contacts> table = new TableView<>();       private final ObservableList<Contacts>data = FXCollections.observableArrayList();     public static void ma

Javafx changing from one scene to another.

import javafx.application.Application; import javafx.scene.layout.StackPane; import javafx.scene.control.Button; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.scene.Scene; import javafx.stage.Stage; public class ChangingScene extends Application {     public static void main(String[]args)     {         Application.launch(args);     }     @Override     public void start(Stage primaryStage)     {         StackPane root = new StackPane();         Scene next = new Scene(root,600,400);//first scene                  Button nextBtn = new Button("next");         root.getChildren().add(nextBtn);//adding nextBtn button on stackpane of scene 2                  //creating scene2         StackPane sp = new StackPane();         Scene back = new Scene(sp,600,400);                  Button backBtn = new Button("back");         sp.getChildren().add(backBtn);                  //adding actions to buttons         ne

Javafx fetching string from a datepicker.

import javafx.application.Application; import javafx.event.ActionEvent; import javafx.event.EventHandler; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.stage.Stage; import javafx.scene.layout.BorderPane; import javafx.scene.control.DatePicker; import javafx.scene.layout.FlowPane; import javafx.scene.control.Button; import javafx.scene.control.TextField; public class FetchingFromDatePicker extends Application {     public static void main(String[]args)     {         Application.launch(args);     }     @Override     public void start(Stage primaryStage)     {         BorderPane bp = new BorderPane();         Scene scene = new Scene(bp,600,400);                  //creating the datepicker         DatePicker dateP = new DatePicker();         dateP.setPrefWidth(200);//creating the width of the datepicker         dateP.setPrefHeight(20);//creating the height of the datepicker                  //creating button         Button btn = new B