image

Index

imagesA

Abstract Windowing Toolkit (AWT), 413

Accelerator() method, 562

AcceptChanges() ActionPerformed() method, 688

Android

application components, 729730

application events and activity changes

activity class, 724

activity process life cycle, 726727

android:onClick attribute, 726

DisplayInformation activity, 727

displayInformation.xml, 728

onClick(View) method, 726

OnClickListener method, 726

performAction() method, 724726

putExtra() method, 727

startActivity(Intent) method, 727

swing-like action listeners, 725

XML tag attributes, 726

application-specific privileges, 743744

basic application

android.app.Activity, 712

dialog box, 711

doWork() method, 713

Hello World view, 712

java.util.Date object, 713

layout folder, 712

LinearLayout, 712

main.xml file, 712

res folder, 712

Swing development, 712

todaysDate.java code, 710

compiling and testing, 713714

development environment

add-ons repository, 709

android development toolkit, 707

android repository option, 709

documentation, 709

download and installation, 707

IDE and ADT, 708

plug-in installation, 708

SDK, 708709

update manager feature, 708

incoming call events

android.content.BroadcastReceiver class, 732

android:name attribute, 733

AndroidManifest.xml file, 731

AndroidManifext.xml file, 733

broadcast receiver, 731732

getExtras() method, 732

normal broadcasts, 732

onReceive method, 732

ordered broadcasts, 732

SMS, 732

tabbed user interface, 737android.app.TabActivity class, 733

android:configChanges attribute, 739

android:drawable attributes, 738

android:launchMode attribute, 739

drawable XML file, 735736

EnterInformation activity, 738

enterinformation.XML file, 735

FrameLayout> tag, 739

<LinearLayout> tags, 739onCreate(Bundle) method, 738

setIndicator(CharSequence, Drawable) method, 738

setupTabs() method, 738

state-list drawable, 737

TabActivity class, 736, 738

TabContainer.java file, 734735

TabController activity, 739

<TabHost> container, 739TabHost instance, 738

tabs.xml file, 735

user interface construction, without XML file

activity class, 721722

android.app.Activity, 723

code, 721722

edittext widget, 723

Java Swing user interface, 722

onCreate(Bundle) method, 723

setContentView() method, 723

Spinner widget, 723

user interface construction, XML file, 715716activity class, 714, 719

android.app.Activity, 716

android.widget.spinner widget, 718

android:id attribute, 719

android:layout_height attribute, 719

android:layout_width attribute, 719

android:onClick attribute, 720

android:text attribute, 719

AndroidManifest.xml, 720

application resources, 717718

application screens, 716

<Button> tag, 719drop-down list, 718

EnterInformation, 716

findViewById(int) method, 718

initialization code, 717

LinearLayout tag, 719

onCreate(Bundle) method, 716

onPause() method, 716

R class, 717

R.id.spinner static integer, 718

R.layout.enterinformation file, 717

setContentView(int) method, 717

<Spinner> tag, 719

strings.xml file, 720

templates, 719

user interface screen, 720

web pages

getSettings() method, 741

onReceivedError method, 742

setJavaScriptEnabled() method, 741

tabLayout, 740, 741

ViewSite, 741

WebChromeClient subclass, 742

WebView, 739743

Window.FEATURE_PROGRESS feature, 741

Antialiasing technique, 335

Applets, 651

ActionListener interface, 688

actionPerformed() method, 688

AWT layout manager, 688

draggable applets creation, 693, 694

external libraries, 695698

FirstApplet subclass, 687

init() method, 687

JApplet, 687

packaging and web page embedding

<applet> tag, 692

CLASSPATH, 691

deployJava.js file, 691

FirstApplet.jar file, 689, 690

HTML page creation, 689

Invoke Deployment Toolkit, 689

JNLP files, 692

name/value pairs, 691

setVisible() method, 689

swing components, 704

invokeAndWait method, 705

javax.swing.JApplet class, 699702

mailapplet, 699

Runnable() method, 705

SwingMailPanel, 702703

SwingUtilities.invokeAndWait method, 704705

text button and label, 685686

Application.launch() method, 523

AuthorWorkCachedRowSet, 300

Automatic resource management (ARM), 136

imagesB

Binary large objects (BLOBs), 311

Bind() method, 540

BookAuthorsCachedRowSet, 300

Branch group nodes, 400

Build() method, 531

Builder class, 531

imagesC

CachedRowSet

code, 289292

acceptChanges() method, 294

connection properties, 293

CreateConnection class, 293

execute() method, 293

executeQuery() method, 293

fetching methods, 294

insertRow() method, 294

main() method, 289

moveToCurrentRow() method, 294

moveToInsertRow() method, 294

output, 292

RowSetFactory, 293

setCommand() method, 293

setKeys() method, 293

SyncResolver object, 294

updateRow() method, 294

calculateDaysPlayed() abstract method, 178

CallableStatement, 318319

cancel() method, 559

ChangeListener, 559

Character large object (CLOB)

BLOBs, 311

ClobgetString() method, 311

ConnectioncreateClob() method, 311

executeUpdate() method, 311

getAsciiStream() method, 311

loadClob() method, 311

loading and querying code, 308310

PreparedStatement setClob() method, 311

setString() method, 311

VARCHAR fields, 311

Character streams and buffers conversion

arbitrary byte-oriented encoding, 255

CharBuffer instance, 257

Charset argument, 256

CharsetEncoder and CharsetDecoder class, 257

IANA Charset Registry, 257

InputStreamReader method, 255

newEncoder() and newDecoder() method, 256

OutputStreamWriter method, 255

CheckMenuItem, 540

ClobgetString() method, 311

close() method, 320

Commit() method, 280, 284

ComputeValue() method, 546, 550

Concurrency

collections helper class, 191

CopyOnWriteArrayList, 190

different collections coordination

atomic operation, 194

fulfillorder() method, 192, 193

inventoryLock.lock() method, 193

inventoryLock.unlock() method, 193194

lock.unlock() method, 195

locking, 195

ReentrantLock object, 195

setFair property, 195

discrete units, 207211

key insertion, 188190

run() method, 186

runnable interface, 185

startUpdatingThread() method, 190

synchronizedList() method, 191

threads, 186

await() method, 203

awaitTermination() method, 196

blockingQueue queue, 201

CorePoolSize, 197

CountDownLatch, 199, 200

inventoryThread.join() method, 200, 203

JVM's thread scheduler, 201

KeepAliveTime, 197

MaximumPoolSize, 197

objectToSync, 202

prestartAllCoreThreads() method, 197

processOrder() method, 198, 199

Queue, 197

shutdown() method, 197

ThreadpoolExecutor instance, 196

TimeUnit, 197

wait() method, 202

WorkQueue, 197

threadsafe sbjects

creation, 203205

implementing, 206207

updation, 187188

user and daemon user thread, 186

Connection management

Connection object, 271

CreateConnection class, 27174

CreateConnection.java, 271

DataSource, 275

db_props.properties, 274

DriverManager, 274275

JNDI, 274275

strategic connection methodology, 274

ConnectioncreateClob() method, 311

CreatePlayer(String) method, 151

cs.getString(1) method, 319

CubicCurveBuilder, 531, 532

imagesD

Data manipulation language (DML), 270

Data structures

code execution

control flow statement, 84

isValidSwitchType() method, 8384

private static void playHands, 82

private static void printWinner, 82

public class, 81

public static void main, 82

RockPaperScissors class method, 85

switch statement, 81

SwitchTypeCheckerisValidSwitchType() method, 85

dynamic arrays

arrayList, 98

List<String> method, 98

output, 97

public static boolean screen, 96

public static void screen, 96

StockScreener class method, 96

StockScreener main() method, 98

void main, public static, 96

fixed set constant

abstract and finaljava.lang.Enum class, 76

compiler error or warning, 75

encapsulate constants, 75

enum type, 74

equals() method, 76

FieldType.EMAIL_ADDRESS coding, 7475

name() method, 76

ordinal() method, 76

values() and valueOf(String) method, 76

fix-sized arrays

Arrays.toString(int[]) method, 90

GradeAnalyzer class, 8587

GradeAnalyzer main() method, 90

initGrades1() method, 90

initGrades2() method, 90

initGrades3() method, 90

min and max grade, 89

object type array, 88

output,GradeAnalyzer class, 87

steps, defining array, 88

generic types

aList.add((Integer)aNum) method, 92

collection interfaces and classes, 91

Collection removeAll() method, 94

compile-time feature, 91

diamond, 94

LinkedList<Double> method, 93

LinkedList<Integer>, 93

List<String>>bMap method, 95

Listadd(E e)method, 92

ListrawList, 92

public interface List, 91

wildcard, 93

intelligent constants design

email address, 77

FieldType enum method, 77

FieldType instances, 80

main() method, 80

password, 77

phone number, 78

social security number, 7880

validate() method, 80

iterable objects

add(List<Stock>) method, 101

collection-based class, 99

iterator() method, 99101

main() method, 100

Mapvalues() method, 101

remove() method, 101

StockPortfolio method, 99, 100

UnmodifiableIterator class, 101

map iterating:, 102104

Databases, 259

array value retrieval

BigDecimal type, 317

code, 315316

data structures, 315

getArray() method, 317

java.sql.Array object, 315, 317

NUMBER data type, 315

PreparedStatement getArray() method, 317

results, 316

array value storage

ArrayDescriptor, 314

AUTHOR_RECIPES table, 312, 314

CHAP_LIST_TYPE, 312

chapterArray, 314

code, 31214

executeUpdate() method, 314

java.sql.Array, 312

oracle.sql.ARRAY, 312, 314

RDBMSs, 31415

storeArray() method, 314

automatic resource handling, 31920

connection

CLASSPATH, 261

connection object, 262

datasource object, 260, 261

datasource registration, 262

DriverManager object, 261

getConnection() method, 25960

InitialContext, 262

java.naming.NamingException exception, 262

java.sql.Connection object, 261

java.sql.SQLException, 262

JDBC Connection object, 259

management. See Connection management

ojdbc6.jar JAR file, 261

SQL exceptions, 26263

create_database.sql script, 259

create_user.sql script, 259

CRUD operations

code, 26669

vs. DML, 270

executeQuery() method, 270

executeUpdate() method, 270

format, 270

performCreate() method, 270

performDelete() method, 271

performRead() method, 270

performUpdate() method, 270

result, 270

statement executeQuery() method, 270

data caching, disconnected state. See CachedRowSet

FilteredRowSet

AuthorFilter, 306, 307

code, 3035

evaluate() methods, 306

executeQuery() method, 307

FilteredRowSetImpl, 307

implementation, 301303

implementFilteredRowSet() method, 303, 307

main() method, 303

output, 305306

RowSet, 306

setCommand() method, 307

setFilter() method, 307

WHERE clause, 306, 307

JoinRowSet

addRowSet() method, 300

AUTHOR_WORK table, 299

BOOK_AUTHOR table, 299

code, 295299

foreign key, 295

getInt() method, 300

getString() method, 300

joinRowQuery() method, 300

main() method, 299

output, 299

primary key, 295

queryAuthorBook() method, 300

queryBookAuthor() method, 300

RowSet, 295

SQL JOIN query, 299

large object query and storage. See Character large object

query and result retrieval

connection object, 265

executeQuery() method, 265

java.sql.Connection object, 264

java.sql.SQLException, 266

next() method, 265

ResultSet getInt() method, 265

ResultSet getString() method, 265

ResultSet object, 264

rs.next(), 265

statement object, 264

System.out() method, 265

scrollable ResultSet

code, 28485

constants, 286

createStatement() method, 285

forward and backward traverse, 284

PreparedStatement object, 286

prepareStatement() method, 285

record retrieval code, 286

SQL injection protection. See PreparedStatements

stored procedure invoking, 317319

transaction

autoCommit() preference, 280

commit() method, 280, 283, 284

insertRecord() method, 284

main() method, 283

management code, 28082

rollback() method, 280, 284

sequential processing, 280

setAutoCommit() method, 283284

TransactionExample class, 280, 283

updatable ResultSet

code, 287

concurrency, 288

createStatement() method, 288

output, 287288

PreparedStatement method, 288

prepareStatement() method, 288

ResultSet object, 286, 287

ResultSet.CONCUR_UPDATABLE constant, 288

Statement object, 288

TYPE_SCROLL_SENSITIVE, 288

updateRow() method, 289

updateString() method, 288

updateXXX() methods, 288

Date

binary literals, 7071

Calendar add() method, 62

Calendar.getInstance() method, 60

compareTo() method, 60

comparison, 6869

days, months, and years, 6163

formatting

calendar object, compare results, 69

java.text.SimpleDateFormat class, 66

pattern characters, 67

SimpleDateFormat class, 6668

getDay() method, 60

getHours() method, 60

getMinutes() method, 60

getMonth() method, 60

getSeconds() method, 60

getTime() method, 60, 64

getTimeInMillis() method, 64

getTimezoneOffset() method, 60

getYear() method, 60

java.util.Calendar class, 58

java.util.concurrent.TimeUnit enum, 63

java.util.Date class, 58

numeric literals, 6970

setTime() method, 60

static int calendar fields, 63

TimeUnit enum, 64

TimeUnit.MILLISECONDS, 65

toHours() method, 65

Debugging and unit testing, 213

classes, lock down, 216

annotation, definition, 216

Assert.assertEquals method, 216

JUnit, 214

MathAdder class, 214215

Emma code coverage

.class files, 222

definition, 222

instrumentation, 222

report creation, 220221

statistics, 222, 223

Exception's StackTrace() method, 213

FindBugs report, 223226

garbage collection, 226229

memory leak spots

class breakdown, VisualVM, 231

createdWindows Set, 233

heap dump, 229

int[] array, 232

JFrames, 232

memory consumption, 229

memory dump, 229

scripting

Apache Ant program, 219

build.path, 219

build.xml file, 218

JAVA_HOME environment variable, 217

JDK installation, 217

JUnit + Ant configuration, 216

StackTrace() output, 214

thread dump, 234236

Document object model (DOM), 618

doFilter() method, 673

DoubleBinding class, 546

DriverManager.getConnection() method, 261

DropShadow object, 532

DUMMY_FUNC, 319

DUMMY_PROC, 318

imagesE

E-mail

authenticator object, 781

checking, 783784

file attachment, 781782

getPasswordAuthentication() method, 781

JavaMail, 779780

javax.mail.Session, 781

mail.smtp.host property, 781

MessageAuthenticator, 781

monitoring, 784786

multiple recipients, 782783

Properties object, 781

standard Map object, 781

Transport() methods, 780

Transport.send() static method, 781

Event dispatching thread (EDT), 385, 558

Event driven architecture (EDA), 644

EventHandler class, 554

execute() method, 293

executeQuery() method, 265, 270, 279, 293, 319

executeUpdate() method, 270, 271, 279, 311

imagesF

FXCollections class, 553

imagesG

getAsciiStream() method, 311

getConnection() method, 261

getCurrencyInstance() method, 251, 252

getItems() method, 540

GridPane class, 542

imagesH

handle() method, 554

Heap dump, 229

HelloWorld application

command-line prompt

compilation and running, 522

directory structure, 522

Group class, 523

javac -d . HelloWorldMain.java, 522

JavaFX application package and deployment, 522

javafx.application.Application class, 523

main() method, 523

node, 523

procedure, 520521

Scene object, 523

Shape objects, 523

show() method, 523

Stage object, 523

start() method, 523

NetBeans IDE

Group class, 523

JavaFX project creation wizard, 522

javafx.application.Application class, 523

main() method, 523

node, 523

procedure, 518519

Run Main Project menu option, 522

runtime libraries, 522

Scene object, 523

Shape objects, 523

show() method, 523

source/binary format, 522

Stage object, 523

start() method, 523

imagesI

initModality() method, 578

initOwner() method, 578

insertRecord() method, 284

insertRow() method, 294

imagesJ, K

Java 2D graphics

attributes additon, 365367

complex shapes, 352

control point, 353

cubic curve, 353

CubicCurve2D.Float constructor, 353

donut shape, 350351

ice cream cone, 353

Path2D, 350

QuadCurve2D, 350

quadratic Bézier curve, 350

quadratic parametric curve, 354

subtract() method, 354

displayGUI(), 323

document printing, 379382

drop shadow effect, 375378

filling shapes, 340

alpha channel, 341342

code, 338340

fill() method, 338

rectangle shape, 342

round rectangle, 342

setPaint() method, 338

shape stroke, 341

smooth rendering, 340

gradients, 342346

image alteration, 387391

image drawing and loading

code, 383386

diamond operator notation, 386

doInBackground() method, 386

done() method, 386

drawImage() methods, 387

EDT, 385

ImageIO.read() method, 386

javax.imageio.ImageIO, 382

javax.swing.SwingWorker, 382

open dialog box, 384, 385

publish() and process() methods, 386

SwingWorker class, 386

image storage, 391396

interactive shapes

cubic curve shape, 355360

instance variables, 362

java.awt.geom.QuadCurve2D object, 355

mouseDragged() method, 361

MouseListener, 355, 361

MouseMotionListener, 355, 361

mouseMoved() method, 361

mousePressed() method, 361

paintComponent() method, 362

QuadCurve2D, positioning handles, 360

quadratic curve shape, 361

javax.swing.JComponent component, 323

javax.swing.JFrame, 323

lines drawing, 328

80/20 rule, 328

background color, 329

basic steps, 328

basicssstroke constructor parameters, 330

clearRect() method, 329

code, 326327

draw() methods, 331

drawing, 328

drawLine() method, 326, 330

java.awt.BasicStroke, 326, 330

java.awt.Color, 326

JComponent class, 328

Line2D.Double class, 330

paint color setting, 329

paintComponent() method, 328

painting, 328

Pareto principle, 328

stroking, 328, 329

super.paintComponent(g), 328, 329

main() method, 323

paintComponent() method, 323

points creation, 324326

shape drawing

antialiasing technique, 335

arc, ellipse, rectangle, and rounded rectangle, 332333

Arc2D Double classes, 335

Arc2D float constructors, 336

Arc2D.Float instance, 337

bounding box, 336

code snippet, 335

code statements, 338

default rendering algorithms, 335

DrawShapes recipe, 334

Ellipse2D class, 338

java.awt.Color.Black, 335

java.awt.Shape, 331

open, chord, and pie arc types, 337

rendering hint, 335

setRenderingHints() method, 335

transforms, 335

translate, 335

translate() method, 337

SimpleAppLauncher.java, 321323

SimpleAppLauncher.launch() method, 323

SwingUtilities.invokeLater() method, 323

text font, 362364

text measurement, 367372

text, multiple line display, 372375

transforming shapes, 346349

Java 7

addNumbers() method, 17

arguments and returning values, 1921

CLASSPATH configuring, 35

code organizing, 2123

command line, 910, 2324

compiling and executing, 78

@Deprecated annotation, 1516

downloading and installing, 13

environment variables, 1012

executable Java class, 56

Javadoc, 1214

main() method, 1718

multiplyNumbers() method, 17, 19

output printing, 89

private modifier, 18

public modifier, 18

Java exceptions

AutoCloseable interface, 136

catching, 129130

cleanup code, 130131

error class, 127

FileHandler pattern, 143

hierarchy, 128

IllegalArgumentException class, 138

InvalidUsernameException, 128

java.util.logging.LogManager(), 140

loadLogConfiguration() function, 140

Log0.log file code, 142

Logger.isDebugEnabled(), 143

logging Levels, 141

multiple exceptions, 132133

recipeLogger event, 139

rethrowing, 138

RuntimeException class, 128, 137138

SocketHandler, 142

throwing, 131132

try/catch syntax, 127, 128

try-with-resources block, 136

uncaught exceptions, 134135

Java networking, 805

accept() method, 810

communicateWithClient() method, 811

createConnection() method, 807

DatagramChannel class, 813815

DatagramChannelconfigureBlocking(boolean) method, 817

flip() method, 817

in.readLine() method, 808

InetSocketAddress instance, 816817

infiniBand, gain performance boosts, 811813

InputStreamReader instance, 811

java.net.ServerSocket, 808809

MulticastChannel interface, 816

NetworkInterface, 816

PrintWriter object, 811

run() method, 817

send() method, 818

server-side application, 808

Socket connection, 805807

TCP/IP layer, 807

testConnection() method, 808

UDP, 816

URL. see URL

Java Platform Manager, 518, 519

Java virtual machine (JVM), 1

java.io.Closeable interface, 320

java.lang.Autocloseable API, 320

java.sql.Connection object, 263

java.sql.PreparedStatement object, 275

java.sql.SQLException, 261

java.util.ArrayLists, 553

Java3D, 397

animation, 404405

3D object creation

color cube object, 398

nodes types, 400

platform view, 399

SimpleUniverse, 399

universe hierarchy, 399401installation, 397398

keyboard events, 408410

KeyNavigatorBehavior, 406408

light source, 410, 411

appearance class, 410

influencing bounds, 412

shade model, 411

shading objects, 410, 411

space game, 412

object transformation, 402403

Javadoc, 1214

JavaFX, 513, 621

animating shapes

anchorPt variable, 601

code, 598600

Java classes, 598

javafx.scene.shape.Path object, 601

mouse-pressed event, 602

mouse-released event, 602

onFinished property, 601

onMouseXXXProperty methods, 602

path transition, 600, 601

PathTransitionBuilder class, 601

RadialGradient, 601

scene graph, 601

animation generation

API, 589

compound transition, 593

cycle count and auto-reverse attributes, 594

EventHandler<ActionEvent> object, 596

fade in and out button controls, 589, 592

fade transitions, 593, 596597

fade-in effect, 597

getChildren().add() method, 595

getKeyFrames().add() method, 594

gotoImageIndex() method, 596

handle() method, 597

Javadoc, 594

javafx.animation.Interpolator, 596

javafx.util.Duration, 594

KeyFrame, 594

KeyValue, 594

node's property, 594

picture, fade in and out, 591592

play() method, 596

previous and next buttons, 593

RectangleBuilder, 595

SequentialTransition, 596

setClip method, 595

setFromValue() and setToValue() methods, 597

setOnFinished() method, 596

standard attributes, 594

ticker control, 589591, 593595

timeline, 594

transitionByFading() method, 596

TranslateTransitionBuilder, 595

translating and fading, 593

translation transition, 593

background process

classes, 554

controls, 558

createWorker() method, 558

EDT, 558

file copy window, 557, 558

queue up, 558

source code, 554557

SwingWorker object, 558

task object, 558559

binding expressions

computeValue() method, 546, 550

console application code, 546549

Contact object, 549550

DoubleBinding class, 546, 550

javafx.beans.binding.* and javafx.beans.property.* packages, 546

javafx.beans.Observable class, 549

multiply() method, 550

output, 549

strategies, 546

borders generation, 545

CSS editor text code, 543544

HBox layout, 545546

imageView object, 545

ImageView object, 545

style selectors, 545

change password dialog box, 578

initModality() method, 578

initOwner() method, 578

javafx.scene.Scene API, 573

javafx.stage.Stage API, 573

javafx.stage.Stage class, 578

JDialog class, 578

JFrame, 578

source code, 573577

start() method, 578

changing text fonts, 526

code, 525526

DropShadow object, 527

javafx.scene.effect.DropShadow, 525

javafx.scene.effect.Reflection, 525

javafx.scene.text.Font, 525

reflection, 527

vector-based graphics, 527

colors assignment

classes, 533

code, 533534

color shapes, 535

cycle method, 537

eclipse shape, radial gradient, 535

LinearGradient properties, 536537

RadialGradient properties, 535536

rectangle, semitransparent linear gradient, 535

rounded rectangle, reflective linear gradient, 535

components addition, layout, 541542

CSS styling

Caspian theme, 618

code, 615617

createMenuItem() method, 619

DOM, 618

JavaFX Caspian Look 'n' Feel theme, 617

javafx.scene.control.Buttons, 620

javafx.scene.control.Labels, 620

loadSkin(), 619

selectors, 619

setStyle() method, 619

skinForm() method, 619

grid layout

cell constraint settings, 613

EventHandler<ActionEvent>, 613

form designer application, 603604

grid-like form class code, 604605

GridPaneControlPanel, 611

javafx.scene.layout.GridPane, 603

JavaFXjavafx.beans.value.ChangeListeners, 612

ManipulatingLayoutViaGrids, 611

MyForm creation, 611

padding and slider control, 613

property control panel, 605610

setOnAction() method, 613

split pane creation, 611

target grid pane, 613, 614

ToggleButton selected property, 612

image creation

ButtonMove.PREV and ButtonMove.NEXT, 588

currentIndex variable, 586

drag-and-drop operation, 584

drag-and-drop support, 586

event.consume() method, 586

EventHandler objects, 586

getDragboard() method, 586

gotoImageIndex() method, 588

handle() method, 586

HBox instance, 586

image aspect ratio, 586

imageFiles variable, 586

instance variables, 585

java classes, 580

javafx.scene.shape.Arc, 588

OnDragDropped attribute, 587

OnDragOver attribute, 586

setOnDragOver() method, 586

setPreserveRatio() method, 586

source code, 580584

translateXProperty(), 588

vs. Java2D, 527

keyboard sequences, 561

accelerator() method, 562

classes, 559

inner shadow effect, 561

setAccelerator() method, 562

source code, 559561

media-rich API, 621

menus creation, 539

classes, 538

code, 538539

hot keys/keyboard functionality, 539

menu bar, 540

menu items, 540

menu objects, 540

MenuBar, 540

MP3 player, 622

application instance variables, 629

drag-and-drop desktop metaphor, 629

java.lang.Runnable method, 632

MediaPlayer object, 631

mouse-dragged event handler, 630

phaseNodes (Group) variable, 630

previousLocation variable, 630

randomly colored circle nodes, 631632

setOnMousePress() method, 632

source code, 622628

spectrumDataUpdate() method, 631

StageStyle.TRANSPARENT, 629

with visualizations, 628

ObservableList

GUI application code, 551552

java swing components, 553

java.util.ArrayList class, 553

javafx.collections.ObservableList and javafx.scene.control.ListView classes, 551

listview, 553554

MVC mechanism, 551

scene graph, 513

shapes creation, 530

code, 528530

cubic curve, 531

donut shape, 532

equivalent shapes and drawing primitives, 531

ice cream cone shape, 531532

javafx.builders.* package, 528

javafx.scene.shape.* package, 528

software installation

CLASSPATH variable, 517

completion, 516

JavaFX 2.0 and NetBeans IDE 7.1.x, 514

JavaFX 2.0 SDK Setup Wizard, 515

JavaFX SDK home directory, 515, 516

NetBeans IDE, 517

Swiss Army Knife, 513

tables

application code, 564565

ChangeListener, 567

getPeople() method code, 565566

javafx.scene.control.TableView class, 562

JTable component, 562

ListView control, 562, 567

ListViewer, 567

ObservableList, 567

person class source code, 562564

setProperty() method, 567

TableView control, 562, 566567

teamMembers (ObservableList) variable, 567

updateItem() method, 567

tabs addition

javafx.scene.control.Tab class, 570

javafx.scene.control.TabPane class, 570

tab orientations, 571572

TabPane, 572, 573

text drawing:, 523525

tree-like data structure, 513

UI with split views, 569

dividers position, 570

GUI application code, 568569

javafx.scene.control.SplitPane class, 567568

SplitPane control, 570

VBox layout control, 570

vertical split, 570

user experience, 513

user interface creation. See HelloWorld application

video media player

animation and media synchronization, 647648

attachMouseEvents() method, 637

ChangeListener's changed() method, 640

createBackground() method, 639

createSlider() method, 639

drag-dropped EventHandler, 640

JavaFX basic video player code, 633636

media actions and events control, 642644

MediaView object, 641

pauseButton and playButton, 641

position mark, 644647

Runnable instance, 641

setFullScreen() method, 639

with slider control, 637

UI code, 638

VP6, 638

visual cues, 579

JavaFX applications

database

alert() function, 778

createStatement().executeQuery, 774

DBUtils.java, 773

display contents, 768

doc.getElementsByTagName, 772

EventHandler<DragEvent>(), 770

getLoadWorker().stateProperty() method, 769

JDBC database, 777

list of feeds, 777

OnAlert web event, 778

public String toString(), 773

RSS feed location, 767

RSS icon, 776

RSS reader, 775

scene.setOnDragDropped(), 771

setOnAlert(), 770

State.SUCCEEDED, 777

three frame readers, 775

webEngine addListener(), 769

HTML5 content

alert() function, 767

Calm Down button, 766

clock application, 753

code,SVG analog clock, 754755

DisplayHtml5Content.class file, 756

executeScript() method, 763

forecast, Yahoo! Weather, 761

getDocument() method, 764

getEngine().load() method, 756

JavaFX Scene graph, 753

Javafx.scene.web.WebEngine, 762

JavaScript updateTime() function, 757

JavaScript/SVG code, 756

loadContent() method, 763

ManipulatingHtmlContent class, 762

OnAlert property, 765

panic button,e-mail notification, 764

start() method,warning message, 764

start() method,weather message, 765

SVG analog clock, 756

SVG generation, 754

TimeLine to update, 763

warning message,panic button, 765766

weather application, 761, 766

weather forecasts, 762

Yahoo weather service, coding, 757760

web page

class check box, 752

click OK to close, 753

creation, 746

dialog box, 748

Hello World application, 750, 751

HTML web page, 751

MyJavaFXApp dialog, 749

MyJavaFXApp.java, 747, 748

NetBeans IDE 7.1, 745

new project dialog box, 747

Select New Project, file menu, 746

setting,run option, 750

source/binary format option, 748

sources and run, 752

Javafx.beans.Observable class, 549

Javafx.concurrent.Service class, 559

Javafx.concurrent.Task class, 554

Javafx.scene.control.ProgressBar class, 554

Javafx.scene.control.ProgressIndicator class, 554

Javafx.scene.input.KeyCode class, 559, 561

Javafx.scene.input.KeyCombination class, 559, 561

Javafx.scene.layout.GridPane class, 541

Javafx.scene.Node class, 531

Javafx.scene.paint.Color class, 533

Javafx.scene.paint.LinearGradient class, 533

Javafx.scene.paint.RadialGradient class, 533

Javafx.scene.paint.Stop class, 533

Javafx.scene.shape.CubicCurve class, 531

javafx.scene.shape.Path class, 531

javafx.scene.shape.PathElement, 528, 531

Javafx.scene.shape.Shape class, 525

Javafx.scene.text.Text class, 523

javafx.scene.text.Text node, 524

javafx.stage.Stage object, 523

JavaMail, 779780

JoinRowSetImpl() object, 300

imagesL

Logging exceptions, 14344

imagesM

MenuItem, 540

Model View Controller (MVC), 413, 551

MoveToCurrentRow() method, 294

MoveToInsertRow() method, 294

Multiply() method, 550

imagesN

NumberBinding class, 546

NumberExpressionBase class, 550

NumberFormat instance, 251

Numbers

arithmetic operations, 4951

comparison operators, 47

complex numbers

isNaN() method, 53

Javadoc JAR file, 51

real and imaginary, 51

standard mathematics methods, 52

trigonometic methods, 52

decimalformat class, 44

decimalformat pattern characters, 46

floating-point numbers, 4849

formatDouble() method, 45

formatting and parsing, 5354

int values, 46

Integer.compare(int,int) method, 47

Integer.MAX_VALUE/Integer.MIN_VALUE, 44

java.lang.Math round() method, 43, 44

java.util.Random class, 56

Math.random() method, 57

monetary values, 5456

NumberFormat class, 45

Random setSeed() method, 57

roundDoubleToLong() method, 44

roundFloatToInt() method, 44

Object-oriented Java, 145booleantrue and booleanfalse result, 173

ByteArrayOutputStream and ByteArrayInputStream, 168

class encapsulation

constructPlayer() method, 182183

inner class, 178182

class functionality, 174176

class interaction via interface, 162163

class template definition, 176178

Cloneable interface, 164166

control access, 145146

deep copies, 168

equals() and hashCode() method, 169172

instance contruction, same class with different values

builder pattern, 158

buildNewTeam() method, 162

buildPlayerList() method, 162

designateTeamCity() method, 162

Roster class, 161

Team object, 160

TeamBuilder interface, 160

TeamType interface, 158159, 161162

instance generation, 151152

interface definition, 155157

Lisp language, 145

one instance class

enum function, 149

getInstance() accessor method, 149150

INSTANCE element, 150

privatestaticfinal field, 150

Singleton pattern, 148149

Statistics class, 150

== and != operators, 169overridden equals() method, 173

private fields, 146147

reusable objects creation, 153155

shallowCopyClone() method, 166167

string's hashCode() method, 174

super.clone() method, 168

imagesO

ObservableList, 566

Ojdbc6.jar JDBC driver, 288

imagesP

PaintComponent() method, 323, 328

Pareto principle, 328

Path elements, 531532

Path.subtract() method, 532

PerformCreate() method, 270

PerformRead() method, 270

PerformUpdate() method, 270

PrepareCall() method, 318319

PreparedStatement getArray() method, 317

PreparedStatement setArray() method, 314

PreparedStatement setClob() method, 311

PreparedStatements

catch block, 278279

CLOB, 311

close() method, 279

executeQuery() method, 279

finally block, 279

pstmt, 279

query, 275276

recipeNumber String, 279

recipeNumber variable, 278

record deletion, 277

record insertion, 276

ResultSet, 279, 285, 286

setInt(position, variable) method, 278

SQL control, 275

SQL string, 277, 278

substitution variable, 277, 278

try-catch block, 278

updatable ResultSet, 288

prepareStatement() method, 285

imagesQ

QuadCurveBuilder, 532

Quadratic Bézier curve, 350

imagesR

RadioMenuItem, 540

readClob() method, 311

registerOutParameter() method, 318

ResultSet getInt() method, 265

ResultSet getString() method, 265

Rich Internet applications (RIAs), 513

rollback() method, 280, 284

imagesS

Scalable Vector Graphics (SVG), 745

SDP protocol transport, 812

selectionItemProperty() method, 567

Serializing Java objects

convert and traverse, 108

copying file, 115116

directory creation, 117

directory monitoring

built-in poll mechanism, 122

ENTRY_DELETE, 121

types,watchEvents, 122

Watch Event, 121

watchKey.pollEvents() method, 122

WatchService.poll, 122

externalizable interface, 110

file moving, 116

Files.createDirectory() method, 118

iterating over files, 118119

marker interface, 107

ObjectOutput methods, 110

ObjectOutputStream class, 106

path execution, 115

property files, 123124

querying, 119120

readExternal(ObjectInput in), 110

readExternal/writeExternal methods, 109

serialization/deserialization mechanism, 109

socket connection

channels.newInputStream(socket) method, 114

Channels.newOutputStream() method, 114

IP address and port, 113

isDone(),isCancelled() method, 114

ObjectOutputStream.reset() method, 115

ObjectOutputStream.writeUnshared() method, 115

send/receive objects, 112

serverSocketChannel.accept() method, 114

socketChannel.connect() method, 114

speed vs. size vs. ease of use, 107

string class, 107

transient properties, 108

uncompressing compressed files, 124126

writeExternal(ObjectOutput out), 110

XML, 111112

Servlets, 651

Apache Tomcat, 651

application-wide parameters

<context-param> XML tag, 671672

MailServlet, 667670

ServletContext object, 667

user feedback form, 671

web.xml file, 670671

attribute changes

addListener() method, 680

attributeAdded() method, 680

attributeRemoved() method, 680

attributeReplaced() method, 680

HttpSessionAttributeListener, 677679

HttpSessionBindingEvent method, 680

configuration and mapping, 654

container events, 675677

destroy() method, 655

doGet() method, 655

finalization, 684685

functionality, 653654

GenericServlet type, 654

HttpServlet methods, 654655

HttpServletRequest and HttpServletResponse object, 656

HttpServletResponsesendRedirect() method, 675

IDE installation, 652

Java SE 7, 651

Java servlet API, 651

packaging, compiling and deployment, 656658

parameters initialization, 661664

registration without WEB-XML, 659661

request and response function

getParameter() method, 666

HTML-based web form, 664

HttpServlet object, 666

MathServlet, 664, 665

servlet-based web frameworks, 667

sendRedirect() method, 674675

service() method, 655

servlet init() method, 655

ServletConfig interface, 656

session information management, 681684

SimpleServlet.java file, 654

startup.sh/startup.bat file, 652

tomcat-users.xml configuration file, 652

web request filter, 672674

setAccelerator() method, 562

setAutoCommit() method, 283

setCommand() method, 293

setEffect() method, 532

setKeys() method, 293

setOffsetX() method, 532

setOffsetY() method, 532

setPassword() method, 293

setProperty() method, 567

setSide() method, 573

setString() method, 311

setStyle() method, 545

setTransformBounds property, 406

setUrl() method, 293

setUsername() method, 293

Shape node, 531

SimpleAppLauncher.launch() method, 323

SimpleStringProperty, 549

Static Code Analyzer (SCA), 226

Stream Unique Identifier (SUID), 108

Strings

case changing

case-sensitive string, 30

toLowerCase() method, 3031

toUpperCase() method, 3031

class, 247

demoComplex() method, 249

demoSimple() method, 249

enRegEx and jaRegEx variables, 247

java.util.regex class, 250

methods, 249

replaceAll() method, 248

replaceFirst() method, 248

split() method, 248

comparing

built-in equals()method, 26

coding, 2728

compareTo()and compareToIgnoreCase() methods, 29

compareTo()method, 26

compareToIgnoreCase() method, 26

comparison operator (==), 28

equalsIgnoreCase() method, 26, 29

Java String equals() method, 28

concatenating

built-in String, 33

combining, 31

concat() method, 32, 33

concatenation operator, 32

helper method, 33

StringBuffer class, 33

StringBuilder/StringBuffer, 32

datat type,programming language, 25

file name end string

endsWith() method, 4142

filename variable, 42

helper methods, 26

iterating character string

charAt() method, 3537

length() methods, 37

toCharArray() method, 35, 36

numeric conversion

autoboxing, 34

Integer.parseInt()method, 34

Integer.valueOf()method, 34

integers, 33

NumberFormatExeption, 34

parseInt() method, 35

unboxing, 34

valueOf()and parseInt() methods, 34

replacing text

Pattern.compile() method, 41

replaceAll() method, 40

retrieval problem, 25

startingindex and endingindex, 26

substring() method,solution, 25

text matches

code and pattern, 38

coding, 3738

Matcher find() method, 40

Matcher lookingAt() method, 40

Matcher matches() method, 40

matches() method, 39

Pattern.compile() method, 39

Pattern.matches() method, 40

regular expressions, 39

String helper matches(), 37

three-step process, 38

trimming whitespace

pattern-searching program, 30

String trim() method, 30

Swing API

animation

actionPerformed() method, 503

creation, 504

effect button, 502

mimic animation, 505

mouseExited () method, 504

stop() method, 505

timer, 503

application

com.acme.myapp.Main, 502

executable jar file, 500

manifest.mf file, 501

web start, 500

associating listeners

DefaultListModel class, 493

document, 493

Document API, 491

DocumentListener, 491493

insertUpdate() method, 493

JList listBox, 492

MyDocumentListener class, 493

removeAllElements() method, 493

removeUpdate() method, 493

searchDictionary() method, 493

borders designing and manipulation

BorderDesigner() method, 466

BorderFactory swing, 465

borderTypeList, 466

ColorComboBox, 467

createColorComboBox() method, 469

createDashedBorder, 467

createStrokeBorder, 467

DashedBorder class, 469

designing, 468

JComponent's setBorder() method, 469

JTabbedPane, 465

LineBorder, 467

map and array variables, 469

StrokeBorder class, 469

TitledBorder, 467, 469

canvas drawing

anchorPt, 461

drawings, 461

Graphics2D class, 458

JPanel class, 458459

mouseClicked, 460

mouseDragged() function, 462

MouseListener class, 458

MouseMotionListener class, 458

mousePress() function, 461

mouseRelease() function, 462

oneDrawing, 461

paintComponent() method, 462

database

code recipe, 443445

DBUtils class, 445447

DBUtils.saveContact() method, 448

derby.jar and derbytools.jar, 445

doInBackground() method, 448

executeUpdate() method, 449

InterruptedException and ExecutionException, 448

Java Database Connectivity, 443

JDBC, 443

saveContact() method, 449

submitting form values, 448

SubmittingFormValuestoDatabase class, 448

dialog box

ActionListener() method, 487

apply() method, 490

ButtonGroup() method, 487

CustomGridLayout () method, 488

development, 489

JDialog class, 486

JDialog's setModal() method, 490

JFrame class, 490

setVisible() method, 490

document

FontFamilyAction, 485

JRadioButtonMenuItem, 483485

JTextPane class, 485

keyboard shortcuts, 485

StyledDocument, 482

StyledEditorKit, 485

TextPane class, 482

editing commands

AbstractAction class, 475

action, 477

actionPerformed() method, 478

ActionWithEditCommand, 477

JTextAreas getDocument() method, 477

MyUndoableEditListener class, 478

MyUndoableEditListener() method, 474

putValue() method, 478

RedoAction redoAction class, 475

StyledDocument class, 473

undoableEditHappened() method, 478

UndoManager class, 473, 477

UndoManager undo class, 476

events generation

ActionListener, 435

addActionListener() method, 436

events, 436

JButton, 435

JPanel, 435

GUI applications

CellConstraint() method, 495

CustomGridLayout, 495

HTML, 496

JButton class, 496

JLabel class, 496

label and button, 494

GUI components

adding, 421

addLayoutComponent, 426

AppSetup interface, 420

BorderLayout manager, 431

BorderLayout.Center, 423

custom layout, 431, 432

DesignGridLayout, 435

FlowLayout manager, 431

form interfaces, 432

getLayoutAlignmentX, 429

getLayoutAlignmentY, 429

getScreenSize() method, 423

GridBagConstraints class, 432

GridBagLayout class, 432

GroupLayout, 435

implements,MyCustomGridLayout, 426

JGoodies, 435

JLabel class, 421

JPanel class, 421

JTextField class, 421, 433

LayingOutComponentsOnGui class, 424

LayingOutComponentsOnGui.java, 424

LayingOutComponentsOnGui.java file, 424

layoutContainer() method, 434

LayoutManager2 methods, 434

list, 418

MigLayout, 435

MyCellConstraint setAlign, 430

MyCellConstraint.java, 424, 430

MyCustomGridLayout class, 426, 433

MyCustomGridLayout.java, 424

preferredLayoutSize, 427

removeLayoutComponent, 426

setDefaultCloseOperation() method, 422

SimpleAppLauncher class, 420

SimpleAppLauncher.displayGUI() method, 422

SimpleAppLauncher.java code, 419

SimpleAppLauncher.launch() method, 421

Toolkit.getDefaultToolkit() method, 423

updateMaxColWidthAndHeight, 429

GUI creation

application, 413415

displayGUI() method, 416

EDT, 416

javax.swing.JComponent, 413

javax.swing.JFrame, 413, 415

javax.swing.SwingUtilities, 414

JFrame's setVisible() method, 417

SwingUtilities.invokeLater() method, 416

UI and graphics, 415

GUI look and feel

JScrollPane() method, 497

JTree() method, 498

Nimbus, 499

UIManager.getInstalledLookAndFeels() method, 499

UIManager.setLookAndFeel() method, 496

icons

createImageIcon() method, 464

generating and laying, 464

getClass() method, 465

getResource() method, 465

ImageIcon class, 462, 463

JButton class, 462, 464

JLabel class, 462, 464

JPanel class, 462

JLayer component

e-mail format, error, 508

EmailValidationLayerUI ()method, 509

ImageIO.read() method, 508

invalid e-mail address, 508

JLayer.getView() method, 509

paint() method, 509

UsingJXLayer class, 508

UsingJXLayer() method, 506

warning, 505, 508

keyboard shortcuts

AbstractAction class, 479

accelerator, 481

creation, 481

KeyEvent class, 479

KeyStroke class, 479

new JMenuBar() method, 479

putValue() method, 481

menu

adding, 455

AppSetup interface, 455

CheckBoxMenuItem class, 453

JCheckBoxMenuItem class, 453, 456

JMenu class, 453, 455

JMenuItem class, 453, 455

JRadioButtonMenuItem class, 453455

multi-window program

internal windows, 451

JDesktopPane, 452

JDesktopPane class, 449

JInternalFrame class, 449

newWindowMenu method, 452

pop up internal windows, 449451

setDragMode() method, 452

SimpleAppLauncher.launch() method, 452

printing support

actionPerformed() method, 512

components application, 511

dialog box, 512

java.awt.print.Printable API class, 512

java.awt.print.PrinterJob class, 512

JTable print() method, 510

timesheet application, 511

swing application

jar executable, 417

jar file, 417

Java app, 417

Java web start, 417

web page, 417

tabs

adding, 458

JTabbedPane class, 456

SCROLL_TAB_LAYOUT policy, 458

setTabPlacement() method, 458

TabPlacementAction implements, 457

text components

AbstractAction class, 473

ActionListener class, 473

actionPerformed() method, 473

CustomGridLayout, 470

events with buttons, 472

getSystemLookAndFeelClassName() methid, 471

JButton, 473

JPasswordField class, 469, 472

JScrollPane class, 469

JTextArea class, 469, 472

JTextField class, 469, 472

JTextPane class, 472

login application, 472

user interface

createWorker() method, 442

doInBackground() method, 442

done() method, 442

file transfer, 437440

GUI, 441

JTextArea, 441

process() method, 442

publish() method, 442

setIndeterminate(false) method, 441

setStringPainted() method, 441

SwingWorker class, 437, 441

Swing GUI applications, 385

SwingUtilities.invokeLater() method, 323

SwingWorker class, 558

SyncProviderException, 294

System.out() method, 265

imagesT

Text nodes

changing text fonts, 525527

keyboard sequences, 561

text drawing, 523525

Thread dump, 234236

ToggleGroup class, 540

TransactionExample class, 280

Transformation nodes, 400

Transmission Control Protocol/Internet Protocol (TCP/IP) layer, 807

imagesU

Unicode, internationalization and currency codes, 237

byte array conversion, 253254

character streams and buffers conversion. see Character streams and buffers conversion

default currency, 251252

default Locale setting

locale.category enumeration, 246

Locale.FRANCE method, 246

Locale.setDefault() method, 244

ResourceBundle text, DISPLAY locale, 244246

ResourceBundle.getBundle() method, 246

Locales creation

BCP 47 document and standards, 243

Builder creation, 240241

Java 7 Locale.Builder class, 240

java.util.Locale class, 240

Locale.Builder instance, 243

Locale.forLanguageTag() method, 241

locale-sensitive class, 242

NumberFormat and DateFormat classes, 240

static instances, 242

regular expression syntax. see also String class

backslash character, 250

Java regular expressions, 250

non-ASCII characters, 250

Unicode digit character conversion, 237

Character class Java API documentation, 239

Character.digit() static method, 239

code points, 238239

isDigit property, 239

java.lang.Character, 237

updateItem() method, 567

updateMessage() method, 558

updateProgress() method, 558

updateRow() method, 289, 294

updateString() method, 288

updateXXX() methods, 288

URL

generation, 818820

parsing

accessor methods, 821

getFile() method, 822

getPath() method, 822

getQuery() and getRef() method, 822

ParseUrl class, 820821

User Datagram Protocol (UDP), 816

imagesV

VARRAY columns

array value retrieval, 315317

array value storage, 312315

VisualVM, 228

imagesW

writeAttribute() method, 790

writeCharacters() method, 790

writeEndElement() method, 790

writeStartDocumentMethod() method, 790

writeStartElement() method, 790

imagesX, Y, Z

XML processing, 787

file reading

hasNext() method, 794

javax.xml.stream.XMLStreamReader interface, 791, 792

nextEvent() method, 794

StAX, 794

XMLEventReader, 792794

file writing, 787

java.io.FileOutputStream class, 789

javax.xml.stream.XMLStreamWriter class, 788789

StAX, 789

XMLStreamWriter instance, 790

Java binding creation, 800801

JAXB, 803804

transformation

file requirements, 795

HTML table, 797

javax.xml.transform package, 795

patients.xml file, 796

XSL document, 796797

unmarshall, 801802

validation, 798800

XRender, 321

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.187.24