Showing posts with label JavaFX. Show all posts
Showing posts with label JavaFX. Show all posts

Java J2EE Spring JavaFX exercise: Reflection effect

Reflection effect
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javafx_extext;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.Reflection;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
*
* @author erix7
*/
public class JavaFX_exText extends Application {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com");
Group root = new Group();
Scene scene = new Scene(root, 400, 300, Color.WHITE);

Reflection reflection = new Reflection();

Text text = new Text(50, 50, "Serif");
text.setFill(Color.RED);
text.setFont(Font.font("Serif", 20));
text.setEffect(reflection);

Text text2 = new Text(50, 100, "SanSerif");
text2.setFill(Color.GREEN);
text2.setFont(Font.font("SanSerif", 30));
text2.setEffect(reflection);

Text text3 = new Text(50, 150, "Monospaced");
text3.setFill(Color.BLUE);
text3.setFont(Font.font("Monospaced", 40));
text3.setEffect(reflection);

root.getChildren().add(text);
root.getChildren().add(text2);
root.getChildren().add(text3);

primaryStage.setScene(scene);
primaryStage.show();
}
}

Java J2EE Spring JavaFX exercise: add shadow effect on text

shadow effect on text
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javafx_extext;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.effect.DropShadow;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
*
* @author erix7
*/
public class JavaFX_exText extends Application {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com");
Group root = new Group();
Scene scene = new Scene(root, 400, 300, Color.WHITE);

DropShadow shadow = new DropShadow();
shadow.setOffsetX(5.0);
shadow.setOffsetY(5.0);
shadow.setColor(Color.BLACK);

Text text = new Text(50, 50, "Serif");
text.setFill(Color.RED);
text.setFont(Font.font("Serif", 20));
text.setEffect(shadow);

Text text2 = new Text(50, 100, "SanSerif");
text2.setFill(Color.GREEN);
text2.setFont(Font.font("SanSerif", 30));
text2.setEffect(shadow);

Text text3 = new Text(50, 150, "Monospaced");
text3.setFill(Color.BLUE);
text3.setFont(Font.font("Monospaced", 40));
text3.setEffect(shadow);

root.getChildren().add(text);
root.getChildren().add(text2);
root.getChildren().add(text3);

primaryStage.setScene(scene);
primaryStage.show();
}
}

Java J2EE Spring JavaFX exercise: Set text font

Set text font
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javafx_extext;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
*
* @author erix7
*/
public class JavaFX_exText extends Application {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com");
Group root = new Group();
Scene scene = new Scene(root, 400, 300, Color.WHITE);

Text text = new Text(50, 50, "Serif");
text.setFill(Color.RED);
text.setFont(Font.font("Serif", 20));

Text text2 = new Text(50, 100, "SanSerif");
text2.setFill(Color.GREEN);
text2.setFont(Font.font("SanSerif", 30));

Text text3 = new Text(50, 150, "Monospaced");
text3.setFill(Color.BLUE);
text3.setFont(Font.font("Monospaced", 40));

root.getChildren().add(text);
root.getChildren().add(text2);
root.getChildren().add(text3);

primaryStage.setScene(scene);
primaryStage.show();
}
}

Java J2EE Spring JavaFX exercise: Set text color using javafx.scene.paint.Color

Set text color using javafx.scene.paint.Color
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javafx_extext;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
*
* @author erix7
*/
public class JavaFX_exText extends Application {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com");
Group root = new Group();
Scene scene = new Scene(root, 400, 300, Color.WHITE);

Text text = new Text(50, 50, "Hello Java-Buddy");
int red = 255;
int green = 0;
int blue = 0;
text.setFill(Color.rgb(red, green, blue, 0.9));

Text text2 = new Text(50, 100, "Hello Java-Buddy");
text2.setFill(Color.GREEN);
Text text3 = new Text(50, 150, "Hello Java-Buddy");
text3.setFill(Color.hsb(40, 0.7, 0.8));

root.getChildren().add(text);
root.getChildren().add(text2);
root.getChildren().add(text3);

primaryStage.setScene(scene);
primaryStage.show();
}
}

Spring Hibernate Communication between JavaFX and JavaScript inside WebView, using JSObject

The former articles demonstrate how to "Execute JavaScript in WebView from Java code" and "implement OnAlert EventHandler of WebEngine".

In order to call JavaFX from Javascript in WebView, we can create a JSObject in JavaFX, and then calling it's setMember() method to make it known to Javascript. After that, Javascript can call it's public methods and access it's public field.

Communication between JavaFX and JavaScript inside WebView


JavaFX code:
package javafxweb;

import java.net.URL;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker.State;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.VPos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;
import netscape.javascript.JSObject;

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class JavaFXWeb extends Application {

private Scene scene;
MyBrowser myBrowser;

Label labelFromJavascript;

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com");

myBrowser = new MyBrowser();
scene = new Scene(myBrowser, 640, 480);

primaryStage.setScene(scene);
primaryStage.show();
}

class MyBrowser extends Region{

HBox toolbar;
VBox toolbox;

WebView webView = new WebView();
WebEngine webEngine = webView.getEngine();

public MyBrowser(){

final URL urlHello = getClass().getResource("hello.html");
webEngine.load(urlHello.toExternalForm());

webEngine.getLoadWorker().stateProperty().addListener(
new ChangeListener<State>(){

@Override
public void changed(ObservableValue<? extends State> ov, State oldState, State newState) {
if(newState == State.SUCCEEDED){
JSObject window = (JSObject)webEngine.executeScript("window");
window.setMember("app", new JavaApplication());
}
}
});


JSObject window = (JSObject)webEngine.executeScript("window");
window.setMember("app", new JavaApplication());

final TextField textField = new TextField ();
textField.setPromptText("Hello! Who are?");

Button buttonEnter = new Button("Enter");
buttonEnter.setOnAction(new EventHandler<ActionEvent>(){

@Override
public void handle(ActionEvent arg0) {
webEngine.executeScript( " updateHello(' " + textField.getText() + " ') " );
}
});

Button buttonClear = new Button("Clear");
buttonClear.setOnAction(new EventHandler<ActionEvent>(){

@Override
public void handle(ActionEvent arg0) {
webEngine.executeScript( "clearHello()" );
}
});

toolbar = new HBox();
toolbar.setPadding(new Insets(10, 10, 10, 10));
toolbar.setSpacing(10);
toolbar.setStyle("-fx-background-color: #336699");
toolbar.getChildren().addAll(textField, buttonEnter, buttonClear);

toolbox = new VBox();
labelFromJavascript = new Label();
toolbox.getChildren().addAll(toolbar, labelFromJavascript);
labelFromJavascript.setText("Wait");

getChildren().add(toolbox);
getChildren().add(webView);

}

@Override
protected void layoutChildren(){
double w = getWidth();
double h = getHeight();
double toolboxHeight = toolbox.prefHeight(w);
layoutInArea(webView, 0, 0, w, h-toolboxHeight, 0, HPos.CENTER, VPos.CENTER);
layoutInArea(toolbox, 0, h-toolboxHeight, w, toolboxHeight, 0, HPos.CENTER, VPos.CENTER);
}

}

public class JavaApplication {
public void callFromJavascript(String msg) {
labelFromJavascript.setText("Click from Javascript: " + msg);
}
}

}


hello.html
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset=utf-8>
<title>Hello Java-Buddy!</title>

<script>

function updateHello(user){
document.getElementById("helloprompt").innerHTML="Hello: " + user;
}

function clearHello(user){
document.getElementById("helloprompt").innerHTML="Hello <a href='http://java-buddy.blogspot.com/'>Java-Buddy</a>";
}

function callJavaFX(){
var msg = document.getElementById("textto").value;
app.callFromJavascript(msg);
}
</script>

</head>
<body>
<img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjlRq_8YevlOSHrtrlvhf3k7o0E0fLS1Wv90sbMxIgQlsGaPxFOvAa8wULLxqAw707tewfbIqZj4qSflE56poWxfJYnotevZnW0JMlNAxpnobpL1CL1aNYz4uM4gpxvpKotR_TjvuvyNFSh/s150/duke_44x80.png"/>
<p id="helloprompt">Hello <a href="http://java-buddy.blogspot.com/">Java-Buddy</a></p>
<p><textarea id="textto"> </textarea></p>
<p><input type="button" value="Click to send message to Javascript" onclick="callJavaFX()"></p>
</body>
</html>


Java J2EE Spring JavaFX exercise: display text on Scene

display text on Scene
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package javafx_extext;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
*
* @author erix7
*/
public class JavaFX_exText extends Application {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com");

Text text = new Text(50, 50, "Hello Java-Buddy");

StackPane root = new StackPane();
root.getChildren().add(text);
primaryStage.setScene(new Scene(root, 300, 250));
primaryStage.show();
}
}

Spring Hibernate Embed WebView in FXML, to load OpenLayers with OpenStreetMap.

Last article demonstrate how to "Embed OpenLayers with OpenStreetMap in JavaFX WebView". This article demonstrate how to do it in FXML.

Embed WebView in FXML, to load OpenLayers with OpenStreetMap.


New a JavaFX FXML Application in NetBeans.

Copy openstreetmap.html from last article.

Create MyBrowser.java, extends Region.
package javafxml_web;

import java.net.URL;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class MyBrowser extends Region{
HBox toolbar;

WebView webView = new WebView();
WebEngine webEngine = webView.getEngine();

public MyBrowser(){

final URL urlGoogleMaps = getClass().getResource("openstreetmap.html");
webEngine.load(urlGoogleMaps.toExternalForm());

getChildren().add(webView);

}
}

Modify Sample.fxml to add MyBrowser, and remove un-used elements.
<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import javafxml_web.*?>

<AnchorPane id="AnchorPane" prefHeight="500" prefWidth="660" xmlns:fx="http://javafx.com/fxml" fx:controller="javafxml_web.Sample">
<children>
<MyBrowser id="mybrowser" layoutX="10" layoutY="10" prefHeight="460" prefWidth="620" fx:id="mybrowser" />
</children>
</AnchorPane>

Modify Sample.java to remove un-used code.
package javafxml_web;

import java.net.URL;
import java.util.ResourceBundle;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class Sample implements Initializable {

@FXML
private MyBrowser mybrowser;

@FXML
private void handleButtonAction(ActionEvent event) {

}

@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
}

}

Spring Hibernate JavaFX 2.1: javafx.scene.chart.StackedBarChart

JavaFX 2.1 introduce a new StackedBarChart class. StackedBarChart is a variation of BarChart that plots bars indicating data values for a category. The bars can be vertical or horizontal depending on which axis is a category axis. The bar for each series is stacked on top of the previous series.

JavaFX 2.1: javafx.scene.chart.StackedBarChart

package javafx21;

import java.util.Arrays;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.StackedBarChart;
import javafx.scene.chart.XYChart;
import javafx.stage.Stage;

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class Charts extends Application {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com");
Group root = new Group();

final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis();

xAxis.setLabel("Month");
xAxis.setCategories(FXCollections.<String> observableArrayList(Arrays.asList(
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December")));
yAxis.setLabel("Value");

final StackedBarChart<String,Number> stackedBarChart = new StackedBarChart<>(xAxis,yAxis);

stackedBarChart.setTitle("StackedBarChart");

//Series 1
XYChart.Series<String,Number> series1 = new XYChart.Series();
series1.setName("XYChart.Series 1");

series1.getData().add(new XYChart.Data("January", 100));
series1.getData().add(new XYChart.Data("February", 200));
series1.getData().add(new XYChart.Data("March", 50));
series1.getData().add(new XYChart.Data("April", 75));
series1.getData().add(new XYChart.Data("May", 110));
series1.getData().add(new XYChart.Data("June", 300));
series1.getData().add(new XYChart.Data("July", 111));
series1.getData().add(new XYChart.Data("August", 30));
series1.getData().add(new XYChart.Data("September", 75));
series1.getData().add(new XYChart.Data("October", 55));
series1.getData().add(new XYChart.Data("November", 225));
series1.getData().add(new XYChart.Data("December", 99));

//Series 2
XYChart.Series<String,Number> series2 = new XYChart.Series();
series2.setName("XYChart.Series 2");

series2.getData().add(new XYChart.Data("January", 150));
series2.getData().add(new XYChart.Data("February", 100));
series2.getData().add(new XYChart.Data("March", 60));
series2.getData().add(new XYChart.Data("April", 40));
series2.getData().add(new XYChart.Data("May", 30));
series2.getData().add(new XYChart.Data("June", 100));
series2.getData().add(new XYChart.Data("July", 100));
series2.getData().add(new XYChart.Data("August", 10));
series2.getData().add(new XYChart.Data("September", 175));
series2.getData().add(new XYChart.Data("October", 155));
series2.getData().add(new XYChart.Data("November", 125));
series2.getData().add(new XYChart.Data("December", 150));

//

stackedBarChart.getData().addAll(series1, series2);

root.getChildren().addAll(stackedBarChart);

primaryStage.setScene(new Scene(root, 500, 400));
primaryStage.show();
}
}


Next:
- Create dynamic StackedBarChart of JavaFX 2

Related:
- JavaFX 2: BarChart
- JavaFX 2.1: javafx.scene.chart.StackedAreaChart


Spring Hibernate JavaFX 2: BarChart

JavaFX 2: BarChart

package javafx21;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.chart.BarChart;
import javafx.scene.chart.CategoryAxis;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.XYChart;
import javafx.stage.Stage;

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class Charts extends Application {



/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com");
Group root = new Group();

final CategoryAxis xAxis = new CategoryAxis();
final NumberAxis yAxis = new NumberAxis();

xAxis.setLabel("Month");
yAxis.setLabel("Value");


final BarChart<String,Number> barChart = new BarChart<>(xAxis,yAxis);

barChart.setTitle("BarChart");

//Series 1
XYChart.Series series1 = new XYChart.Series();
series1.setName("XYChart.Series 1");

series1.getData().add(new XYChart.Data("January", 100));
series1.getData().add(new XYChart.Data("February", 200));
series1.getData().add(new XYChart.Data("March", 50));
series1.getData().add(new XYChart.Data("April", 75));
series1.getData().add(new XYChart.Data("May", 110));
series1.getData().add(new XYChart.Data("June", 300));
series1.getData().add(new XYChart.Data("July", 111));
series1.getData().add(new XYChart.Data("August", 30));
series1.getData().add(new XYChart.Data("September", 75));
series1.getData().add(new XYChart.Data("October", 55));
series1.getData().add(new XYChart.Data("November", 225));
series1.getData().add(new XYChart.Data("December", 99));

//Series 2
XYChart.Series series2 = new XYChart.Series();
series2.setName("XYChart.Series 2");

series2.getData().add(new XYChart.Data("January", 150));
series2.getData().add(new XYChart.Data("February", 100));
series2.getData().add(new XYChart.Data("March", 60));
series2.getData().add(new XYChart.Data("April", 40));
series2.getData().add(new XYChart.Data("May", 30));
series2.getData().add(new XYChart.Data("June", 100));
series2.getData().add(new XYChart.Data("July", 100));
series2.getData().add(new XYChart.Data("August", 10));
series2.getData().add(new XYChart.Data("September", 175));
series2.getData().add(new XYChart.Data("October", 155));
series2.getData().add(new XYChart.Data("November", 125));
series2.getData().add(new XYChart.Data("December", 150));

//

barChart.getData().addAll(series1, series2);

root.getChildren().addAll(barChart);

primaryStage.setScene(new Scene(root, 500, 400));
primaryStage.show();
}
}


Compare with JavaFX Area Chart

Spring Hibernate Embed OpenLayers with OpenStreetMap in JavaFX WebView

OpenLayers makes it easy to put a dynamic map in any web page. With OpenStreetMap, it's a free replacement of Google Maps. We can embed WebView loaded with OpenLayers in JavaFX to display map.

Embed OpenLayers with OpenStreetMap in JavaFX WebView


Create a HTML file, openstreetmap.html. Actually it's a normal web page HTML file.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<script type="text/javascript" src="http://openlayers.org/api/2.11/OpenLayers.js"></script>
<script type="text/javascript" >
var myMap;

function loadOpenLayers(){

myMap = new OpenLayers.Map("mymap", {});

var wms = new OpenLayers.Layer.WMS(
"OpenLayers WMS",
"http://vmap0.tiles.osgeo.org/wms/vmap0",
{layers: "basic"},
{});

myMap.addLayer(wms);

myMap.setCenter(new OpenLayers.LonLat(-122.349243, 47.651743));
myMap.zoomTo(6);
}

</script>
</head>
<body onload="loadOpenLayers();">
<div id="mymap" style="width: 620px; height: 460px; border: 1px solid;">
</div>

</body>
</html>


Java Code
package javafx_openstreetview;

import java.net.URL;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class JavaFX_OpenStreetView extends Application {

private Scene scene;
MyBrowser myBrowser;

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com");

myBrowser = new MyBrowser();
scene = new Scene(myBrowser, 640, 480);

primaryStage.setScene(scene);
primaryStage.show();
}

class MyBrowser extends Region{

HBox toolbar;

WebView webView = new WebView();
WebEngine webEngine = webView.getEngine();

public MyBrowser(){

final URL urlGoogleMaps = getClass().getResource("openstreetmap.html");
webEngine.load(urlGoogleMaps.toExternalForm());

getChildren().add(webView);

}
}
}


Related:
- Embed Google Maps in JavaFX WebView.
- Embed WebView in FXML, to load OpenLayers with OpenStreetMap.


Spring Hibernate Building my First JavaFX Application using NetBeans 7.1




Introduction: Building my First JavaFX Application using NetBeans 7.1
This is an Introduction for a series of videos about how to create a simple JavaFX application using NetBeans 7.1. This video will show you the final result, before you can go through the steps.

Spring Framework Open new window in JavaFX 2

The example demonstrate how to open new window in JavaFX 2, once button clicked.

Open new window in JavaFX 2


/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package testjavafxwindow;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class TestJavaFXWindow extends Application {

@Override
public void start(final Stage primaryStage) {
Button btn = new Button();
btn.setText("Open a New Window");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {

Label secondLabel = new Label("Hello");

StackPane secondaryLayout = new StackPane();
secondaryLayout.getChildren().add(secondLabel);

Scene secondScene = new Scene(secondaryLayout, 200, 100);

Stage secondStage = new Stage();
secondStage.setTitle("Second Stage");
secondStage.setScene(secondScene);

//Set position of second window, related to primary window.
secondStage.setX(primaryStage.getX() + 250);
secondStage.setY(primaryStage.getY() + 100);

secondStage.show();
}
});

StackPane root = new StackPane();
root.getChildren().add(btn);

Scene scene = new Scene(root, 300, 250);

primaryStage.setTitle("java-buddy.blogspot.com");
primaryStage.setScene(scene);
primaryStage.show();
}

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


Spring Framework Save WritableImage to file

To save WritableImage to file, e can use the code:


                    File file = new File("test.png");
RenderedImage renderedImage = SwingFXUtils.fromFXImage(writableImage, null);
ImageIO.write(
renderedImage,
"png",
file);


Where we render the image by calling SwingFXUtils.fromFXImage() and write to file by calling ImageIO.write().

Complete example:

Modify the code in last post "Create and adjust Color using hue, saturation, brightness". Add a button to save the image once button clicked.

package testjavafx;

import java.awt.image.BufferedImage;
import java.awt.image.RenderedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.embed.swing.SwingFXUtils;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Slider;
import javafx.scene.control.SliderBuilder;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.image.PixelReader;
import javafx.scene.image.PixelWriter;
import javafx.scene.image.WritableImage;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javax.imageio.ImageIO;

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class TestJavaFX extends Application {

PixelReader pixelReader;
int width, height;

WritableImage writableImage, writableImageHue, writableImageSaturation, writableImageBrightness;
PixelWriter pixelWriter, pixelWriterHue, pixelWriterSaturation, pixelWriterBrightness;
ImageView destImageView, imageViewHue, imageViewSaturation, imageViewBrightness;

Slider sliderHue, sliderSaturation, sliderBrightness;
double adjHue, adjSaturation, adjBrightness;

@Override
public void start(Stage primaryStage) {

Image image = new Image("http://goo.gl/kYEQl");
ImageView imageView = new ImageView();
imageView.setImage(image);

pixelReader = image.getPixelReader();
width = (int)image.getWidth();
height = (int)image.getHeight();

//Copy from source to destination pixel by pixel
writableImage = new WritableImage(width, height);
pixelWriter = writableImage.getPixelWriter();

writableImageHue = new WritableImage(width, height);
pixelWriterHue = writableImageHue.getPixelWriter();

writableImageSaturation = new WritableImage(width, height);
pixelWriterSaturation = writableImageSaturation.getPixelWriter();

writableImageBrightness = new WritableImage(width, height);
pixelWriterBrightness = writableImageBrightness.getPixelWriter();

destImageView = new ImageView();
imageViewHue = new ImageView();
imageViewSaturation = new ImageView();
imageViewBrightness = new ImageView();

HBox hBox_Image = new HBox();
hBox_Image.getChildren().addAll(imageView, destImageView);

//Control box for Hue
sliderHue = SliderBuilder.create()
.prefWidth(300)
.min(-360)
.max(360)
.majorTickUnit(30)
.showTickMarks(true)
.showTickLabels(true)
.value(0)
.build();
sliderHue.valueProperty().addListener(sliderChangeListener);
HBox hBox_Hue = new HBox();
hBox_Hue.getChildren().addAll(imageViewHue, sliderHue);

//Control box for Saturation
sliderSaturation = SliderBuilder.create()
.prefWidth(300)
.min(-1)
.max(1)
.majorTickUnit(0.2)
.showTickMarks(true)
.showTickLabels(true)
.value(0)
.build();
sliderSaturation.valueProperty().addListener(sliderChangeListener);
HBox hBox_Saturation = new HBox();
hBox_Saturation.getChildren().addAll(imageViewSaturation, sliderSaturation);

//Control box for Blue
sliderBrightness = SliderBuilder.create()
.prefWidth(300)
.min(-1)
.max(1)
.majorTickUnit(0.2)
.showTickMarks(true)
.showTickLabels(true)
.value(0)
.build();
sliderBrightness.valueProperty().addListener(sliderChangeListener);
HBox hBox_Brightness = new HBox();
hBox_Brightness.getChildren().addAll(imageViewBrightness, sliderBrightness);

Button buttonSave = new Button("Save");
buttonSave.setOnAction(new EventHandler<ActionEvent>() {

@Override
public void handle(ActionEvent event) {
try {
File file = new File("test.png");
RenderedImage renderedImage = SwingFXUtils.fromFXImage(writableImage, null);
ImageIO.write(
renderedImage,
"png",
file);
} catch (IOException ex) {
Logger.getLogger(TestJavaFX.class.getName()).log(Level.SEVERE, null, ex);
}
}
});

VBox vBox = new VBox();
vBox.getChildren().addAll(hBox_Image,
hBox_Hue, hBox_Saturation, hBox_Brightness, buttonSave);

StackPane root = new StackPane();
root.getChildren().add(vBox);
Scene scene = new Scene(root, 350, 400);
primaryStage.setTitle("java-buddy.blogspot.com");
primaryStage.setScene(scene);
primaryStage.show();

updateImage();
}

ChangeListener<Number> sliderChangeListener
= new ChangeListener<Number>(){

@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
updateImage();
}
};

private void updateImage(){
adjHue = sliderHue.valueProperty().doubleValue();
adjSaturation = sliderSaturation.valueProperty().doubleValue();
adjBrightness = sliderBrightness.valueProperty().doubleValue();

for (int y = 0; y < height; y++){
for (int x = 0; x < width; x++){
Color color = pixelReader.getColor(x, y);
pixelWriter.setColor(x, y, color);

double hue = color.getHue() + adjHue;
if(hue > 360.0){
hue = hue - 360;
}else if(hue < 0.0){
hue = hue + 360.0;
}

double saturation = color.getSaturation() + adjSaturation;
if(saturation > 1.0){
saturation = 1.0;
}else if(saturation < 0.0){
saturation = 0.0;
}

double brightness = color.getBrightness() + adjBrightness;
if(brightness > 1.0){
brightness = 1.0;
}else if(brightness < 0.0){
brightness = 0.0;
}

double opacity = color.getOpacity();

pixelWriterHue.setColor(x, y, new Color(hue/360.0, hue/360.0, hue/360.0, opacity));
pixelWriterSaturation.setColor(x, y, new Color(saturation, saturation, saturation, opacity));
pixelWriterBrightness.setColor(x, y, new Color(brightness, brightness, brightness, opacity));

Color newColor = Color.hsb(hue, saturation, brightness, opacity);
pixelWriter.setColor(x, y, newColor);

}
}

imageViewHue.setImage(writableImageHue);
imageViewSaturation.setImage(writableImageSaturation);
imageViewBrightness.setImage(writableImageBrightness);
destImageView.setImage(writableImage);
}

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



Spring Hibernate Video: JavaFX Canvas

JavaFX Canvas Node
A quick run through of what the JavaFX Canvas node is and how to use it in an application.

Spring Hibernate Detect mouse event

This exercise demonstrate how to detect MouseEvent for JavaFX 2.0.

detect MouseEvent for JavaFX 2.0
package javafx_mouseevent;

import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class JavaFX_MouseEvent extends Application {

Label label;

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com");
StackPane root = new StackPane();
Scene scene = new Scene(root, 300, 250);

label = new Label("Wait mouse");


scene.setOnMouseClicked(mouseHandler);
scene.setOnMouseDragged(mouseHandler);
scene.setOnMouseEntered(mouseHandler);
scene.setOnMouseExited(mouseHandler);
scene.setOnMouseMoved(mouseHandler);
scene.setOnMousePressed(mouseHandler);
scene.setOnMouseReleased(mouseHandler);

root.getChildren().add(label);
primaryStage.setScene(scene);
primaryStage.show();
}

EventHandler<MouseEvent> mouseHandler = new EventHandler<MouseEvent>() {

@Override
public void handle(MouseEvent mouseEvent) {
label.setText(mouseEvent.getEventType() + "\n"
+ "X : Y - " + mouseEvent.getX() + " : " + mouseEvent.getY() + "\n"
+ "SceneX : SceneY - " + mouseEvent.getSceneX() + " : " + mouseEvent.getSceneY() + "\n"
+ "ScreenX : ScreenY - " + mouseEvent.getScreenX() + " : " + mouseEvent.getScreenY());
}

};

}


Next:
- Free draw by MouseEvent



Spring Framework Simple example of JavaFX ComboBox

Simple example of JavaFX ComboBox
Simple example of JavaFX ComboBox


package javafxcombobox;

import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.ComboBox;
import javafx.scene.control.Label;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;

/**
* @web http://java-buddy.blogspot.com/
*/
public class JavaFXComboBox extends Application {

@Override
public void start(Stage primaryStage) {

final ComboBox comboBox = new ComboBox();
comboBox.getItems().addAll(
"Item 1",
"Item 2",
"Item 3",
"Item 4");
comboBox.setValue("Item 1");

final Label label = new Label();

Button btn = new Button();
btn.setText("Read comboBox");
btn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
label.setText("selectd: " + comboBox.getValue());
}
});

VBox vBox = new VBox();
vBox.setPadding(new Insets(5, 5, 5, 5));
vBox.setSpacing(5);
vBox.getChildren().addAll(label, comboBox, btn);

StackPane root = new StackPane();
root.getChildren().add(vBox);

Scene scene = new Scene(root, 300, 250);

primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}

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


Next: JavaFX ComboBox for custom object

Spring Hibernate JavaFX 2.0: TranslateTransition



package javafx_imagetransition;

import javafx.animation.*;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import javafx.util.Duration;

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class JavaFX_ImageTransition extends Application {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

Scene scene;

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("http://java-buddy.blogspot.com/");
StackPane root = new StackPane();
scene = new Scene(root, 300, 250);

VBox vBox = new VBox();
vBox.setSpacing(3);

final Image image1 = new Image(getClass().getResourceAsStream("duke_44x80.png"));
final ImageView imageView = new ImageView();
imageView.setImage(image1);

final TranslateTransition transitionForward
= createTransitionForward(imageView);
final TranslateTransition transitionBackward
= createTransitionBackward(imageView);

Button btnForward = new Button();
btnForward.setText("Forward");
btnForward.setOnAction(new EventHandler<ActionEvent>() {

@Override
public void handle(ActionEvent event) {
transitionForward.play();
}
});

Button btnBackward = new Button();
btnBackward.setText("Backward");
btnBackward.setOnAction(new EventHandler<ActionEvent>() {

@Override
public void handle(ActionEvent event) {
transitionBackward.play();
}
});

vBox.getChildren().add(imageView);
vBox.getChildren().add(btnForward);
vBox.getChildren().add(btnBackward);

root.getChildren().add(vBox);
primaryStage.setScene(scene);
primaryStage.show();
}

TranslateTransition createTransitionForward(final ImageView iv){
TranslateTransition transition = TranslateTransitionBuilder.create()
.node(iv)
.fromX(0)
.toX(scene.widthProperty().doubleValue() - iv.getImage().getWidth())
.fromY(0)
.toY(scene.heightProperty().doubleValue() - iv.getImage().getHeight())
.duration(Duration.millis(1000))
.interpolator(Interpolator.LINEAR)
.cycleCount(1)
.build();

return transition;
}

TranslateTransition createTransitionBackward(final ImageView iv){
TranslateTransition transition = TranslateTransitionBuilder.create()
.node(iv)
.fromX(scene.widthProperty().doubleValue() - iv.getImage().getWidth())
.toX(0)
.fromY(scene.heightProperty().doubleValue() - iv.getImage().getHeight())
.toY(0)
.duration(Duration.millis(1000))
.interpolator(Interpolator.LINEAR)
.cycleCount(1)
.build();

return transition;
}
}



Read more: Implement setOnFinished() to handle end of Transition

Spring Hibernate Define the range and space of NumberAxis in JavaFX charts

In the last post of StackedAreaChart, the month axis is displayed from 0~13. In order to specify the horizontal axis, we can use 3-parameters/4-parameters constructor of NumberAxis.

public NumberAxis(double lowerBound, double upperBound, double tickUnit)
Create a non-auto-ranging NumberAxis with the given upper bound, lower bound and tick unit.
Parameters:
  • lowerBound - The lower bound for this axis, ie min plottable value
  • upperBound - The upper bound for this axis, ie max plottable value
  • tickUnit - The tick unit, ie space between tickmarks

Example:

package javafx21;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.StackedAreaChart;
import javafx.scene.chart.XYChart;
import javafx.stage.Stage;

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class Charts extends Application {



/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com");
Group root = new Group();

//final NumberAxis xAxis = new NumberAxis();
//Use 3 parameter constructor to define the min, max and space of the axis
final NumberAxis xAxis = new NumberAxis(1, 12, 1);

final NumberAxis yAxis = new NumberAxis();
final StackedAreaChart<Number,Number> stackedAreaChart = new StackedAreaChart<>(xAxis,yAxis);
final XYChart.Series<Number,Number> series1 = new XYChart.Series<>();

xAxis.setLabel("Month");
yAxis.setLabel("Value");

stackedAreaChart.setTitle("StackedAreaChart");

//Series 1

series1.setName("XYChart.Series 1");

series1.getData().add(new XYChart.Data(1, 100));
series1.getData().add(new XYChart.Data(2, 200));
series1.getData().add(new XYChart.Data(3, 50));
series1.getData().add(new XYChart.Data(4, 75));
series1.getData().add(new XYChart.Data(5, 110));
series1.getData().add(new XYChart.Data(6, 300));
series1.getData().add(new XYChart.Data(7, 111));
series1.getData().add(new XYChart.Data(8, 30));
series1.getData().add(new XYChart.Data(9, 75));
series1.getData().add(new XYChart.Data(10, 55));
series1.getData().add(new XYChart.Data(11, 225));
series1.getData().add(new XYChart.Data(12, 99));

//Series 2
XYChart.Series<Number,Number> series2 = new XYChart.Series();
series2.setName("XYChart.Series 2");

series2.getData().add(new XYChart.Data(1, 50));
series2.getData().add(new XYChart.Data(2, 200));
series2.getData().add(new XYChart.Data(3, 260));
series2.getData().add(new XYChart.Data(4, 100));
//series2.getData().add(new XYChart.Data(5, 100));
series2.getData().add(new XYChart.Data(6, 100));
series2.getData().add(new XYChart.Data(7, 0));
//series2.getData().add(new XYChart.Data(8, 0));
series2.getData().add(new XYChart.Data(9, 0));
series2.getData().add(new XYChart.Data(10, 100));
//series2.getData().add(new XYChart.Data(11, 150));
series2.getData().add(new XYChart.Data(12, 200));

//

stackedAreaChart.getData().addAll(series1, series2);

root.getChildren().addAll(stackedAreaChart);

primaryStage.setScene(new Scene(root, 500, 400));
primaryStage.show();
}
}


Spring Hibernate JavaFX 2.1: javafx.scene.chart.StackedAreaChart

JavaFX 2.1 introduce a new StackedAreaChart class. StackedAreaChart is a variation of AreaChart that displays trends of the contribution of each value. (over time e.g.) The areas are stacked so that each series adjoins but does not overlap the preceding series. This contrasts with the Area chart where each series overlays the preceding series. The cumulative nature of the StackedAreaChart gives an idea of the total Y data value at any given point along the X axis. Since data points across multiple series may not be common, StackedAreaChart interpolates values along the line joining the data points whenever necessary.


In the example, some column in series 2 are missed. From the graph, it can be noticed how JavaFX display the StackedAreaChart with missed column.

package javafx21;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.chart.NumberAxis;
import javafx.scene.chart.StackedAreaChart;
import javafx.scene.chart.XYChart;
import javafx.stage.Stage;

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class Charts extends Application {



/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com");
Group root = new Group();

final NumberAxis xAxis = new NumberAxis();
final NumberAxis yAxis = new NumberAxis();
final StackedAreaChart<Number,Number> stackedAreaChart = new StackedAreaChart<>(xAxis,yAxis);
final XYChart.Series<Number,Number> series1 = new XYChart.Series<>();

xAxis.setLabel("Month");
yAxis.setLabel("Value");

stackedAreaChart.setTitle("StackedAreaChart");

//Series 1

series1.setName("XYChart.Series 1");

series1.getData().add(new XYChart.Data(1, 100));
series1.getData().add(new XYChart.Data(2, 200));
series1.getData().add(new XYChart.Data(3, 50));
series1.getData().add(new XYChart.Data(4, 75));
series1.getData().add(new XYChart.Data(5, 110));
series1.getData().add(new XYChart.Data(6, 300));
series1.getData().add(new XYChart.Data(7, 111));
series1.getData().add(new XYChart.Data(8, 30));
series1.getData().add(new XYChart.Data(9, 75));
series1.getData().add(new XYChart.Data(10, 55));
series1.getData().add(new XYChart.Data(11, 225));
series1.getData().add(new XYChart.Data(12, 99));

//Series 2
XYChart.Series<Number,Number> series2 = new XYChart.Series();
series2.setName("XYChart.Series 2");

series2.getData().add(new XYChart.Data(1, 50));
series2.getData().add(new XYChart.Data(2, 200));
series2.getData().add(new XYChart.Data(3, 260));
series2.getData().add(new XYChart.Data(4, 100));
//series2.getData().add(new XYChart.Data(5, 100));
series2.getData().add(new XYChart.Data(6, 100));
series2.getData().add(new XYChart.Data(7, 0));
//series2.getData().add(new XYChart.Data(8, 0));
series2.getData().add(new XYChart.Data(9, 0));
series2.getData().add(new XYChart.Data(10, 100));
//series2.getData().add(new XYChart.Data(11, 150));
series2.getData().add(new XYChart.Data(12, 200));

//

stackedAreaChart.getData().addAll(series1, series2);

root.getChildren().addAll(stackedAreaChart);

primaryStage.setScene(new Scene(root, 500, 400));
primaryStage.show();
}
}


Related:
- Define the range and space of NumberAxis in JavaFX charts
- JavaFX 2.1: javafx.scene.chart.StackedBarChart


Spring Hibernate Embed Google Maps in JavaFX WebView

The Google Maps Javascript API lets you embed Google Maps in your own web pages. With WebView in JavaFX 2.0, you can easy embed Google Maps in your Java application.

Embed Google Maps in JavaFX WebView

Create a googlemaps.html to embed Google Maps in web page.
<!DOCTYPE html>
<html>
<head>
<title>Java-Buddy: Google Maps</title>
<script src="http://maps.google.com/maps/api/js?sensor=false"></script>
<style>#mapcanvas { height: 360px; width: 100%}</style>

<script>
var map;
function loadmap(){

var options = {
zoom: 16,
center: new google.maps.LatLng(51.507222, -0.1275),
mapTypeId: google.maps.MapTypeId.SATELLITE
}
map = new google.maps.Map(document.getElementById("mapcanvas"), options);
}

</script>

</head>
<body onload="loadmap()">
<h1>Java-Buddy: Google Maps</h1>
<div id="mapcanvas"></div>
</body>
</html>


Embed googlemaps.html in WebView in your Java application.
package javafx_googlemaps;

import java.net.URL;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.geometry.VPos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Region;
import javafx.scene.layout.StackPane;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebEvent;
import javafx.scene.web.WebView;
import javafx.stage.Stage;

/**
*
* @web http://java-buddy.blogspot.com/
*/
public class JavaFX_GoogleMaps extends Application {

private Scene scene;
MyBrowser myBrowser;

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
launch(args);
}

@Override
public void start(Stage primaryStage) {
primaryStage.setTitle("java-buddy.blogspot.com");

myBrowser = new MyBrowser();
scene = new Scene(myBrowser, 640, 480);

primaryStage.setScene(scene);
primaryStage.show();
}

class MyBrowser extends Region{

HBox toolbar;

WebView webView = new WebView();
WebEngine webEngine = webView.getEngine();

public MyBrowser(){

final URL urlGoogleMaps = getClass().getResource("googlemaps.html");
webEngine.load(urlGoogleMaps.toExternalForm());

getChildren().add(webView);

}

}
}


Related:
- Embed OpenLayers with OpenStreetMap in JavaFX WebView


Labels

.equals = operator abstract class abstract method abstract window toolkit Access Modifiers accessing java beans accessing javabeans action events actionperformed active addition Advanced Advanced Overloading AdvJavaBooks Agile development ajax alive AMQP and Android anonymous class anonymous inner class Ant ant tutorials anti patterns antipatterns Apache Camel api for jsp api for servlet api for servlets api jsp application context application scope application session Apps Architecture are you eligible for the ocmjd certificaiton are you eligible for the scjd certification arithmetic operator arpanet array construction array declaration array initialization array list array to list conversion arraylist arraylist of strings arraylist of types arraylist questions arraylists Arrays arrays in java ask for help assert assert in java assertions assertions in java assignment assignment operator Atlassian attribute visibility authentication authorization autoboxing autounboxing awt AWT Event Handling awt interview questions AWT Layouts awt questions awt questions and answers backed collection backed collections Basic Basics of event handling bean attributes bean properties bean scope Beginner best practices BigData blocked books boxing buffer size bufferedreader bufferedwriter business delegate business delegate pattern calendar case statement casting in java casting interview questions chapter review choosing a java locking mechanism choosing a locking mechanism choosing a thread locking mechanism class inside a method class questions class with no name class without a name classes interview questions Clipboard closing jsp tags code snap coding cohesion collection generics collection interview questions collection methods collection of types collection questions collection searching collection types Collections Collections Framework collections interview questions collections sorting colors in java swings colors in swing command line arguments communication between threads comparable comparator comparison operators compiling java classes computers concurrency example and tutorial config Configuration ConnectionPooling constructor creation constructor interview questions constructor overloading constructors in java containers contents of deployment descriptor contents of web.xml context context scope converting array to list converting list to array core java core java interview core java interview question core java interview questions core java questions core java; core java; object oriented programming CoreJava CoreJavaBooks CORS coupling create threads creating 2 dimensional shapes creating 2D shapes creating a frame creating a jframe creating a thread creating an arraylist creating an inner class creating an interface creating java beans creating java threads creating javabeans creating threads creating threads in java CSS cURL currency current thread determination custom tag library custom taglib custom taglibs custom tags CVS dao dao design pattern dao factory pattern dao pattern data access object data access object pattern data structure and algorithm database date and time tutorial date format dateformat dates deadlock deadlocks debugging Declarations decorator pattern decrement default deleting sessions deploy web app deployment deployment descriptor deployment descriptor contents deployment of web application deserialization deserialize design pattern design pattern interview questions design patterns Designpatterns destory method destroy destroying sessions determining current thread determining the current thread Developer Differences different types of collections display stuff in a frame displaying images displaying images in java swings displaying images in swings displaying text in a component division do while loop doget dohead dopost doput DOS Downloads drawing a line drawing an ellipse drawing circles drawing ellipses drawing lines Drools tutorial eBooks Eclipse Eclipse Tutorial Encapsulation encapsulation in java enhanced for loop entity facade pattern enumerations enumerations in java enums equal to equals equals comparison error and exception error codes error handling in servlets error page event handling in swings event listeners exam prep tips example servlet Examples exception exception handling exception handling in servlets exception handling interview questions exception handling questions Exceptions exceptions in java exceptions in web applications explicit locking explicit locking of objects file file navigation filereader filewriter final class final method FireBug first servlet FIX protocol FIX Protocol interview questions FIX protocol tutorial font fonts for each loop for loop form parameters form values formatting forwarding requests frame frame creation frame positioning frame swings front controller front controller design pattern front controller pattern fundamental.Java FXML Games garbage collection garbage collection interview questions garbage collection questions garbage collector gc gc questions general generic Generics generics collections Geo get get set methods getattribute getting bean property getting form values getting form values in servlet getting scwcd certified getting servlet initialization parameters getting sun certified Google Graphics2D gregorian calendar handling strings in java hash hash map hash table hashcode hashmap hashset hashtable head head request HeadFirst heap heaps hibernate hibernate interview questions hibernate interview questions and answers hibernate questions hibernate questions and answers Hibernate Tutorial HibernateBooks homework How To HTML HTML and JavaScript html form http request http request handling http request header http request methods http request servlet http request type http session httprequest httprequest methods httpservlet httpservlet interview questions httpservlet interview questions with answers httpsession httpsession interview questions httpsession questions HttpSessionActivationListener HttpSessionAttributeListener HttpSessionBindingListener if if else if else block if else statement Image IO implementing an interface Implicit objects increment info inheritance inheritance in java init init method Initialization Blocks inner class inner class inside a method inner classes innerclass installation instanceof instanceof operator IntelliJ interaction between threads interface interface interview interface questions interfaces interfaces in java interfaces interview questions internet history interrupting a thread interrupting threads Interview interview questions interview questions on design patterns interview questions on exception handling interview questions on java collections interview questions on serialization introduction to java threads introduction to jsps introduction to threading introduction to threads invalidating session Investment Banking IO Package iscurrentthread iterator J2EE j2ee api j2ee design pattern j2ee design pattern interview questions j2ee design patterns j2ee hibernate interview questions j2ee history j2ee interview j2ee interview questions j2ee mvc j2ee mvc pattern j2ee programmer j2ee questions j2ee servlet api j2ee session j2ee struts interview questions java java 5 tutorial Java 8 java arrays java assertions java assignments java awt questions java bean java bean scope java beans java beginners tutorial Java career java certification Java Class java collection interview questions and answers java collection tutorial java collections java collections interview questions java constructors java currency Java CV java data base connectivity java database connectivity java database connectivity interview questions and answers java dates java design pattern java design patterns java developer certification Java EE java encapsulation java enums java event listeners java exceptions java formatting java garbage collection java garbage collector java gc java heap Java I/O java inheritance java input output Java Interface Java Interview Java Interview Answers Java Interview Questions Java Introduction java io java IO tutorial java iterator java jdbc Java JSON tutorial Java Key Areas java lists java literals java locks nested Java Media Framework java methods java multithreading Java multithreading Tutorials java nested locks java networking tutorial java numbers Java Objects java operators java overloading java parsing Java Programming Tutorials java race conditions java regex java regular expressions Java resume java scjp java searching java serialization java server pages java server pages api java server pages questions java spring interview questions. j2ee spring interview questions java stack java strings java swing java swing event listeners java swing frame java swing images java swings java swings images java thread explicit locking java thread lock scope java thread locking java thread locking mechanism java thread locking objects java threads java threads race condition java tips java tokenizing Java Tools Java Tutorial java ui questions Java Utilities java variables java wrappers Java xml tutorial java.lang java8 javabean javabean accessing javabean scope JavaBeans javac JavaEE JavaFX JavaFX 3D JavaFX 8 JavaOne JavaScript JavaTips JDBC jdbc driver jdbc example jdbc interview questions jdbc interview questions and answers jdbc interview questions with answers jdbc sample code JDBC Tutorial jdbc type 1 driver jdbc type 2 driver jdbc type 3 driver jdbc type 4 driver Jdeveloper JDK JDK8 JEE Tutorial jframe jframe creation jframe position jframe positioning JIRA JMeter JMS JMX join() joining threads JPA JQuery JS JSF JSF Tutorial JSONP JSP jsp and java beans jsp and servlets jsp and xml jsp api jsp code jsp compilation jsp conversion jsp directives jsp error page jsp error page directive jsp implicit objects jsp interview jsp interview questions jsp introduction jsp intvw questions jsp life jsp life cycle jsp life-cycle jsp lifecycle jsp page directive jsp questions jsp sample jsp scripting jsp scriptlets jsp servlets jsp summary jsp synopsis jsp tag libraries jsp tag library jsp taglib jsp tags jsp technology jsp to servlet jsp to servlet conversion jsp translation jsp usage jsp usebean jsp xml tags jsp xml tags usage jsp-servlet jsp:getProperty jsp:setProperty jsp:usebean jsps JSTL JUnit testing keyword synchronized keyword volatile Keywords Lambda Expressions Learning libraries life cycle life cycle of a jsp life cycle of a servlet life cycle of a thread life cycle of jsp life cycle of threads lifecycle of a thread linked list linkedhashmap linkedhashset linkedlist linux List listeners lists Literals locale lock manager pattern lock scope locking objects using threads log Logging logging errors logical and logical operators logical or loops loosely coupled making an arraylist making threads sleep making threads sleep for time MapReduce maps maps usage Maven Maven Tutorial max priority member access method arguments method local inner class method overloading method overriding method return types methods creating classes min priority Miscellaneous mobile mock exam model view controller model view controller design pattern model view controller pattern Multi Threading Multi-threading multiple threads multiplication multithreading multithreading in java multithreading interview questions multithreading questions mvc mvc design pattern mvc pattern MyEclipse mysql nested java lock nested java locks nested java thread locks nested locks nested thread locks NetBeans Networking new news nio NonAccess Modifiers norm priority normal inner class Normalization not equal to Notepad notify notifyall number format numberformat numbers object comparison object notify object orientation object oriented object oriented programming Object Oriented Programming in java objects interview questions ocmjd certification ocmjd certification eligibility OO OO Java oops OpenCSV OpenCV opening jsp tags OpenJDK OpenJFX Operators or Oracle Oracle ADF Mobile Oracle Certified Exams oracle certified master java developer oracle database ORM other topics out overloading overloading constructors overloading in java overriding page page directive page scope parsing passing variables passing variables to methods performance Platform Playing with Numbers points to remember polymorphism positioning a frame post practice exam Primitive Casting primitive variables printwriter priority queue priority queues priorityqueue priorityqueues private processing form values Products programming Projects protected public put questions questions on garbage collection questions on java strings queue quick recap quick review race conditions read objects from stream reading http request header RealTime_Tips redirecting to another servlet redirection reference reference variable casting reference variables Refreshing Java regex Regular Expressions regular inner class relational operators reminder request request dispatcher request forwarding request header request object. httpservletrequest request scope requestdispatcher response RESTClient RESTful retrieving values from session return error codes return types returning values runnable runnable interface running running java programs RUP sample jsp sample questions sample questions scwcd sample servlet scanner Scene Builder scjd certification scjd certification eligibility requirements scjp SCJP Certification scjp exam scjp exam questions scjp exam sample questions scjp questions scjp test scjp test questions scope scope of java locks scope of java thread locks scope of locks scripting in jsp scriptlet tags scriptlets scriptlets in jsp pages scwcd scwcd certification scwcd certification practice exam scwcd exam scwcd exam questions scwcd jsp summary scwcd mock exam scwcd mock exam answers scwcd practice exam scwcd practice test scwcd questions scwcd test SDLC searching searching arrays searching collections searching in java searching treemap searching treesets security self assement self assement scwcd self assessment scjp self test self test scjp self test scwcd send error method senderror method sending error code to browser serialization serialization in java serialization interview questions Serialization on Swing serialization questions service service method servlet servlet and forms servlet and jsp servlet api servlet attributes servlet code servlet container servlet context servlet error handling servlet exception handling servlet handling http request servlet initialization servlet initialization parameters servlet interview servlet interview questions servlet interview questions with answers servlet intvw questions servlet life cycle servlet lifecycle servlet questions servlet questions with answers servlet request servlet request dispatcher servlet request type servlet skeleton servletcontext servletcontextevent servletrequest Servlets servlets and jsps servlets api servlets details servlets request handling session session clean up session event listeners session facade pattern session interview questions session invalidation session listeners session management session questions session scope session timeout session tracking through url rewriting set collections set status method setattribute sets setstatus method setting bean property setting request type short circuit operators Singleton sleep sleeping threads soapUI Software Installation sorting sorting arraylist sorting arrays sorting collections special collections special inner classes split spring spring and hibernate interview questions spring batch Spring Core Spring Framework Spring Integration spring interview questions Spring JDBC Spring MVC Spring security Spring tutorial SQL SQL and database tutorial examples SQL Tutorial SSL stack stacks stacks and heaps static static class static declaration static imports static inner static inner class static method Static variable stopped stopping a thread stopping thread stopping threads Stored Procedure storing values in session Streams strictfp StrictMath string string buffer string builder string class string formatting String Handling string interview questions string manupulation string questions string tokenizer stringbuffer stringbuffer questions stringbuilder Strings strings in java struts Struts 1 Struts 1.2 Struts 2 struts framework interview questions struts interview questions struts interview questions with answers struts mvc interview questions struts questions Struts2 StrutsBooks submitting request subtraction Sun Certification sun certified java developer Sun Certified Java Programmer swing swing action performed swing and colors Swing Components swing event handling swing event listeners swing events Swing Hacks swing images Swing Look And Feels swings swings frame switch block switch case block switch case statement Sybase Sybase and SQL Server synchronization synchronized code synchronized keyword synchronized method System Properties tag lib tag library tag-lib taglibs tags TDD Technical Blogging ternary operator Test Driven Development test scjp Testing the context the session the volatile keyword thread thread class thread deadlocks thread interaction thread interruption thread life cycle thread lifecycle thread lock scope thread locks thread notify thread priorities thread race conditions race conditions in threads thread sleep thread states thread stoppage thread stopping thread synchronization thread syncing thread yield Threads threads in java threads interview questions threads life cycle threads questions tibco tightly coupled tips tips and tricks tips.FXML tokenizing Tomcat Tools toString transitions treemap treeset tricks Tricks Bag try catch try catch finally. finally block Tutorial type casting in java ui programming with java swings UML unboxing unit testing unix url rewriting use bean usebean using a arraylist using collections using colors using colours using command line arguments using different fonts using expressions using font using fonts using fonts in swings using hashmap using http session using httpsession using iterator using java beans in jsp using javabean in jsp using javabeans in jsp using javac using lists using maps using request dispatcher using scriptlets using session persistense using sets using special fonts using system properties using the jsp use bean using treeset using use bean Using Variables using volatile Using Wrappers using xml in jsp Util pack value object value object design pattern value object pattern var-args varargs Variable Arguments Variables vector vector questions vectors visibility vo pattern volatile volatile keyword volatile variables wait method waiting web app exception handling web app interview web application deployment web application exceptions web application scope web application security web component developer web component developer certification web context web context interfaces web context listeners web interview questions web security web server web servers Web services web.xml web.xml deployment webapp log weblogic website hacking website security what are threads what is a java thread what is a thread what is thread while loop windows windows 8 wrapper classes wrappers write objects to stream WSAD xml xml and jsp xml tags xslt yield()