20.12.2019

Java Beginners Guide Fifth Edition

Java Beginners Guide Fifth Edition

Reviews Author: Herbert Schildt Pub Date: 2014 ISBN: 9252 Pages: 699 Language: English Format: PDF Size: 10 Mb Fully updated for Java Platform, Standard Edition 8 (Java SE 8), Java: A Beginner’s Guide, Sixth Edition gets you started programming in Java right away. Bestselling programming author Herb Schildt begins with the basics, such as how to create, compile, and run a Java program. He then moves on to the keywords, syntax, and constructs that form the core of the Java language. This Oracle Press resource also covers some of Java’s more advanced features, including multithreaded programming, generics, and Swing. Of course, new Java SE 8 features such as lambda expressions and default interface methods are described. An introduction to JavaFX, Java’s newest GUI, concludes this step-by-step tutorial.

Designed for Easy Learning:. Key Skills & Concepts — Chapter-opening lists of specific skills covered in the chapter. Ask the Expert — Q&A sections filled with bonus information and helpful tips.

Try This — Hands-on exercises that show you how to apply your skills. Self Tests — End-of-chapter quizzes to reinforce your skills. Annotated Syntax — Example code with commentary that describes the programming techniques being illustrated. Introducing JavaFX Key Skills & Concepts. Understand JavaFX’s concepts of a stage, a scene, a node, and a scene graph. Know the JavaFX life-cycle methods. Know the general form of a JavaFX application.

Understand how to launch a JavaFX application. Create a Label. Use Button.

Handle events. Use CheckBox.

Work with ListView. Create a TextField. Add effects.

Apply transforms In the fast-paced world of computing, change is constant, and the art and science ofprogramming continue to evolve and advance. It should not then be surprising that Java’s GUI frameworks have also participated in this process.

Recall that Java’s original GUI framework was the AWT. It was soon followed by Swing, which offered a far superior approach. Although Swing has been very successful, it can be difficult to create the “visual sparkle” that many of today’s applications demand. Furthermore, the conceptual basis that underpins the design of GUI frameworks has advanced.

To better handle the demands of the modern GUI and advances in GUI design, a new approach was needed. The result is JavaFX, Java’s next-generation GUI framework. This chapter provides an introduction to this powerful new system. It is important to mention that the development of JavaFX occurred in two main phases. The original JavaFX was based on a scripting language called JavaFX Script. However, JavaFX Script has been discontinued.

Beginning with the release of JavaFX 2.0, JavaFX has been programmed in Java itself and provides a comprehensive API. JavaFX has been bundled with Java since JDK 7, update 4. The latest version of JavaFX is JavaFX 8, which is included with JDK 8.

(The version number is 8 to align with the JDK version. Thus, the numbers 3 through 7 were skipped.) Because, at the time of this writing, JavaFX 8 represents the latest version of JavaFX, it is the version of JavaFX discussed here. Furthermore, when the term JavaFX is used, it refers to JavaFX 8. Before we begin, it is useful to answer one question that naturally arises relating to JavaFX: Is JavaFX designed as a replacement for Swing? The answer is, essentially, Yes.

However, Swing will be part of Java programming for some time to come. The reason is that there is a large amount of Swing legacy code. Furthermore, there are legions of programmers who know how to program for Swing. Nevertheless, JavaFX has clearly been positioned as the platform of the future.

It is expected that over the next few years, JavaFX will supplant Swing for new projects, and many Swing-based applications will migrate to JavaFX. Simply put: JavaFX is something that no Java programmer can afford to ignore. JavaFX Basic Concepts Before you can create a JavaFX application, there are several key concepts and features you must understand.

Although JavaFX has similarities with Java’s other GUIs, the AWT and Swing, it has substantial differences. For example, like Swing, JavaFX components are lightweight and events are handled in an easy-to-manage, straightforward manner. However, the overall organization of JavaFX and the relationship of its main components differ significantly from either Swing or the AWT. Therefore, a careful reading of the following sections is recommended. The JavaFX Packages The JavaFX framework is contained in packages that begin with the javafx prefix. At the time of this writing, there are more than 30 JavaFX packages in its API library.

Here are four examples: javafx.application, javafx.stage, javafx.scene, and javafx.scene.layout. Although we will only use a few JavaFX packages in this chapter, you will want to spend some time browsing their capabilities. JavaFX offers a wide array of functionality. The Stage and Scene Classes The central metaphor implemented by JavaFX is the stage. As in the case of an actual stage play, a stage contains a scene. Thus, loosely speaking, a stage defines a space and a scene defines what goes in that space. Or, put another way, a stage is a container for scenes and a scene is a container for the items that comprise the scene.

Beginners

As a result, all JavaFX applications have at least one stage and one scene. These elements are encapsulated in the JavaFX API by the Stage and Scene classes. To create a JavaFX application, you will, at minimum, add at least one Scene object to a Stage. Let’s look a bit more closely at these two classes. Stage is a top-level container. All JavaFX applications automatically have access to one Stage, called the primary stage. The primary stage is supplied by the run-time system when a JavaFX application is started.

Although you can create other stages, for many applications, the primary stage will be the only one required. As mentioned, Scene is a container for the items that comprise the scene. These can consist of controls, such as push buttons and check boxes, text, and graphics.

To create a scene, you will add those elements to an instance of Scene. Nodes and Scene Graphs The individual elements of a scene are called nodes. For example, a push button control is a node.

However, nodes can also consist of groups of nodes. Furthermore, a node can have a child node. In this case, a node with a child is called a parent node or branch node. Nodes without children are terminal nodes and are called leaves. The collection of all nodes in a scene creates what is referred to as a scene graph, which comprises a tree. There is one special type of node in the scene graph, called the root node.

This is the top-level node and is the only node in the scene graph that does not have a parent. Thus, with the exception of the root node, all other nodes have parents, and all nodes either directly or indirectly descend from the root node. The base class for all nodes is Node.

There are several other classes that are, either directly or indirectly, subclasses of Node. These include Parent, Group, Region, and Control, to name a few.

Layouts JavaFX provides several layout panes that manage the process of placing elements in a scene. For example, the FlowPane class provides a flow layout and the GridPane class supports a row/column grid-based layout. Several other layouts, such as BorderPane (which is similar to the AWT’s BorderLayout), are available. Each inherits Node.

The layouts are packaged in javafx.scene.layout.

Essential Skills-Made Easy! Learn the fundamentals of Java programming in no time from bestselling programming author Herb Schildt. Fully updated to cover Java Platform, Standard Edition 7 (Java SE 7), Java: A Beginner's Guide, Fifth Edition starts with the basics, such as how to compile and run a Java program, and then discusses the keywords, syntax, and constructs that form the core of the Java language. You'll also find coverage of some of Java's most advanced features, including multithreaded programming and generics. An introduction to Swing concludes the book. Get started programming in Java right away with help from this fast-paced tutorial. Designed for Easy Learning:.

Key Skills & Concepts-Chapter-opening lists of specific skills covered in the chapter. Ask the Expert-Q&A sections filled with bonus information and helpful tips. Try This-Hands-on exercises that show you how to apply your skills.

Java Beginners Guide Pdf

Self Tests-End-of-chapter questions that test your understanding. Annotated Syntax-Example code with commentary that describes the programming techniques being illustrated 'synopsis' may belong to another edition of this title.