Saturday, December 27, 2014
JavaFX + ImageIO: Convert PNG file to JPG
This example show how to choose PNG file using JavaFX FileChooser, open with ImageIO (actually any supported image format), and save in JPG using ImageIO.
[フレーム]
package javafximagefilechooser;
import java.awt.Color;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.embed.swing.SwingFXUtils;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import javax.imageio.ImageIO;
/**
*
* @web http://java-buddy.blogspot.com
*/
public class JavaFXImageFileChooser extends Application {
@Override
public void start(Stage primaryStage) {
final FileChooser fileChooser = new FileChooser();
final Button openButton = new Button("Open Image");
openButton.setOnAction(
new EventHandler<ActionEvent>() {
@Override
public void handle(final ActionEvent e) {
setExtFilters(fileChooser);
File file = fileChooser.showOpenDialog(primaryStage);
if (file != null) {
openNewImageWindow(file);
}
}
});
StackPane root = new StackPane();
root.getChildren().add(openButton);
Scene scene = new Scene(root, 400, 150);
primaryStage.setTitle("java-buddy.blogspot.com");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
private void setExtFilters(FileChooser chooser){
chooser.getExtensionFilters().addAll(
new FileChooser.ExtensionFilter("All Images", "*.*"),
new FileChooser.ExtensionFilter("PNG", "*.png")
);
}
private void openNewImageWindow(File file){
Stage secondStage = new Stage();
MenuBar menuBar = new MenuBar();
Menu menuFile = new Menu("File");
MenuItem menuItem_Save = new MenuItem("Save Image");
menuFile.getItems().addAll(menuItem_Save);
menuBar.getMenus().addAll(menuFile);
Label name = new Label(file.getAbsolutePath());
BufferedImage bufferedImage = null;
try {
bufferedImage = ImageIO.read(file);
} catch (IOException ex) {
Logger.getLogger(JavaFXImageFileChooser.class.getName()).log(Level.SEVERE, null, ex);
}
ImageView imageView = new ImageView();
final BufferedImage imageToWrite =
new BufferedImage(
bufferedImage.getWidth(),
bufferedImage.getHeight(),
BufferedImage.TYPE_INT_RGB);
imageToWrite.createGraphics().drawImage(bufferedImage, 0, 0, Color.WHITE, null);
menuItem_Save.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Save Image");
File file = fileChooser.showSaveDialog(secondStage);
if (file != null) {
try {
ImageIO.write(imageToWrite, "jpg", file);
} catch (IOException ex) {
Logger.getLogger(
JavaFXImageFileChooser.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
});
final VBox vbox = new VBox();
vbox.setAlignment(Pos.CENTER);
vbox.setSpacing(10);
vbox.setPadding(new Insets(0, 10, 0, 10));
vbox.getChildren().addAll(name, imageView);
imageView.setFitHeight(400);
imageView.setPreserveRatio(true);
imageView.setImage(SwingFXUtils.toFXImage(bufferedImage, null));
imageView.setSmooth(true);
imageView.setCache(true);
Scene scene = new Scene(new VBox(), 400, 350);
((VBox)scene.getRoot()).getChildren().addAll(menuBar, vbox);
secondStage.setTitle(file.getName());
secondStage.setScene(scene);
secondStage.show();
}
}
標籤:
ImageIO,
JavaFX,
JavaFX 8 example
Thursday, December 25, 2014
JavaFX FileChooser, open and save image file
Example to open and save png files, using JavaFX FileChooser.
package javafximagefilechooser;
import java.awt.Desktop;
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javafx.application.Application;
import javafx.embed.swing.SwingFXUtils;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Menu;
import javafx.scene.control.MenuBar;
import javafx.scene.control.MenuItem;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.stage.FileChooser;
import javafx.stage.Stage;
import javax.imageio.ImageIO;
/**
*
* @web http://java-buddy.blogspot.com
*/
public class JavaFXImageFileChooser extends Application {
@Override
public void start(Stage primaryStage) {
final FileChooser fileChooser = new FileChooser();
final Button openButton = new Button("Open Image");
openButton.setOnAction(
new EventHandler<ActionEvent>() {
@Override
public void handle(final ActionEvent e) {
setExtFilters(fileChooser);
File file = fileChooser.showOpenDialog(primaryStage);
if (file != null) {
openNewImageWindow(file);
}
}
});
StackPane root = new StackPane();
root.getChildren().add(openButton);
Scene scene = new Scene(root, 400, 150);
primaryStage.setTitle("java-buddy.blogspot.com");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
private void setExtFilters(FileChooser chooser){
chooser.getExtensionFilters().addAll(
new FileChooser.ExtensionFilter("All Images", "*.*"),
new FileChooser.ExtensionFilter("PNG", "*.png")
);
}
private void openNewImageWindow(File file){
Stage secondStage = new Stage();
MenuBar menuBar = new MenuBar();
Menu menuFile = new Menu("File");
MenuItem menuItem_Save = new MenuItem("Save Image");
menuFile.getItems().addAll(menuItem_Save);
menuBar.getMenus().addAll(menuFile);
Label name = new Label(file.getAbsolutePath());
Image image = new Image(file.toURI().toString());
ImageView imageView = new ImageView();
menuItem_Save.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("Save Image");
File file = fileChooser.showSaveDialog(secondStage);
if (file != null) {
try {
ImageIO.write(SwingFXUtils.fromFXImage(imageView.getImage(),
null), "png", file);
} catch (IOException ex) {
Logger.getLogger(
JavaFXImageFileChooser.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
});
final VBox vbox = new VBox();
vbox.setAlignment(Pos.CENTER);
vbox.setSpacing(10);
vbox.setPadding(new Insets(0, 10, 0, 10));
vbox.getChildren().addAll(name, imageView);
imageView.setFitHeight(400);
imageView.setPreserveRatio(true);
imageView.setImage(image);
imageView.setSmooth(true);
imageView.setCache(true);
Scene scene = new Scene(new VBox(), 400, 350);
((VBox)scene.getRoot()).getChildren().addAll(menuBar, vbox);
secondStage.setTitle(file.getName());
secondStage.setScene(scene);
secondStage.show();
}
}
[フレーム]
標籤:
JavaFX,
JavaFX 8 example
Wednesday, December 24, 2014
To list ImageIO supported read/write file format on your system
Example to list suffixes, format names and MIME types of supported image format on your system, by ImageIO, for read and write.
package javasupportedimageformat;
import javax.imageio.ImageIO;
/**
*
* @web http://java-buddy.blogspot.com
*/
public class JavaSupportedImageFormat {
public static void main(String[] args) {
//reader support
System.out.println("ImageIO reader supported file suffixes:");
String readerFileSuffixes[] = ImageIO.getReaderFileSuffixes();
for(String f : readerFileSuffixes){
System.out.println(f);
}
System.out.println();
System.out.println("ImageIO reader supported format names:");
String readerFormatNames[] = ImageIO.getReaderFormatNames();
for(String f : readerFormatNames){
System.out.println(f);
}
System.out.println();
System.out.println("ImageIO reader supported MIME types:");
String readerMIMETypes[] = ImageIO.getReaderMIMETypes();
for(String f : readerMIMETypes){
System.out.println(f);
}
System.out.println();
//writer support
System.out.println("ImageIO writer supported file suffixes:");
String writerFileSuffixes[] = ImageIO.getWriterFileSuffixes();
for(String f : writerFileSuffixes){
System.out.println(f);
}
System.out.println();
System.out.println("ImageIO writer supported format names:");
String writerFormatNames[] = ImageIO.getWriterFormatNames();
for(String f : writerFormatNames){
System.out.println(f);
}
System.out.println();
System.out.println("ImageIO writer supported MIME types:");
String writerMIMETypes[] = ImageIO.getWriterMIMETypes();
for(String f : writerMIMETypes){
System.out.println(f);
}
System.out.println();
}
}
Monday, December 22, 2014
Building home gateways with Eclipse SmartHome
[フレーム]
Despite the buzz around the Internet of Things (IoT) there are still many devices, systems and protocols for home automation that cannot be directly hooked up to your wifi and used through IP.
To enable smartphone apps to access them and to integrate them with other devices, an IP gateway is required - if it connects to more than just one specific system, this is usually called a home gateway.
Eclipse SmartHome is a flexible software framework for such home gateways. Being initiated by the popular open-source project openHAB, the Eclipse SmartHome project leads the way from the niche to the mass market by fostering industry adoption and by introducing new concepts for setup and configuration procedures of such solutions.
In this webinar you will learn about the concepts of Eclipse SmartHome, what services it provides and how to build a customized solution with it.
Slides are available on Slideshare: http://slideshare.net/xthirtynine/eclipse-smart-home-webinar
Saturday, December 13, 2014
get NetworkInterface and my IP address
Example to display name and ip address of NetworkInterface.
reference: https://docs.oracle.com/javase/tutorial/networking/nifs/listing.html
reference: https://docs.oracle.com/javase/tutorial/networking/nifs/listing.html
package javamyipaddress;
import static java.lang.System.out;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.SocketException;
import java.util.Collections;
import java.util.Enumeration;
/**
*
* @web http://java-buddy.blogspot.com/
* ref: https://docs.oracle.com/javase/tutorial/networking/nifs/listing.html
*/
public class JavaMyIpAddress {
public static void main(String args[]) throws SocketException {
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netint : Collections.list(nets))
displayInterfaceInformation(netint);
}
static void displayInterfaceInformation(NetworkInterface netint) throws SocketException {
out.printf("Display name: %s\n", netint.getDisplayName());
out.printf("Name: %s\n", netint.getName());
Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();
for (InetAddress inetAddress : Collections.list(inetAddresses)) {
out.printf("InetAddress: %s\n", inetAddress);
}
out.printf("\n");
}
}
Saturday, December 6, 2014
JavaFX example, setCursor() and getCursor()
JavaFX example to set cursor type to node by calling setCursor() and get cursor type by calling getCursor().
[フレーム]
package javafxhello;
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.scene.Cursor;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class JavaFXHello extends Application {
Scene scene;
Button createButton(Cursor cursor) {
Button btn = new Button();
btn.setMnemonicParsing(false);
//Sets the value of the property mnemonicParsing false to display '_'.
/*
MnemonicParsing property to enable/disable text parsing.
If this is set to true, then the Label text will be parsed
to see if it contains the mnemonic parsing character '_'.
When a mnemonic is detected the key combination will be
determined based on the succeeding character,
and the mnemonic added.
*/
btn.setCursor(cursor);
btn.setText(btn.getCursor().toString());
btn.setOnAction((ActionEvent event) -> {
Node src = (Node) event.getSource();
scene.setCursor(src.getCursor());
});
return btn;
}
@Override
public void start(Stage primaryStage) {
VBox vBox = new VBox();
scene = new Scene(vBox, 300, 250);
Button btnCLOSED_HAND = createButton(Cursor.CLOSED_HAND);
Button btnCROSSHAIR = createButton(Cursor.CROSSHAIR);
Button btnDEFAULT = createButton(Cursor.DEFAULT);
Button btnDISAPPEAR = createButton(Cursor.DISAPPEAR);
Button btnE_RESIZE = createButton(Cursor.E_RESIZE);
Button btnH_RESIZE = createButton(Cursor.H_RESIZE);
Button btnHAND = createButton(Cursor.HAND);
Button btnMOVE = createButton(Cursor.MOVE);
Button btnN_RESIZE = createButton(Cursor.N_RESIZE);
Button btnNE_RESIZE = createButton(Cursor.NE_RESIZE);
Button btnNONE = createButton(Cursor.NONE);
Button btnNW_RESIZE = createButton(Cursor.NW_RESIZE);
Button btnOPEN_HAND = createButton(Cursor.OPEN_HAND);
Button btnS_RESIZE = createButton(Cursor.S_RESIZE);
Button btnSE_RESIZE = createButton(Cursor.SE_RESIZE);
Button btnSW_RESIZE = createButton(Cursor.SW_RESIZE);
Button btnTEXT = createButton(Cursor.TEXT);
Button btnV_RESIZE = createButton(Cursor.V_RESIZE);
Button btnW_RESIZE = createButton(Cursor.W_RESIZE);
Button btnWAIT = createButton(Cursor.WAIT);
vBox.getChildren().addAll(
btnCLOSED_HAND, btnCROSSHAIR, btnDEFAULT,
btnDISAPPEAR, btnE_RESIZE, btnH_RESIZE,
btnHAND, btnMOVE, btnN_RESIZE, btnNE_RESIZE,
btnNONE, btnNW_RESIZE, btnOPEN_HAND, btnS_RESIZE,
btnSE_RESIZE, btnSW_RESIZE, btnTEXT, btnV_RESIZE,
btnW_RESIZE, btnWAIT);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
標籤:
JavaFX,
JavaFX 8 example
Wednesday, December 3, 2014
JavaFX example of using scene.nodeOrientationProperty().setValue(NodeOrientation.RIGHT_TO_LEFT)
[フレーム]
package javafxhello;
import javafx.application.Application;
import javafx.geometry.NodeOrientation;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class JavaFXHello extends Application {
@Override
public void start(Stage primaryStage) {
HBox hBox123 = new HBox();
hBox123.getChildren().addAll(
new Label(" Label 1 "),
new Label(" Label 2 "),
new Label(" Label 3 ")
);
HBox hBoxABC = new HBox();
hBoxABC.getChildren().addAll(
new Label(" Label A "),
new Label(" Label B "),
new Label(" Label C ")
);
VBox vBox = new VBox();
vBox.getChildren().addAll(hBox123, hBoxABC);
Scene scene = new Scene(vBox, 300, 250);
scene.nodeOrientationProperty().setValue(NodeOrientation.RIGHT_TO_LEFT);
//hBox123.nodeOrientationProperty().setValue(NodeOrientation.RIGHT_TO_LEFT);
//hBoxABC.nodeOrientationProperty().setValue(NodeOrientation.RIGHT_TO_LEFT);
primaryStage.setTitle("Hello World!");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
標籤:
JavaFX,
JavaFX 8 example
Tuesday, December 2, 2014
Java ME Embedded for Raspberry Pi, Release 8.1
The Oracle Java ME Embedded release 8.1 software for the Raspberry Pi platform is a ready-to-run binary for use with an off-the-shelf Raspberry Pi Model B board. The Oracle Java ME Embedded release 8.1 software underwent sanity check for use with a Raspberry Pi Model B+ board. See the Usage Notes for more details.
The Oracle Java ME Embedded software uses an optimized platform stack for small embedded devices, which includes the Connected Limited Device Configuration (CLDC) HotSpot Implementation (Java Virtual Machine) version 8, the Micro Edition Embedded Profile (MEEP) application environment, the Generic Connection Framework (GCF) API, and enhanced support for various Java Specification Requests (JSRs).
~ Release Notes
~ Getting Started Guide
The Oracle Java ME Embedded software uses an optimized platform stack for small embedded devices, which includes the Connected Limited Device Configuration (CLDC) HotSpot Implementation (Java Virtual Machine) version 8, the Micro Edition Embedded Profile (MEEP) application environment, the Generic Connection Framework (GCF) API, and enhanced support for various Java Specification Requests (JSRs).
~ Release Notes
~ Getting Started Guide
Thursday, November 27, 2014
Example of ListChangeListener for javafx.collections.ObservableList
[フレーム]
package javafxobservablelistchangelistener;
import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ListChangeListener;
import javafx.collections.ObservableList;
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.layout.VBox;
import javafx.stage.Stage;
public class JavaFXObservableListChangeListener extends Application {
int count = 0;
ObservableList observableList;
@Override
public void start(Stage primaryStage) {
observableList = FXCollections.observableArrayList();
observableList.addListener(new ListChangeListener(){
@Override
public void onChanged(ListChangeListener.Change c) {
System.out.println("\nonChanged()");
while(c.next()){
System.out.println("next: ");
if(c.wasAdded()){
System.out.println("- wasAdded");
}
if(c.wasPermutated()){
System.out.println("- wasPermutated");
}
if(c.wasRemoved()){
System.out.println("- wasRemoved");
}
if(c.wasReplaced()){
System.out.println("- wasReplaced");
}
if(c.wasUpdated()){
System.out.println("- wasUpdated");
}
}
for(Object i : observableList){
System.out.println(i);
}
}
});
Button btnAdd = new Button();
btnAdd.setText("Add item");
btnAdd.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
observableList.add(count);
count++;
}
});
Button btnRemove = new Button();
btnRemove.setText("Remove item");
btnRemove.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
int size = observableList.size();
if(size > 0){
observableList.remove(size-1);
}
}
});
Button btnReplace = new Button();
btnReplace.setText("Replace last item (+1)");
btnReplace.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
int size = observableList.size();
if(size > 0){
observableList.set(
size-1,
(int)observableList.get(size-1)+1);
}
}
});
VBox vBox = new VBox();
vBox.getChildren().addAll(btnAdd, btnRemove, btnReplace);
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);
}
}
標籤:
JavaFX 8 example
Wednesday, November 19, 2014
Java in a Nutshell
Java in a Nutshell
The latest edition of Java in a Nutshell is designed to help experienced Java programmers get the most out of Java 7 and 8, but it’s also a learning path for new developers. Chock full of examples that demonstrate how to take complete advantage of modern Java APIs and development best practices, the first section of this thoroughly updated book provides a fast-paced, no-fluff introduction to the Java programming language and the core runtime aspects of the Java platform.
The second section is a reference to core concepts and APIs that shows you how to perform real programming work in the Java environment.
The latest edition of Java in a Nutshell is designed to help experienced Java programmers get the most out of Java 7 and 8, but it’s also a learning path for new developers. Chock full of examples that demonstrate how to take complete advantage of modern Java APIs and development best practices, the first section of this thoroughly updated book provides a fast-paced, no-fluff introduction to the Java programming language and the core runtime aspects of the Java platform.
The second section is a reference to core concepts and APIs that shows you how to perform real programming work in the Java environment.
- Get up to speed on language details, including Java 8 changes
- Learn object-oriented programming, using basic Java syntax
- Explore generics, enumerations, annotations, and lambda expressions
- Understand basic techniques used in object-oriented design
- Examine concurrency and memory, and how they’re intertwined
- Work with Java collections and handle common data formats
- Delve into Java’s latest I/O APIs, including asynchronous channels
- Use Nashorn to execute JavaScript on the Java Virtual Machine
- Become familiar with development tools in OpenJDK
Streamed live on Nov 6, 2014
It may seem hard to get started with the Internet of Things (IoT) with so many technologies, protocols, hardware platforms, … involved. In this session, Benjamin Cabé from the Eclipse Foundation will cover all you need to know to start building IoT solutions using Java and open technologies like MQTT, CoAP, OSGi, or LWM2M. A real-life application (smart greenhouse) will be used as an example and you will most likely leave the session craving for building a very similar application yourself!
Speaker: Benjamin Cabé
Benjamin Cabé is IoT evangelist at the Eclipse Foundation. He advocates the use of open and innovative technologies for the Internet of Things and likes building crazy machines with Arduino kits and all kinds of open hardware platforms. You can find him online on Twitter (@kartben) or on his blog: http://blog.benjamin-cabe.com.
Saturday, November 8, 2014
List and check ConditionalFeature
javafx.application.ConditionalFeature defines a set of conditional (optional) features. These features may not be available on all platforms. An application that wants to know whether a particular feature is available may query this using the Platform.isSupported() function. Using a conditional feature on a platform that does not support it will not cause an exception. In general, the conditional feature will just be ignored. See the documentation for each feature for more detail.
package javaconditionalfeature;
import javafx.application.ConditionalFeature;
import javafx.application.Platform;
public class JavaConditionalFeature {
public static void main(String[] args) {
for (ConditionalFeature c : ConditionalFeature.values()){
System.out.print(c + " : ");
if(Platform.isSupported(c)){
System.out.println("supported");
}else{
System.out.println("not supported");
}
}
}
}
標籤:
fundamental.Java
Wednesday, November 5, 2014
JavaOne 2014 Keynotes
[フレーム]
Watch the full JavaOne 2014 Keynotes: https://www.oracle.com/javaone/live/on-demand/index.html#javaone
Wednesday, October 22, 2014
Beginning Java 8 APIs, Extensions and Libraries: Swing, JavaFX, JavaScript, JDBC and Network Programming APIs
Beginning Java 8 APIs, Extensions and Libraries: Swing, JavaFX, JavaScript, JDBC and Network Programming APIs
completes the Apress learning Java journey and is a comprehensive approach to learning the Java programming language extensions and available APIs and libraries, including the new JavaFX APIs.
This book covers the key extensions of the Java programming language such as Swing, JavaFX, network programming, and JDBC. Each topic starts with a discussion of the topic's background. A step-by-step process, with small snippets of Java code, provides easy-to-follow instructions. At the end of a topic, a complete and ready-to-run Java program is provided. This book contains over 130 images and diagrams to help you visualize and better understand the topics. More than 130 complete programs allow you to practice and quickly learn the topics.
The Swing chapters discuss various aspects of working with a GUI, from the very basic concepts of developing a Swing application, to the most advanced topics, such as decorating a Swing component with a JLayer, drag-and-drop features, Synth Skinnable L&F, etc.
The chapter on network programming covers the basics of network technologies first, and then, the advanced topics of network programming, using a Java class library. It covers IPv4 and IPv6, addressing schemes, subnetting, supernetting, multicasting, TCP/IP sockets, UPD sockets, asynchronous socket I/O, etc.
The chapter on JDBC provides the details of connecting and working with databases such as Oracle, SQL Server, MySQL, DB2, Java DB (Apache Derby), Sybase, Adaptive Server Anywhere, etc. It contains a complete discussion on processing a ResultSet and a RowSet. It discusses how to use the RowSetFactory, to obtain a RowSet object of a specific type. Working with Large Objects (LOBs), such as Blob, Clob, and NClob, is covered in detail with Java code examples and database scripts.
What you’ll learn
This tutorial is for Java programmers who are familiar with the fundamentals of the Java language and Java programming, who are now ready to call upon the power of extended Java functionality available from the huge array of Java APIs, extensions and libraries.
Table of Contents
1. Introduction to Swing
2. Swing Components
3. Advanced Swing
4. Applets
5. Network Programming
6. JDBC APIs
7. Java Remote Method Invocation
8. Java Native Interface
9. Introduction to JavaFX
10. Scripting in Java
This book covers the key extensions of the Java programming language such as Swing, JavaFX, network programming, and JDBC. Each topic starts with a discussion of the topic's background. A step-by-step process, with small snippets of Java code, provides easy-to-follow instructions. At the end of a topic, a complete and ready-to-run Java program is provided. This book contains over 130 images and diagrams to help you visualize and better understand the topics. More than 130 complete programs allow you to practice and quickly learn the topics.
The Swing chapters discuss various aspects of working with a GUI, from the very basic concepts of developing a Swing application, to the most advanced topics, such as decorating a Swing component with a JLayer, drag-and-drop features, Synth Skinnable L&F, etc.
The chapter on network programming covers the basics of network technologies first, and then, the advanced topics of network programming, using a Java class library. It covers IPv4 and IPv6, addressing schemes, subnetting, supernetting, multicasting, TCP/IP sockets, UPD sockets, asynchronous socket I/O, etc.
The chapter on JDBC provides the details of connecting and working with databases such as Oracle, SQL Server, MySQL, DB2, Java DB (Apache Derby), Sybase, Adaptive Server Anywhere, etc. It contains a complete discussion on processing a ResultSet and a RowSet. It discusses how to use the RowSetFactory, to obtain a RowSet object of a specific type. Working with Large Objects (LOBs), such as Blob, Clob, and NClob, is covered in detail with Java code examples and database scripts.
What you’ll learn
- How to extend your Java skills beyond the fundamental object oriented concepts and core language features
- How to apply Java Swing for building Java front ends or user interfaces (UIs)
- How to build small Java applications called applets
- How to do Java network programming
- How to connect with databases using JDBC APIs
- How to work with JavaFX, RMI (Remote Method Invocation), and JNI (Java Native Interface)
- How to use scripting in Java, including coverage of the Nashorn engine
This tutorial is for Java programmers who are familiar with the fundamentals of the Java language and Java programming, who are now ready to call upon the power of extended Java functionality available from the huge array of Java APIs, extensions and libraries.
Table of Contents
1. Introduction to Swing
2. Swing Components
3. Advanced Swing
4. Applets
5. Network Programming
6. JDBC APIs
7. Java Remote Method Invocation
8. Java Native Interface
9. Introduction to JavaFX
10. Scripting in Java
Java 8 Recipes, 2nd Edition
Java 8 Recipes
offers solutions to common programming problems encountered while developing Java-based applications. Fully updated with the newest features and techniques available, Java 8 Recipes provides code examples involving Lambdas, embedded scripting with Nashorn, the new date-time API, stream support, functional interfaces, and much more. Especial emphasis is given to features such as lambdas that are newly introduced in Java 8. Content is presented in the popular problem-solution format: Look up the programming problem that you want to solve. Read the solution. Apply the solution directly in your own code. Problem solved!
The problem-solution approach sets Java 8 Recipes apart. Java 8 Recipes is focused less on the language itself and more on what you can do with it that is useful. The book respects your time by always focusing on a task that you might want to perform using the language. Solutions come first. Explanations come later. You are free to crib from the book and apply the code examples directly to your own projects.
Java 8 Recipes is aimed mainly at intermediate and experienced Java programmers. If you're past the point of being able to write "Hello, World", then you'll find Java 8 Recipes to be chock full of interesting and useful programming solutions to help you achieve your goals and meet with success in your Java programming projects.
Table of Contents
Chapter 1: Language Basics
Chapter 2: Java 8 JDK Enhancements
Chapter 3: Strings
Chapter 4: Numbers and Dates
Chapter 5: Object-Oriented Java
Chapter 6: Lambda Expressions
Chapter 7: Data Structures, Conditionals, and Collections
Chapter 8: Input and Output
Chapter 9: Exceptions and Logging
Chapter 10: Concurrency
Chapter 11: Debugging and Unit Testing
Chapter 12: Unicode, Internationalization, and Currency Codes
Chapter 13: Working with Databases
Chapter 14: JavaFX Fundamentals
Chapter 15: Graphics with JavaFX
Chapter 16: Media with JavaFX
Chapter 17: JavaFX on the Web
Chapter 18: Nashorn and Scripting
Chapter 19: Email
Chapter 20: XML Processing
Chapter 21: Networking
Chapter 22: Java 8 Security Enhancements
Design and Deploy High-Performance JavaFX Controls: Mastering JavaFX 8 Controls (Oracle (McGraw-Hill))
The problem-solution approach sets Java 8 Recipes apart. Java 8 Recipes is focused less on the language itself and more on what you can do with it that is useful. The book respects your time by always focusing on a task that you might want to perform using the language. Solutions come first. Explanations come later. You are free to crib from the book and apply the code examples directly to your own projects.
- Covers the newly-released Java 8, including a brand new chapter on lambdas
- Focuses especially on up-and-coming technologies such as Project Nashorn and Java FX 2.0
- Respects your time by focusing on practical solutions you can implement in your own code
- Develop Java SE applications using the latest in Java SE technology
- Exploit the newly-introduced lambda features in Java 8
- Build dynamic web applications with JavaScript and Project Nashorn
- Create great-looking user interfaces with Java FX 2.0
- Generate graphics and work with media such as sound and video
- Add internationalization support to your Java applications
Java 8 Recipes is aimed mainly at intermediate and experienced Java programmers. If you're past the point of being able to write "Hello, World", then you'll find Java 8 Recipes to be chock full of interesting and useful programming solutions to help you achieve your goals and meet with success in your Java programming projects.
Table of Contents
Chapter 1: Language Basics
Chapter 2: Java 8 JDK Enhancements
Chapter 3: Strings
Chapter 4: Numbers and Dates
Chapter 5: Object-Oriented Java
Chapter 6: Lambda Expressions
Chapter 7: Data Structures, Conditionals, and Collections
Chapter 8: Input and Output
Chapter 9: Exceptions and Logging
Chapter 10: Concurrency
Chapter 11: Debugging and Unit Testing
Chapter 12: Unicode, Internationalization, and Currency Codes
Chapter 13: Working with Databases
Chapter 14: JavaFX Fundamentals
Chapter 15: Graphics with JavaFX
Chapter 16: Media with JavaFX
Chapter 17: JavaFX on the Web
Chapter 18: Nashorn and Scripting
Chapter 19: Email
Chapter 20: XML Processing
Chapter 21: Networking
Chapter 22: Java 8 Security Enhancements
Deliver state-of-the-art applications with visually stunning UIs. Mastering JavaFX 8 Controls provides clear instructions, detailed examples, and ready-to-use code samples. Find out how to work with the latest JavaFX APIs, configure UI components, automatically generate FXML, build cutting-edge controls, and effectively apply CSS styling. Troubleshooting, tuning, and deployment are also covered in this Oracle Press guide.
- Understand the properties of JavaFX 8 controls and APIs
- Create custom controls, transformations, and layouts
- Work from JavaFX Scene Graph and Scene Builder
- Visualize data models using advanced control types
- Use ListView, TableView, and TreeView APIs
- Handle audio and video content using JavaFX media classes
- Maximize separation between UI and application logic using FXML
- Style controls and applications using CSS
- Extend functionality of Swing and SWT applications with JavaFX
Mastering Lambdas: Java Programming in a Multicore World describes how the lambda-related features of Java SE 8 will enable Java to meet the challenges of next-generation parallel hardware architectures. The book explains how to write lambdas, and how to use them in streams and in collection processing, providing code examples throughout. You'll learn how to use lambda expressions to take full advantage of performance improvements provided by today's multicore hardware. This Oracle Press book covers:
- Why lambdas were needed, and how they will change Java programming
- Syntax of lambda expressions
- The basic operation of streams and pipelines
- Using collectors and reduction to end pipelines
- Creating streams
- Spliterators, the fork/join framework, and exceptions
- Examining stream performance with microbenchmarking
- API evolution using default methods
Java EE 7: The Big Picture uniquely explores the entire Java EE 7 platform in an all-encompassing style while examining each tier of the platform in enough detail so that you can select the right technologies for specific project needs. In this authoritative guide, Java expert Danny Coward walks you through the code, applications, and frameworks that power the platform. Take full advantage of the robust capabilities of Java EE 7, increase your productivity, and meet enterprise demands with help from this Oracle Press resource.
- Explore the features of the Java servlet model and Java servlet API
- Create dynamic web content with JavaServer Pages and JavaServer Faces
- Build websites for nonbrowser clients with JAX-RS
- Push data to web clients using Java WebSockets
- Secure web applications
- Work with web component APIs
- Maximize enterprise beans for multithreading, asynchronous processes, transactions, and more
- Access relational databases with the Java Database Connectivity APIs and the Java Persistence API
- Understand the packaging and deployment mechanisms of Java EE applications
- Work with Java EE Contexts and Dependency Injection
- Secure enterprise beans in a Java EE application
- Enable parallel processing with Java EE concurrency APIs