Posts

Showing posts from February, 2016

JavaFX 8 Tutorial 55 - Centering Image Using StackPane

Image
package tutorial.pkg55.centering.image; import javafx.application.Application; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.scene.shape.Ellipse; import javafx.stage.Stage; /**  *  * @author Ram  */ public class Tutorial55CenteringImage extends Application {         @Override     public void start(Stage primaryStage) {         primaryStage.setTitle("JavaFX 8 Tutorial 55 - Centering Image Using StackPane");                 StackPane root = new StackPane();         Scene scene = new Scene(root, 400, 200);                 Image img = new Image("file:Javafx.jpg", 100, 150, true, true);         ImageView iv = new ImageView(img);      ...

JavaFX 8 Tutorial 54 - Centering Text In Scene

Image
package tutorial.pkg54.centering.text; import javafx.application.Application; import javafx.geometry.VPos; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.text.Font; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; import javafx.stage.Stage; /**  *  * @author Ram  */ public class Tutorial54CenteringText extends Application {         @Override     public void start(Stage primaryStage) {         primaryStage.setTitle("JavaFX 8 Tutorial 54 - Centering Text In Scene");         Group root = new Group();         Scene scene = new Scene(root, 400, 200);                 Text text = new Text("JavaFX 8 Tutorial 54 - Centering Text In Scene");         text.setTextOrigin(VPos.TOP);         text.setFont(Font.font(null, FontWeight.BOLD, 15)); ...

JavaFX 8 Tutorial 53 - JavaFX Application Deployment

Image
Steps for JavaFX Application Deployment: 1.    Install Inno Setup (for exe installer) Link: http://www.jrsoftware.org/download.php/is.exe 2.    Install WIX Setup (for msi installer) Link: http://wixtoolset.org/releases/v3.10/stable 3.    Set Environment variables for Inno setup Path: C:\Program Files (x86)\Inno Setup 5 4.    Set Environment variables for WIX setup Path: C:\Program Files (x86)\WiX Toolset v3.10\bin 5.    Add Icon to application     primaryStage.setTitle("User Info App ");     primaryStage.getIcons().add(new Image("file:user-icon.png")); 6.    Open build.xml and Add Following code in it at last <target name="-post-jfx-deploy">     <fx:deploy verbose="true" nativeBundles="exe" outdir="${basedir}/${dist.dir}" outfile="${application.title}">         <fx:application name="${application.title}" mainClass="${javafx.mai...

JavaFX 8 Tutorial 52 - Import Excel to Database

Image
The code written in this tutorial is : private Button importXLToDB; importXLToDB = new Button("Import XL TO DB");         importXLToDB.setFont(Font.font("Sanserif", 15));         importXLToDB.setOnAction(e -> {             try {                 String query = "Insert into UserDatabase(ID, FirstName, LastName, Email) values (?,?,?,?)";                 pst = conn.prepareStatement(query);                                 FileInputStream fileIn = new FileInputStream(new File("UserInfo.xlsx"));                                 XSSFWorkbook wb = new XSSFWorkbook(fileIn);                 XSSFSheet sheet = wb.getSheetAt(0);   ...

JavaFX 8 Tutorial 51 - Export Database to Excel

Image
The code written in this tutorial is : private Button exportToXL; exportToXL = new Button("Export To Excel");         exportToXL.setFont(Font.font("Sanserif", 15));         exportToXL.setOnAction( e->{             try {                 String query = "Select * from UserDatabase";                 pst = conn.prepareStatement(query);                 rs = pst.executeQuery();                                 //Apache POI Jar Link-                 //http://a.mbbsindia.com/poi/release/bin/poi-bin-3.13-20150929.zip                 XSSFWorkbook wb = new XSSFWorkbook();//for earlier version use HSSF           ...

JavaFX 8 Tutorial 50 - Retrive Image from Database

Image
The code written in this tutorial is:  table.setOnMouseClicked(e ->{             try {                 User user = (User)table.getSelectionModel().getSelectedItem();                                 String query = "select * from UserDatabase where ID = ?";                 pst = conn.prepareStatement(query);                 pst.setString(1, user.getID());                 rs = pst.executeQuery();                                 while(rs.next()){                     InputStream is = rs.getBinaryStream("Image");                   ...

JavaFX 8 Tutorial 49 - Image and Database

Image
The code written in this tutorial is : private FileInputStream fis;         Button button = new Button("Save");         button.setFont(Font.font("SanSerif", 15));         button.setOnAction(e ->{             try{                 String query = "INSERT INTO UserDatabase ( Image) VALUES(?)";                 pst = conn.prepareStatement(query);                 fis = new FileInputStream(file);// file is selected using filechooser which is in last tutorial                 pst.setBinaryStream(11, (InputStream)fis, (int)file.length());                 pst.execute();                                 pst.close();...

JavaFX 8 Tutorial 48 - ImageView

Image
The code written in this tutorial is : private ImageView imageView; private Image image; browse.setOnAction(e ->{             //Single File Selection             file = fileChooser.showOpenDialog(primaryStage);             if(file != null){                 textArea.setText(file.getAbsolutePath());                 image = new Image(file.toURI().toString(), 100, 150, true, true);//path, PrefWidth, PrefHeight, PreserveRatio, Smooth                               imageView = new ImageView(image);                 imageView.setFitWidth(100);                 imageView.setFitHeight(150);               ...

JavaFX 8 Tutorial 47 - Get Selected Filepath Into TextArea

Image
The code written in this tutorial is: private TextArea textArea; browse.setOnAction(e ->{ //Single File Selection             file = fileChooser.showOpenDialog(primaryStage);             if(file != null){                 textArea.setText(file.getAbsolutePath());                           } //Multiple File Selection             /*List<File> fileList = fileChooser.showOpenMultipleDialog(primaryStage);             if(fileList != null){                 fileList.stream().forEach(selectedFiles ->{                     textArea.setText(fileList.toString());                 });     ...