Saturday, 9 January 2016

Tutorial On Toggle Button In JavaFx

In this article we are going to show how to create a toggle button in java-fx with source code.Previously we have also created toggle button in java swing.
See Related Tutorials:
 how to create toggle button in javaswing.
How To Create HelloWord Application In JavaFx Using Netbeans.
Combo box in java-fx
Cosmetic Planet

CODE:

import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.Toggle;
import javafx.scene.control.ToggleButton;
import javafx.scene.control.ToggleGroup;
import javafx.scene.media.AudioClip;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

public class mybej extends Application
{

@Override
public void start(Stage primaryStage) {
Group g = new Group();
primaryStage.setTitle("Toggle Button In JavaFx");

final ToggleGroup group = new ToggleGroup();
final ToggleButton tb1 = new ToggleButton("ON");
tb1.setToggleGroup(group);
tb1.setSelected(false);
final Rectangle rect = new Rectangle(145, 50);
rect.setFill(Color.RED);
rect.setLayoutX(40);
rect.setLayoutY(40);
g.getChildren().addAll(tb1,rect);
group.selectedToggleProperty().addListener(new ChangeListener<Toggle>(){
public void changed(ObservableValue<? extends Toggle> ov,
Toggle toggle, Toggle new_toggle) {
if (new_toggle == null)
{
rect.setFill(Color.RED);
tb1.setText("ON");
}
else
{
rect.setFill(Color.BLUE);
tb1.setText("OFF");
}
}
});

Scene sc = new Scene(g,400,300);
primaryStage.setScene(sc);
primaryStage.show();
}

public static void main(String[] args) {
launch(args);
}

}

OUTPUT:

Minesweeper Game In Java-Fx For Free Download

We are back with a exciting game called minesweeper this game needs no introduction as it is the most oldest game.The only reason for sharing this game with you to provide a basic solutions of gaming in java-fx.So enjoy a free download of this game and feel free to share your opinion.

SCREENSHOT:





Friday, 1 January 2016

,

Tic Tac Toe Game In Java-Fx For Download

Tic tac toe is one of the most basic games in world of gaming.The reason of sharing this game code is to provide a opportunity to new game developers to learn basics of gaming in java-fx.This game is to free to download so grab it and don't forget share your reviews about it.

SNAP SHOT:








Sunday, 6 December 2015

How To Create Calculator In Web Page Using JQuery


How To Create Calculator In Web Page Using JQuery
In this article we  show you how to create simple calculator using jquery.This calculator is created with basic code such as if-else ladder and switches to show you how to perform basic operation in a webpages.Thank you enjoy the post and give your feed back.

CODE: 


Live Demo

Friday, 27 November 2015

How To Create Animated Back To Top PlugIn Using JQuery


Reading long article its very irritating to scroll up whole page using scroll bar I recommend you to add simple back to top plugin in you website adding below code.

How To Scroll Up Webpage On A Click Using Jquery:

As we know that jquery has various animations properties by using one of them we can do our task.Here is a syntax of method whic we are going to used in our example.

$('selector').animate({scrollTop : position},time in millisec)

CODE:



Live Demo

Thursday, 26 November 2015

How To Automatically Change Background Colour Of Website Using JQuery

How To Automatically Change  Background Colour Of  Website Using JQuery

In this post we are going to show you how to give new look to your website each time when new visitor visits your website this can be done using simple jquery ,javascripting and css code.

How To Automatically Generate New Background Color:

This can be done using simple logic we have to generate three random numbers between 0 to 256 to create and colour in RGB format we can generate random number by following code.
 var r =  Math.floor((Math.random() * 255) + 1);
Then by using below code we can change the background colour of any component in our website.
$("body").css("background",'rgb('+r+','+g+','+b+')');
On every new visit or refresh it will change background colour of website.Thats it enjoy the code and must give your feedback.

How To Automatically Changed Fixed Background Colour:

By using below code we can generate random colours of our own choice so when ever visitor refresh your website he gets new look.
var col = ["#ff8080","#80ff80","#8080ff","#ff80df"];
var r =  Math.floor((Math.random() * 3) + 1);
$("body").css("background",col[r]);
Thats it thankyou enjoy the code and must give your feedback.  

Wednesday, 25 November 2015

How To Validate HTML5 Forms Using Jquery

Validation is a process to check whether the user is filling right information or wrong in form by using this method we can stop user filling wrong or empty information in form.This process can be done using jquery and javascripting in this example we have shown how to validate empty field,how to validate email address and how to validate password strength.You can also use html required attribute to validate your form.

OUTPUT:

how to validate form using jquery and javascripting




CODE:


Live Demo

Wednesday, 4 November 2015

Circle Shape Stage In JavaFx

In this code I show you how can we use javafx graphics to create stage of custom shapes.In this program I have create an stage of circle shape you can create stage of any shape by making change in this line. 

Circle dragger = new Circle(100, 100, 100,Color.CADETBLUE);

Enjoy reading.

CODE:

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.HBox;
import javafx.scene.paint.Color;
import javafx.scene.shape.Circle;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
import javafx.stage.StageStyle;

public class mybej extends Application {
Double intx,inty;
@Override
public void start(final Stage stage) {

stage.initStyle(StageStyle.TRANSPARENT);
Text text = new Text("Transparent STAGE");
Circle dragger = new Circle(100, 100, 100,Color.CADETBLUE);
text.setFont(new Font(40));
Group g = new Group();
Button min = new Button("-");
min.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
stage.setIconified(true);
}
});
Button close = new Button("X");
close.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent event) {
stage.close();
}
});

dragger.setOnMousePressed(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
intx = (me.getScreenX() - stage.getX());
inty = me.getScreenY() - stage.getY();
}
});

//when screen is dragged, translate it accordingly
dragger.setOnMouseDragged(new EventHandler<MouseEvent>() {
public void handle(MouseEvent me) {
stage.setX(me.getScreenX() - intx);
stage.setY(me.getScreenY() - inty);
}
});
HBox hBox = new HBox();
hBox.setSpacing(10);
hBox.setPadding(new Insets(25,0,0,60));
hBox.setAlignment(Pos.TOP_CENTER);
hBox.getChildren().addAll(min,close);

g.getChildren().addAll(dragger,hBox);
final Scene scene = new Scene(g,300, 250);
scene.setFill(Color.TRANSPARENT);
stage.setScene(scene);
stage.show();

}

public static void main(String[] args) {
launch(args);
}
}

OUTPUT:

Round shape stage in javafx

Saturday, 31 October 2015

Anagram Word Puzzle Game In Java

Today we are going to share with you an exciting word puzzle game in java this game generates an random scramble word user have to guess correct word if user guess correct word hi/her score will be increased.In this game user have also an option to skip the word.That is the complete description of a project.Download and enjoy this project don't forget to share your reviews.

SNAPSHOT:




DOWNLOAD THIS PROJECT:

                                                     DOWNLOAD

Thursday, 22 October 2015

, ,

Employee Management Project In Java

This project completely  based on jdbc and jswing.This is a perfect project for beginners who want to learn database management system in java.Following are the features of this project.

FEATURES:

Save employee record.
It can calculate salary of employee.
It can search employee record.
It can delete employee record.

OUTPUT: 





DOWNLOAD THIS PROJECT:


                           DOWNLOAD


Searching In Jtable On Every Key Press

When working with huge data we often need to search specific data in our table in this tutorial we shows how to search data in jtable using textfield  when ever user press key from keyboard it searches the data according to key press rowfilter is used to perform this task.

RowFilter<M,I>:

M: Here we have to specify the name of model we want to add row filter.
I: Type of identifier is specified here.

CODING:

import javax.swing.*;
import java.awt.*;
import javax.swing.event.*;
import javax.swing.table.*;
public class table extends JFrame{

table()
{
final JTextField t1 = new JTextField(15);
setTitle("Searching In JTable");
JLabel l1 = new JLabel("Search");
setDefaultCloseOperation(EXIT_ON_CLOSE);      
String columnNames[] = {"Product Name","Price"};
Object rowData[][]={{"Light",300},{"Fan",400},{"Bulb",100},{"Egg",50},{"Biscuit",20},{"Milk",80}};
TableModel model = new DefaultTableModel(rowData, columnNames);


final TableRowSorter<TableModel> sorter1 = new TableRowSorter<>(model);

JTable table1 = new JTable(model);
table1.setRowSorter(sorter1);
setLayout(new FlowLayout(FlowLayout.CENTER));
JScrollPane js = new JScrollPane(table1,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
add(l1);
add(t1);
add(js);

t1.getDocument().addDocumentListener(new DocumentListener(){
@Override public void insertUpdate(DocumentEvent e) {
search(t1.getText());

}
@Override public void removeUpdate(DocumentEvent e) {
search(t1.getText());
}
@Override public void changedUpdate(DocumentEvent e) {
search(t1.getText());
}
public void search(String s)
{
if (s.length() == 0) {

sorter1.setRowFilter(null);
} else {

sorter1.setRowFilter(RowFilter.regexFilter(s));
}
}
});
setSize(500,600);
setVisible(true);
}
}

class tab
{
public static void main(String[] args)  {

table x= new table();

}

}

OUTPUT:





Wednesday, 21 October 2015

,

How To Open And Save File In Java Fx

Before reading this article you should read Tutorial on file chooser in javafx,Tutorial on context menu in javafx. In this tutorial we will see how to use file chooser to open and save  image files in java fx.following are the explanations of methods used in these tutorials.

imageIo.write(RenderedImage im,String format,File outputlocation)

Writes an image using an  ImageWriter that supports the given specified format of a image. If there is already a File present, its will be over written.
im: Name of image that is to be written.

format: In this parameter you have to specify format in which you want to write a image.

outputlocation: Here you have to specify the location of image where you have to write.

HOW TO SAVE IMAGE FROM JAVAFX APPLICATION USING FILE CHOOSER:

import java.io.File;
import java.io.IOException;
import javafx.application.Application;
import javafx.embed.swing.SwingFXUtils;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.Color;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import javax.imageio.ImageIO;

public class mybej extends Application
{
public static void main(String[] args)
{
launch(args);
}
@Override
public void start( final Stage primaryStage) {
final Group root = new Group();
final Image pic = new Image ("fac.jpg");
ImageView iv = new ImageView();
iv.setImage(pic);

final FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Save File Chooser");
final Scene scene = new Scene(root, 600, 350,Color.WHITE);
final ContextMenu cm = new ContextMenu(); 
MenuItem cmItem2 = new MenuItem("Save Image");
cm.getItems().add(cmItem2);
cmItem2.setOnAction(new EventHandler<ActionEvent>() {
public void handle(ActionEvent e) {

fileChooser.setTitle("Save Image");

File file = fileChooser.showSaveDialog(primaryStage);
if (file != null) {
try {
ImageIO.write(SwingFXUtils.fromFXImage(pic, null), "png", file);
} catch (IOException ex) {
System.out.println(ex.getMessage());
}
}
}
}
);
scene.addEventHandler(MouseEvent.MOUSE_CLICKED,
new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent e) {
if (e.getButton() == MouseButton.SECONDARY)  
cm.show(root, e.getX(),e.getY());
}
}); 
primaryStage.setScene(scene);
root.getChildren().addAll(iv);
primaryStage.show();
}

}

OUTPUT:



HOW TO OPEN IMAGE FILE USING FILE CHOOSER IN JAVA FX:


import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.FileChooser;
import javafx.stage.Stage;

public final class mybej extends Application {

private Desktop desktop = Desktop.getDesktop();

@Override
public void start(final Stage stage) {
stage.setTitle("File Chooser Sample");
final FileChooser fileChooser = new FileChooser();
File file = fileChooser.showOpenDialog(stage);

if (file != null) {
openFile(file);
}


Group root = new Group();

stage.setScene(new Scene(root));

}

public static void main(String[] args) {
Application.launch(args);
}

private void openFile(File file) {
try {
desktop.open(file);
} catch (IOException ex) {
System.out.print(ex);
}
}
}

How To Create Musical Piano In JavaFx

 After using lots of application based on audio I get motivated to create a program based on audio,this program used AudioClip class to play a music when button of piano is pressed and I have used play method to play particular audioclip when piano button is pressed following code show how to create a musical piano in javafx.

CODING:

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.input.MouseEvent;
import javafx.scene.media.AudioClip;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
import javafx.stage.Stage;

public class Mypiano extends Application
{

@Override
public void start(Stage primaryStage)
{

Group root = new Group();  
Rectangle r = new Rectangle(300,60,60,200);
r.setFill(Color.WHITE);
r.setStroke(Color.BLACK);
Rectangle ra = new Rectangle(340,60,50,130);
ra.setFill(Color.BLACK);
Rectangle r1 = new Rectangle(361,60,60,200);
r1.setFill(Color.WHITE);
r1.setStroke(Color.BLACK);
Rectangle r1a = new Rectangle(400,60,50,130);
r1a.setFill(Color.BLACK);
Rectangle r2 = new Rectangle(421,60,60,200);
r2.setFill(Color.WHITE);
r2.setStroke(Color.BLACK);
Rectangle r2a = new Rectangle(461,60,50,130);
r2a.setFill(Color.BLACK);
Rectangle r3 = new Rectangle(483,60,60,200);
r3.setFill(Color.WHITE);
r3.setStroke(Color.BLACK);
Rectangle r3a = new Rectangle(524,60,20,130);
r3a.setFill(Color.BLACK);
Rectangle r4 = new Rectangle(545,60,60,200);
r4.setFill(Color.WHITE);
r4.setStroke(Color.BLACK);
Rectangle r4a = new Rectangle(584,60,20,130);
r4a.setFill(Color.BLACK);

final AudioClip note1 =
new AudioClip(getClass().getResource("Note1.wav").toString());
final AudioClip note2 =
new AudioClip(getClass().getResource("Note2.wav").toString());
final AudioClip note3 =
new AudioClip(getClass().getResource("Note3.wav").toString());

final AudioClip note4 =
new AudioClip(getClass().getResource("Note4.wav").toString());


final AudioClip note5 =
new AudioClip(getClass().getResource("Note5.wav").toString());


final AudioClip note6 =
new AudioClip(getClass().getResource("Note6.wav").toString());

final AudioClip note7 =
new AudioClip(getClass().getResource("Note7.wav").toString());

final AudioClip note8 =
new AudioClip(getClass().getResource("Note8.wav").toString());
r.setOnMouseClicked(new EventHandler<MouseEvent>()
{
@Override
public void handle(MouseEvent me) {

note1.play();

}
});
r1.setOnMouseClicked(new EventHandler<MouseEvent>()
{
@Override
public void handle(MouseEvent me) {

note2.play();

}
});
r2.setOnMouseClicked(new EventHandler<MouseEvent>()
{
@Override
public void handle(MouseEvent me) {

note3.play();

}
});
r3.setOnMouseClicked(new EventHandler<MouseEvent>()
{
@Override
public void handle(MouseEvent me) {

note4.play();

}
});
r4.setOnMouseClicked(new EventHandler<MouseEvent>()
{
@Override
public void handle(MouseEvent me) {

note5.play();

}
});
ra.setOnMouseClicked(new EventHandler<MouseEvent>()
{
@Override
public void handle(MouseEvent me) {

note6.play();

}
});

r1a.setOnMouseClicked(new EventHandler<MouseEvent>()
{
@Override
public void handle(MouseEvent me) {

note7.play();

}
});
r2a.setOnMouseClicked(new EventHandler<MouseEvent>()
{
@Override
public void handle(MouseEvent me) {

note1.play();

}
});
r3a.setOnMouseClicked(new EventHandler<MouseEvent>()
{
@Override
public void handle(MouseEvent me) {

note2.play();

}
});
r4a.setOnMouseClicked(new EventHandler<MouseEvent>()
{
@Override
public void handle(MouseEvent me) {

note8.play();

}
});


root.getChildren().addAll(r,ra,r1,r1a,r2,r2a,r3,r3a,r4,r4a);
Scene scene = new Scene(root, 600, 300);
primaryStage.setTitle("PIANO");
primaryStage.setScene(scene);
primaryStage.show();
}

public static void main(String[] args) {
launch(args);
}

}

OUTPUT:


Tutorial On Button In Java Fx

In this article I have tried to show you how to use button in javafx application button in javafx can be used in three different modes.
  1. NORMAL:Creates a simple push button.
  2. DEFAULT:Creates a simple button that can be operated by enter key.
  3. CANCEL:Creates a button that can be operated by escape button.
In this program we have shown you how to create default button.setLayoutX,setLayoutX is used to position of button in screen.

CODING:

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;


public class mainfx extends Application 
{

@Override
public void start(Stage primaryStage) {
Group g = new Group();
primaryStage.setTitle("FX Button");
Button btn = new Button("Press To Exit");
btn.setMinWidth(100);
btn.setLayoutX(100);
btn.setLayoutY(100);

btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
System.exit(1);
}
});

g.getChildren().add(btn);
Scene sc = new Scene(g,400,300);
primaryStage.setScene(sc);
primaryStage.show();
}


public static void main(String[] args) {
launch(args);
}

}

APPLYING MOUSE EVENT IN BUTTON:

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.input.MouseEvent;
import javafx.scene.transform.Rotate;
import javafx.stage.Stage;

public class mainfx extends Application {

Button btn = new Button();
@Override
public void start(Stage primaryStage) {
Group g = new Group();
primaryStage.setTitle("Button Event In JavaFx");
btn = new Button("Enter Mouse To Rotate");
btn.setMinWidth(100);
btn.setLayoutX(100);
btn.setLayoutY(100);

btn.addEventHandler(MouseEvent.MOUSE_ENTERED,
new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent e) {
btn.getTransforms().add(new Rotate(45));
}
});    

g.getChildren().add(btn);
Scene sc = new Scene(g,400,300);
primaryStage.setScene(sc);
primaryStage.show();
}


public static void main(String[] args) {
launch(args);
}

}









Monday, 19 October 2015

Tutorial On File Chooser In Java Fx

In our previous article we have also discussed about jfilechooser the reason of writing again an article on filechooser in javafx is that in javafx it has some new features that we are going to   discussed in this article.

SAVE FILE CHOOSER IN JAVAFX:

Below program shows how to create a simple save file chooser this used when want to save a particular file using filechooser. 

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.FileChooser;
import javafx.stage.Stage;

public class mybej extends Application
{
public static void main(String[] args)
{
launch(args);
}
@Override
public void start( Stage primaryStage) {
Group root = new Group();
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Save File Chooser");
fileChooser.showSaveDialog(primaryStage);
primaryStage.setScene(new Scene(root, 500, 400));

}

}


OPEN FILE CHOOSER IN JAVAFX:

This program can be used to create a open file chooser that can be useful to open a particular file.
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.FileChooser;
import javafx.stage.Stage;

public class mybej extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start( Stage primaryStage) {
Group root = new Group();
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Open File Chooser");
fileChooser.showOpenDialog(primaryStage);
primaryStage.setScene(new Scene(root, 500, 400));

}

}



HOW TO SET INITIAL DIRECTORY OF FILE CHOOSER IN JAVAFX:

JavaFx provides a new option by using this option we can set the initial directory of filechooser.This can be done by simple adding below code in your code. 
fileChooser.setInitialDirectory(new File("C:"));

HOW TO ADD EXTENSION FILTER  IN FILECHOOSER IN JAVAFX:

Some we want that only a particular type of file is should be shown by file chooser in javafx we can do this by simply adding this code in this program we have added jpg extion filter you can change it according to your need.
 fileChooser.getExtensionFilters().addAll(
new FileChooser.ExtensionFilter("JPG", "*.jpg"),
new FileChooser.ExtensionFilter("PNG", "*.png"),
new FileChooser.ExtensionFilter("JAVA", "*.java")    
);




How To Create Pop-Up Menu In JavaFx

In this tutorial we show how to create pop up menu in javafx using context menu.Context menu can be created using ObservableList of menu items user have option to add any of menu like radio menu and checkmenu.For creating pop-up menu we have to first create a context menu then we have to add a menuitemin in context menu accoding to our need following program shows how to create a pop-up menu.

CODING:

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuItem;
import javafx.scene.input.MouseButton;
import javafx.scene.input.MouseEvent;
import javafx.scene.paint.Color;
import javafx.stage.Stage;

public class mybej extends Application 
{

public static void main(String[] args) 
{
launch(args);
}

@Override
public void start(Stage primaryStage) 
{
final Group root = new Group();
final ContextMenu cm = new ContextMenu();
MenuItem menu1 = new MenuItem("First Menu");
Menu menu = new Menu("Second Menu ");
MenuItem submenu = new MenuItem("First Sub Menu");
MenuItem submenu1 = new MenuItem("Second Sub Menu");
MenuItem menu3 = new MenuItem("Third Menu");
cm.getItems().add(menu1);
cm.getItems().add(menu);
menu.getItems().add(submenu);
menu.getItems().add(submenu1);
cm.getItems().add(menu3);
Scene scene = new Scene(root, 600, 350,Color.WHITE);
scene.addEventHandler(MouseEvent.MOUSE_CLICKED,
new EventHandler<MouseEvent>() {
@Override public void handle(MouseEvent e) {
if (e.getButton() == MouseButton.SECONDARY)  
cm.show(root, e.getX(),e.getY());
}
});
primaryStage.setScene(scene);
primaryStage.setTitle("POP MENU IN JAVAFX");
primaryStage.setWidth(200);
primaryStage.setHeight(200);
primaryStage.show();
}
}

OUTPUT:


Saturday, 17 October 2015

,

How To Load And Refresh Data Base Data In Table JavaFx

In this tutorial we are going to discussed how to load database data in table after the table have loaded sometimes data becomes change we should have a option to refresh our data in this program we have show you how to refresh table in javafx on a click.This enable user to continuously update database data.  

CODING:

import javafx.application.Application;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.stage.Stage;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.control.Button;
public class mybej extends Application 
{

private final TableView<myData> table = new TableView<>();
private final ObservableList<myData> data =
FXCollections.observableArrayList();
String s,s1,s2,s3,s4,s5;
Button b1 = new Button("REFRESH");
ResultSet database,database1;
Statement st,st1;
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage stage) {
TableColumn firstCol = new TableColumn("First Name");
firstCol.setMinWidth(100);
firstCol.setCellValueFactory(
new PropertyValueFactory<>("name"));
TableColumn secCol = new TableColumn("Fax-Number");
secCol.setCellValueFactory(
new PropertyValueFactory<>("number"));
TableColumn lastCol = new TableColumn("Email");
lastCol.setCellValueFactory(
new PropertyValueFactory<>("email"));
table.setItems(data);
table.getColumns().addAll(firstCol, secCol,lastCol);
table.setMinWidth(230);
table.setLayoutX(10);
table.setLayoutY(40);
b1.setLayoutX(5);
b1.setLayoutY(5);
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection cn=DriverManager.getConnection("jdbc:odbc:login");
st1=cn.createStatement();
database=st1.executeQuery("select * from load");
while(database.next())
{
s = database.getString(1);
s1 = database.getString(2);
s2 = database.getString(3);
data.add(new myData(s,s1,s2));
}  
st.close();
database.close();
cn.close();
}
catch(Exception e)
{
System.out.print(e);

}
b1.setOnAction(new EventHandler<ActionEvent>() {
@Override 
public void handle(ActionEvent e) {
try
{
Connection cn=DriverManager.getConnection("jdbc:odbc:login");
st=cn.createStatement();

database=st1.executeQuery("select * from load");
data.removeAll(data);
while(database.next())
{
s3 = database.getString(1);
s4 = database.getString(2);
s5 = database.getString(3);

data.add(new myData(s3,s4,s5));

}
st.close();
cn.close();
}   catch(Exception ex)
{
System.out.print(ex);
}
}
});
Group root = new Group();
root.getChildren().addAll(table,b1);
stage.setTitle("Table with Database");    
Scene scene = new Scene(root, 300, 250);
stage.setScene(scene);
stage.show();
}

public static class myData {

private final SimpleStringProperty Name;
private final SimpleStringProperty email;
private final SimpleStringProperty number;
private myData(String fName,String fnum,String email) {
this.Name = new SimpleStringProperty(fName);
this.email = new SimpleStringProperty(email);
this.number = new SimpleStringProperty(fnum);
}


public String getEmail() {
return email.get();
}
public void setEmail(String fName) {
email.set(fName);
}
public String getName() {
return Name.get();
}
public void setName(String fName) {
Name.set(fName);
}
public String getNumber() {
return number.get();
}
public void setNumber(String fName) {
number.set(fName);
}

}
} 

OUTPUT: