Professional Documents
Culture Documents
Textbook Java Apis Extensions and Libraries Kishori Sharan Ebook All Chapter PDF
Textbook Java Apis Extensions and Libraries Kishori Sharan Ebook All Chapter PDF
Kishori Sharan
Visit to download the full and correct content document:
https://textbookfull.com/product/java-apis-extensions-and-libraries-kishori-sharan/
More products digital (pdf, epub, mobi) instant
download maybe you interests ...
https://textbookfull.com/product/java-9-revealed-for-early-
adoption-and-migration-1st-edition-kishori-sharan-auth/
https://textbookfull.com/product/java-language-features-with-
modules-streams-threads-i-o-and-lambda-expressions-2nd-edition-
kishori-sharan/
https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-
loucas/
https://textbookfull.com/product/beginning-java-9-fundamentals-
arrays-objects-modules-jshell-and-regular-expressions-sharan/
RESTful Java Web Services A pragmatic guide to
designing and building RESTful APIs using Java 3rd
Edition Balachandar
https://textbookfull.com/product/restful-java-web-services-a-
pragmatic-guide-to-designing-and-building-restful-apis-using-
java-3rd-edition-balachandar/
https://textbookfull.com/product/building-hybrid-android-apps-
with-java-and-javascript-applying-native-device-apis-japplying-
native-device-apis-1st-edition-gok-nizamettin-khanna-nitin/
https://textbookfull.com/product/pro-jpa-2-in-java-ee-8-an-in-
depth-guide-to-java-persistence-apis-third-edition-mike-keith/
https://textbookfull.com/product/pro-java-9-games-development-
leveraging-the-javafx-apis-1st-edition-wallace-jackson-auth/
https://textbookfull.com/product/chatgpt-for-java-a-hands-on-
developers-guide-to-chatgpt-and-open-ai-apis-1st-edition-bruce-
hopkins/
Java APIs,
Extensions and
Libraries
With JavaFX, JDBC, jmod, jlink,
Networking, and the Process API
—
Second Edition
—
Kishori Sharan
Java APIs, Extensions
and Libraries
With JavaFX, JDBC, jmod, jlink,
Networking, and the Process API
Second Edition
Kishori Sharan
Java APIs, Extensions and Libraries: With JavaFX, JDBC, jmod, jlink, Networking, and the Process API
Kishori Sharan
Montgomery, Alabama, USA
ISBN-13 (pbk): 978-1-4842-3545-4 ISBN-13 (electronic): 978-1-4842-3546-1
https://doi.org/10.1007/978-1-4842-3546-1
Library of Congress Control Number: 2018939410
Copyright © 2018 by Kishori Sharan
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage
and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or
hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are
not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material
contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Steve Anglin
Development Editor: Matthew Moodie
Coordinating Editor: Mark Powers
Cover designed by eStudioCalamar
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail
orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC
and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc).
SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail editorial@apress.com; for reprint, paperback, or audio
rights, please email bookpermissions@springernature.com.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web
page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to readers
on GitHub via the book’s product page, located at www.apress.com/9781484235454. For more detailed
information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
Contents
■
■Chapter 1: Introduction to Swing�������������������������������������������������������������������������� 1
What Is Swing?���������������������������������������������������������������������������������������������������������������� 2
The Simplest Swing Program������������������������������������������������������������������������������������������� 3
Components of a JFrame������������������������������������������������������������������������������������������������� 7
Adding Components to a JFrame������������������������������������������������������������������������������������� 9
Some Utility Classes������������������������������������������������������������������������������������������������������� 13
The Point Class������������������������������������������������������������������������������������������������������������������������������������� 13
The Dimension Class���������������������������������������������������������������������������������������������������������������������������� 13
The Insets Class������������������������������������������������������������������������������������������������������������������������������������ 14
The Rectangle Class����������������������������������������������������������������������������������������������������������������������������� 14
Layout Managers������������������������������������������������������������������������������������������������������������ 15
FlowLayout������������������������������������������������������������������������������������������������������������������������������������������� 16
BorderLayout���������������������������������������������������������������������������������������������������������������������������������������� 21
CardLayout������������������������������������������������������������������������������������������������������������������������������������������� 24
BoxLayout��������������������������������������������������������������������������������������������������������������������������������������������� 26
GridLayout�������������������������������������������������������������������������������������������������������������������������������������������� 31
GridBagLayout�������������������������������������������������������������������������������������������������������������������������������������� 33
SpringLayout���������������������������������������������������������������������������������������������������������������������������������������� 51
GroupLayout����������������������������������������������������������������������������������������������������������������������������������������� 59
The null Layout Manager���������������������������������������������������������������������������������������������������������������������� 68
iii
■ Contents
iv
■ Contents
JTree����������������������������������������������������������������������������������������������������������������������������� 163
JTabbedPane and JSplitPane��������������������������������������������������������������������������������������� 169
Custom Dialogs������������������������������������������������������������������������������������������������������������ 171
Standard Dialogs���������������������������������������������������������������������������������������������������������� 174
File and Color Choosers����������������������������������������������������������������������������������������������� 181
JFileChooser��������������������������������������������������������������������������������������������������������������������������������������� 181
JColorChooser������������������������������������������������������������������������������������������������������������������������������������ 185
JWindow����������������������������������������������������������������������������������������������������������������������� 186
Working with Colors����������������������������������������������������������������������������������������������������� 186
Working with Borders��������������������������������������������������������������������������������������������������� 187
Working with Fonts������������������������������������������������������������������������������������������������������ 190
Validating Components������������������������������������������������������������������������������������������������ 192
Painting Components and Drawing Shapes����������������������������������������������������������������� 193
Immediate Painting������������������������������������������������������������������������������������������������������ 198
Double Buffering���������������������������������������������������������������������������������������������������������� 198
JFrame Revisited���������������������������������������������������������������������������������������������������������� 200
Summary���������������������������������������������������������������������������������������������������������������������� 202
■
■Chapter 3: Advanced Swing������������������������������������������������������������������������������ 205
Using HTML in Swing Components������������������������������������������������������������������������������ 206
Threading Model in Swing�������������������������������������������������������������������������������������������� 207
Pluggable Look and Feel���������������������������������������������������������������������������������������������� 215
Drag and Drop�������������������������������������������������������������������������������������������������������������� 221
Multiple Document Interface Application��������������������������������������������������������������������� 229
The Toolkit Class����������������������������������������������������������������������������������������������������������� 232
Decorating Components Using JLayer������������������������������������������������������������������������� 234
Translucent Windows��������������������������������������������������������������������������������������������������� 241
Shaped Window������������������������������������������������������������������������������������������������������������ 247
Summary���������������������������������������������������������������������������������������������������������������������� 250
v
■ Contents
■
■Chapter 4: Network Programming��������������������������������������������������������������������� 253
What Is Network Programming?���������������������������������������������������������������������������������� 253
Network Protocol Suite������������������������������������������������������������������������������������������������ 255
IP Addressing Scheme�������������������������������������������������������������������������������������������������� 258
IPv4 Addressing Scheme�������������������������������������������������������������������������������������������������������������������� 258
IPv6 Addressing Scheme�������������������������������������������������������������������������������������������������������������������� 261
vi
■ Contents
vii
■ Contents
■
■Chapter 5: JDBC API������������������������������������������������������������������������������������������ 347
What Is the JDBC API?�������������������������������������������������������������������������������������������������� 348
System Requirements�������������������������������������������������������������������������������������������������� 348
Types of JDBC Drivers�������������������������������������������������������������������������������������������������� 349
JDBC Native API Driver����������������������������������������������������������������������������������������������������������������������� 349
JDBC-Net Driver��������������������������������������������������������������������������������������������������������������������������������� 349
JDBC Driver���������������������������������������������������������������������������������������������������������������������������������������� 350
A Brief Overview of Apache Derby�������������������������������������������������������������������������������� 350
Downloading Derby���������������������������������������������������������������������������������������������������������������������������� 350
Installing Derby����������������������������������������������������������������������������������������������������������������������������������� 350
Derby Installation Files����������������������������������������������������������������������������������������������������������������������� 350
Configuring Derby������������������������������������������������������������������������������������������������������������������������������� 351
Running the Derby Server������������������������������������������������������������������������������������������������������������������ 351
viii
■ Contents
ix
■ Contents
ResultSetMetaData������������������������������������������������������������������������������������������������������� 435
Using RowSets������������������������������������������������������������������������������������������������������������� 437
Creating a RowSet������������������������������������������������������������������������������������������������������������������������������ 440
x
■ Contents
java.security.AccessControlException������������������������������������������������������������������������������������������������ 505
java.lang.ClassNotFoundException����������������������������������������������������������������������������������������������������� 506
xi
■ Contents
xii
■ Contents
FXML���������������������������������������������������������������������������������������������������������������������������� 637
Printing������������������������������������������������������������������������������������������������������������������������� 642
Summary���������������������������������������������������������������������������������������������������������������������� 647
■
■Chapter 9: Scripting in Java������������������������������������������������������������������������������ 651
What Is Scripting in Java?�������������������������������������������������������������������������������������������� 651
Executing Your First Script������������������������������������������������������������������������������������������� 653
Using Other Scripting Languages��������������������������������������������������������������������������������� 655
Exploring the javax.script Package������������������������������������������������������������������������������ 658
The ScriptEngine and ScriptEngineFactory Interfaces����������������������������������������������������������������������� 658
The AbstractScriptEngine Class���������������������������������������������������������������������������������������������������������� 658
The ScriptEngineManager Class��������������������������������������������������������������������������������������������������������� 658
The Compilable Interface and the CompiledScript Class�������������������������������������������������������������������� 658
The Invocable Interface���������������������������������������������������������������������������������������������������������������������� 658
The Bindings Interface and the SimpleBindings Class����������������������������������������������������������������������� 659
The ScriptContext Interface and the SimpleScriptContext Class�������������������������������������������������������� 659
The ScriptException Class������������������������������������������������������������������������������������������������������������������ 659
Discovering and Instantiating Script Engines������������������������������������������������������������������������������������� 659
xiii
■ Contents
xiv
■ Contents
Summary���������������������������������������������������������������������������������������������������������������������� 780
■
■Chapter 12: Custom Runtime Images���������������������������������������������������������������� 783
What Is a Custom Runtime Image?������������������������������������������������������������������������������ 783
No More rt.jar��������������������������������������������������������������������������������������������������������������� 784
Creating Custom Runtime Images�������������������������������������������������������������������������������� 784
Binding Services���������������������������������������������������������������������������������������������������������� 788
Using Plugins with the jlink Tool����������������������������������������������������������������������������������� 790
The jimage Tool������������������������������������������������������������������������������������������������������������ 793
Summary���������������������������������������������������������������������������������������������������������������������� 795
Index��������������������������������������������������������������������������������������������������������������������� 797
xvi
About the Author
xvii
About the Technical Reviewer
Manuel Jordan Elera is an autodidactic developer and researcher who enjoys learning new technologies for
his own experiments and creating new integrations.
Manuel won the 2010 Springy Award – Community Champion and Spring Champion 2013. In his
little free time, he reads the Bible and composes music on his guitar. Manuel is known as dr_pompeii.
He has technically reviewed numerous books for Apress, including Pro Spring Messaging (2017),
Pro Spring, 4th Edition (2014), Practical Spring LDAP (2013), Pro JPA 2, Second Edition (2013), and
Pro Spring Security (2013).
Read his 13 detailed tutorials about many Spring technologies, contact him through his blog at http://
www.manueljordanelera.blogspot.com, and follow him on his Twitter account at @dr_pompeii.
xix
Acknowledgments
I would like to thank my family members and friends for their encouragement and support—my mom
Pratima Devi; my elder brothers, Janki Sharan and Dr. Sita Sharan; my nephews, Gaurav and Saurav; my
sister Ratna; and my friends Karthikeya Venkatesan, Rahul Nagpal, Ravi Datla, Mahbub Choudhury, Richard
Castillo, and many more friends not mentioned here.
My wife, Ellen, was always patient as I spent long hours at my computer desk working on this book.
I want to thank her for all of her support in writing this book.
Special thanks to my friend Preethi Vasudev for offering her valuable time and providing solutions
to the exercises in this book. She likes programming challenges—particularly Google Code Jam. I bet she
enjoyed solving the exercises in each chapter of this book.
My sincere thanks are due to the wonderful team at Apress for their support during the publication of
this book. Thanks to Mark Powers, the editorial operations manager, for providing excellent support. Thanks
to the technical reviewer, Manuel Jordan Elera, for his technical insights and feedback during the review
process; he was instrumental in weeding out several technical errors. Last but not least, my sincere thanks to
Steve Anglin, the lead editor at Apress, for taking the initiative for the publication of this book.
xxi
Introduction
xxiii
■ Introduction
Audience
This book is designed to be useful to anyone who wants to learn the Java programming language. If you
are a beginner, with little or no programming background in Java, you are advised to read the companion
book Beginning Java 9 Fundamentals (second edition) and Java Language Features (second edition) before
reading this book. This book contains topics of various degrees of complexity. As a beginner, if you find
yourself overwhelmed while reading a section in a chapter, you can skip to the next section or the next
chapter and revisit it later when you gain more experience.
xxiv
■ Introduction
If you are a Java developer with an intermediate or advanced level of experience, you can jump to
a chapter or a section in a chapter directly. If you are reading this book to get a certification in the Java
programming language, you need to read almost all of the chapters, paying attention to all of the detailed
descriptions and rules. Most of the certification programs test your fundamental knowledge of the language,
not advanced knowledge. You need to read only those topics that are part of your certification test.
Compiling and running over 200 complete Java programs will help you prepare for your certification.
If you are a student who is attending a class in the Java programming language, you should read the
chapters of this book selectively. You need to read only those chapters that are covered in your class syllabus.
I am sure that you, as a Java student, do not need to read the entire book page by page.
The learning and knowledge that we have, is, at the most, but little compared with that of
which we are ignorant.
—Plato
True knowledge exists in knowing that you know nothing. And in knowing that you know
nothing, that makes you the smartest of all.
—Socrates
Readers are advised to use the API documentation for the Java programming language as much
as possible while using this book. The Java API documentation is where you will find a complete list of
everything available in the Java class library. You can download (or view) the Java API documentation from
the official website of Oracle Corporation at www.oracle.com. While you read this book, you need to practice
writing Java programs yourself. You can also practice by tweaking the programs provided in the book. It does
not help much in your learning process if you just read this book and do not practice by writing your own
programs. Remember that “practice makes perfect,” which is also true in learning how to program in Java.
xxv
CHAPTER 1
Introduction to Swing
Swing and AWT APIs are defined in the java.desktop module. Your module that uses Swing needs to
read the java.desktop module as the jdojo.swing.intro module does.
What Is Swing?
Swing provides graphical user interface (GUI) components to develop Java applications with a rich set of
graphics such as windows, text fields, buttons, checkboxes, etc. What is a GUI? Before I define a GUI, let me
first define a user interface (UI). A program does three things:
• Accepts inputs from the user
• Processes the inputs
• Produces outputs
A user interface provides a means to exchange information between a user and a program, in terms of
inputs and outputs. In other words, a user interface defines the way the interaction between the user and a
program takes place. Typing text using a keyboard, selecting a menu item using a mouse, or clicking a button
can provide input to a program. The output from a program can be displayed on a computer monitor in the
form of character-based text, a graph such as a bar chart, a picture, etc.
You have written many Java programs. You have seen programs where users had to provide inputs to the
program in the form of text entered on the console, and the program would print the output on the console.
A user interface where the user’s input and the program’s output are in text form is known as a character-
based user interface. A GUI lets users interact with a program using graphical elements called controls or
widgets, using a keyboard, a mouse, and other devices.
Figure 1-1 shows a program that lets users enter a person’s name and date of birth (DOB) and save the
information by using the keyboard. It is an example of a character-based user interface.
Figure 1-2 lets the user perform the same actions, but using a graphical user interface. It displays six
graphical elements in a window. It uses two labels (Name: and DOB:), two text fields where the user will
enter the Name and DOB values, and two buttons (Save and Close). A graphical user interface, compared to
a character-based user interface, makes the user’s interaction with a program easier. Can you guess what
kind of application you are going to develop in this chapter? It will be all about GUI. GUI development is
interesting and a little more complex than character-based program development. Once you understand the
elements involved in GUI development, it will be fun to work with it.
2
Chapter 1 ■ Introduction to Swing
This chapter attempts to cover the basics of GUI development using Swing’s components and top-
level containers. Care has been taken to explain GUI-related details for those programmers who might
not have used any programming languages/tools to develop a GUI before. If you have already used a GUI
development language/tool, it will be easier for you to understand the materials covered in this chapter.
Swing is a vast topic and it is not possible to cover every detail of it. It deserves a book by itself. In fact, there
are a few books in the market dedicated only to Swing.
A container is a component that can hold other components inside it. A container at the highest level
is called a top-level container. JFrame, JDialog, JWindow, and JApplet are examples of top-level containers.
JPanel is an example of a simple container. JButton, JTextField, etc. are examples of components. In
a Swing application, every component must be contained within a container. The container is known as
the component’s parent and the component is known as container’s child. This parent-child relationship
(or container-contained relationship) is known as containment hierarchy. To display a component on the
screen, a top-level container must be at the root of the containment hierarchy. Every Swing application must
have at least one top-level container. Figure 1-3 shows the containment hierarchy of a Swing application.
A top-level container contains a container called “Container 1,” which in turn contains a component
called “Component 1” and a container called “Container 2,” which in turn contains two components called
“Component 2” and “Component 3.”
3
Chapter 1 ■ Introduction to Swing
One of the constructors of the JFrame class takes a String argument, which is the title of the JFrame.
Classes representing Swing components are in the javax.swing package, and so is the JFrame class. The
following snippet of code creates a JFrame object with its title set to Simplest Swing:
When you create a JFrame object, by default, it is not visible. You need to call its setVisible(boolean
visible) method to make it visible. If you pass true to this method, the JFrame is made visible, and if you
pass false, it is made invisible.
That is all you have to do to develop your first Swing application! In fact, you can wrap the two
statements, to create and display a JFrame, into one statement, like so:
Creating a JFrame and making it visible from the main thread is not the correct way to start a Swing
application. However, it does not do any harm in the trivial programs that you will use here, so I will
continue using this approach to keep the code simple to learn, so you can focus on the topic you are
learning. It also takes an understanding of event-handling and threading mechanisms in Swing to
understand why you need to start a Swing application the other way. Chapter 3 explains how to start a Swing
application in detail. The correct way of creating and showing a JFrame is to wrap the GUI creation and
make it visible in a Runnable and then pass the Runnable to the invokeLater() method of the javax.swing.
SwingUtilities or java.awt.EventQueue class as follows:
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
...
SwingUtilities.invokeLater(() -> new JFrame("Test").setVisible(true));
Listing 1-2 contains the complete code to create and display a JFrame. When you run this program, it
displays a JFrame at the top-left corner of the screen, as shown in Figure 1-4. The figure shows the frame
when the program was run on Windows 10. On other platforms, the frame may look a little different. Most of
the screenshots for the GUIs in this chapter were taken on Windows 10.
import javax.swing.JFrame;
4
Chapter 1 ■ Introduction to Swing
This was not very impressive, was it? Do not despair. You will improve this program as you learn more
about Swing. This was just to show you the tip of the iceberg of what Swing offers.
You can resize the JFrame shown in the Figure 1-4 to make it bigger. Place your mouse pointer on any of
the four edges (left, top, right, or bottom) or any of the four corners of the displayed JFrame. The mouse pointer
changes its shape to a resize pointer (a line with arrows at both ends) when you place it on the JFrame’s edge.
Then just drag the resize mouse pointer to resize the JFrame in the direction you want to resize it.
Figure 1-5 shows the resized JFrame. Note that the text “Simplest Swing” that you passed to the
constructor when you created the JFrame is displayed in the title bar of the JFrame.
How do you exit a Swing application? How do you exit when you run the program listed in Listing 1-2?
When you click the close button in the title bar (right-most button on the title bar with an X), the JFrame
is closed. However, the program does not exit. If you are running this program from a command prompt,
the prompt does not return when you close the JFrame. You will have to force exit the program, for
example, by pressing Ctrl+C if you are running it from a command prompt on Windows. So, how do
you exit a Swing application? You can define one of the four behaviors of a JFrame to determine what
happens when the JFrame is closed. They are defined in the javax.swing.WindowConstants interface as
four constants. The JFrame class implements the WindowConstants interface. You can reference all these
constants using JFrame.CONSTANT_NAME syntax (or you can use the WindowConstants.CONSTANT_NAME
syntax). The four constants are as follows:
• DO_NOTHING_ON_CLOSE
• HIDE_ON_CLOSE
• DISPOSE_ON_CLOSE
• EXIT_ON_CLOSE
The DO_NOTHING_ON_CLOSE option does not do anything when the user closes a JFrame. If you set this
option for a JFrame, you must provide some other way to exit the application, such as an Exit button or an
Exit menu option in the JFrame.
5
Chapter 1 ■ Introduction to Swing
The HIDE_ON_CLOSE option just hides a JFrame when the user closes it. This is the default behavior. This
is what happened when you clicked the close button in the title bar to close the program listed in Listing 1-2.
The JFrame was just made invisible and the program was still running.
The DISPOSE_ON_CLOSE option hides and disposes of the JFrame when the user closes it. Disposing a
JFrame releases any operating system-level resources used by it. Note the difference between HIDE_ON_CLOSE
and DISPOSE_ON_CLOSE. When you use the option HIDE_ON_CLOSE, a JFrame is just hidden, but it is still using
all the operating system resources. If your JFrame is hidden and shown very frequently, you may want to use
this option. However, if your JFrame consumes many resources, you may want to use the DISPOSE_ON_CLOSE
option, so the resources may be released and reused while the JFrame is not being displayed.
The EXIT_ON_CLOSE option exits the application. Setting this option works when a JFrame is closed,
as if System.exit() has been called. This option should be used with some care. This option will exit the
application. If you have more than one JFrame or any other type of window displayed on the screen, using
this option for one JFrame will close all other windows. Use this option with caution as you may lose any
unsaved data when the application exits.
You can set the default close behavior of a JFrame by passing one of the four constants to its
setDefaultCloseOperation() method as follows:
You solved one problem with the first example. Another problem is that the JFrame is displayed with no
viewable area. It displays only the title bar. You need to set the size and position of your JFrame before or after it
is visible. The size of a frame is defined by its width and height in pixels that you can set using its setSize(int
width, int height) method. The position is defined by the (x, y) coordinates in pixels of the top-left corner
of the JFrame with respect to the top-left corner of the screen. By default, its position is set to (0, 0) and this is
the reason the JFrame was displayed at the top-left corner of the screen. You can set the (x, y) coordinates of
the JFrame using its setLocation(int x, int y) method. If you want to set its size and its position in one
step, use its setBounds(int x, int y, int width, int height) method instead. Listing 1-3 fixes these two
problems in the simplest Swing program.
import javax.swing.JFrame;
6
Another random document with
no related content on Scribd:
“You had better not say any more,” she interrupted; “you will only
make matters worse.” Then added with a dawning smile, “It is what I
always do myself. I speak from experience.”
“Promise me one thing,” he urged—“that you will not drop me
when you are weeding out your acquaintance.”
“Pray, why should I drop you? My new rule does not apply to you.
Are you a millionaire?” And she broke into a laugh.
A keener observer than the young lady would have noticed a
shade of embarrassment in his glance as, after a moment’s
hesitation, he said—
“I am quite an old Indian friend now, at any rate—almost your first
acquaintance.”
“Yes, I admit all that; but you must not presume on our ancient
friendship. I warn you solemnly that the next time you laugh at me—
laugh until you actually cry—our relations will be—strained.”
Time wore on; Honor was becoming familiarized with her new
surroundings, had picked up some useful Hindustani words, made a
round of calls, and shown that she had no mean skill at tennis. And
Mrs. Brande had demonstrated that she was not a woman of words
only. She had given young Jervis a general and urgent invitation to
her house—moreover, he found favour in her husband’s eyes. He
was a fine, well-set-up, gentlemanly young fellow, a keen tennis
player, with no haw-haw humbug about him, therefore the
Honourable Pelham heartily endorsed his wife’s hospitality.
As for Captain Waring, alas! the three days’ travelling intimacy—
like steamer friendships—had flickered, and flickered, and sunk
down, and died. Mrs. Brande’s state-dinners were unimpeachable,
but desperately dull; and she was not in the “smart” set; her niece
was far too downright and raw; her sincere grey eyes had a way of
looking at him that made him feel uncomfortable—a blasé, world-
battered, selfish mortal. She had a sharp tongue, too, and no
fortune; therefore he went over to the enemy’s camp, and followed
the standard of Mrs. Langrishe.
A month had elapsed, and Shirani was as full and as gay as Miss
Paske had predicted—there were dinners, dances, balls, theatricals,
and picnics.
Visitors had shaken down into sets, and discovered whom they
liked and whom they did not like. In a short hill season there is no
time to waste on long-drawn-out overtures to acquaintance; besides,
in India, society changes so rapidly, and has so many mutual friends
—the result of so many different moves—that people know each
other as intimately in six months as they would in six years in
England. There were “sets” in Shirani, though not aggressively
defined: the acting and musical set, which numbered as stars Miss
Paske and Mr. Joy; also Captain Dashwood, of the Dappled
Hussars; Mrs. Rolland, who had once been a matchless actress, but
was now both deaf and quarrelsome; and many other lesser lights.
Then there was the “smart” set, headed by Mrs. Langrishe, who
wore dresses more suitable to Ascot than the Hymalayas; drank tea
with each other, dined with each other—talked peerage, and
discussed London gossip; looked down on many of their neighbours,
and spoke of them as being “scarcely human,” and were altogether
quite painfully exclusive.
There was the “fast” set—men who played high at the club, betted
on races in England (per wire); enjoyed big nights and bear fights,
and occasionally went down without settling their club account!
And even Mrs. Brande had a set—yes, positively her own little
circle for the first time in her life—and was a proud and happy
woman.
“It made a wonderful difference having a girl in the house,” she
remarked at least twice a day to “P.,” and “P.,” strange to say,
received the well-worn observation without a sarcastic rejoinder.
Certainly Honor had made a change at Rookwood. She had
prevailed on her aunt to allow her to cover the green rep drawing-
room suite with pretty cretonne, to banish the round table with its
circle of books dealt out like a pack of cards, to arrange flowers and
grasses in profusion, and to have tea in the verandah. Honor played
tennis capitally, and her uncle, instead of going to the club,
inaugurated sets at home, and these afternoons began to have quite
a reputation. There were good courts, good players—excellent
refreshments. Mrs. Brande’s strawberries and rich yellow cream
were renowned; and people were eager for standing invitations to
Rookwood “Tuesdays” and “Saturdays.” Besides Mr. Brande and his
niece—hosts in themselves—there were Sir Gloster, Mrs. Sladen,
the Padré and his wife, and young Jervis, who were regular
habitués. There were tournaments and prizes, and a briskness and
“go” about these functions that made them the most popular
entertainments in Shirani, and folk condescended to fish
industriously for what they would once have scorned, viz.:
—“invitations to Mother Brande’s afternoons.”
Captain Waring was tired of Shirani, though he had met many pals
—played polo three times a week, and whist six times, until the small
hours. Although invited out twice as much as any other bachelor, and
twice as popular as his cousin, indeed he and his cousin—as he
remarked with a roar of laughter—“were not in the same set.”
(Nor, for that matter, were Mrs. Langrishe and her niece in the
same set; for Lalla was “theatrical” and her aunt was “smart.”)
Captain Waring and his companion lived together in Haddon Hall,
with its world-wide reputation for smoking chimneys; but although
they resided under the same roof, they saw but little of one another.
Waring had the best rooms, an imposing staff of crest-emblazoned
servants. Jervis lived in two small apartments, and the chief of his
retinue was a respectable grey-bearded bearer, Jan Mahomed by
name, who looked cheap. Jervis spent most of his time taking long
walks or rides—shooting or sketching with some young fellows in the
Scorpions—or up at Rookwood, where he dined at least thrice a
week and spent all his Sundays, and where he had been warmly
received by Ben, and adopted into the family as his “uncle”! No
words, however many and eloquent, could more strongly indicate
how highly he stood in Mr. and Mrs. Brande’s good graces. To be
Ben’s “uncle” almost implied that they looked upon him as an
adopted son.
Frequently days elapsed, and Clarence and his companion
scarcely saw one another, save at polo. Mark kept early hours and
was up betimes—indeed, occasionally he was up and dressed ere
his cousin had gone to bed.
One afternoon, however, he found him evidently awaiting his
arrival, sitting in the verandah, and not as usual at the club card-
table.
“Hullo, Mark! what a gay young bird you are, always going out,
always on the wing—never at home!”
“The same to you,” said the other cheerily.
“Well, I just wanted to see you and catch you for a few minutes,
old chap. I’m getting beastly sick of this place—we have been here
nearly six weeks—I vote, as the policeman says, we ‘move on.’”
“Move where?” was the laconic inquiry.
“To Simla, to be sure! the club here is just a mere rowdy pot-
house. I never saw such rotten polo! My best pony is lame—gone in
the shoulder. I believe that little beggar Byng stuck me; and besides
this, Miss Potter—the girl with the black eyes and twelve hundred a
year—is going away.”
“To Simla?” expressively.
“Yes. She does not want to move, but the people she is with, the
Athertons, are off, and of course she is bound to go with them. That
girl likes me—she believes in me.”
“Do you think she believes that you are what they call you here, a
millionaire?”
“What a grossly coarse way of putting it! Well, I should not be
surprised if she did!”
“Then if that is the case, don’t you think the sooner you undeceive
her the better!”
“Excellent high-minded youth! But why?”
“Because it strikes me that we have played this little game long
enough.”
“And you languish for the good old board ship and Poonah days
over again! Shall we publish who is really who, in the papers, and
send a little ‘para’ to the Pioneer?” with angry sarcasm.
“No; but don’t you see that when I took what you called a ‘back
seat,’ I never supposed it would develop into a regular sort of society
fraud, or lead us on to such an extent. I’m always on the point of
blurting out something about money, and pulling myself up. If I speak
the truth people will swear I am lying. I don’t mind their thinking me
an insignificant, idle young ass; but when they talk before me of dire
poverty, and then pause apologetically—when they positively refrain
from asking me to subscribe to entertainments or charities—I tell you
I don’t like it. I am a rank impostor. There will be an awful explosion
some day, if we don’t look out.”
“A pleasant explosion for you. Surely you are not quite such a fool
as to suppose that any one would think the worse of you because
you are a rich man.”
Mark’s thoughts wandered to Honor Gordon, and he made no
answer.
“We have gone too far to go back,” continued Waring,
impressively, “at least as far as Shirani is concerned. We might shift
our sky and go to Simla, and then after a time allow the truth to ooze
out.”
“I am desperately sorry I ever tampered with the truth,” cried the
other, starting to his feet and beginning to walk about the verandah.
“I have never told a direct lie, and no one has ever suspected me—I
have not a rich air, nor the tastes of a wealthy man; now, you”—
suddenly halting before Clarence, and looking him all over—“have
both.”
“True, oh king! and people jumped at their own conclusions. Can
we help that? It has given me a ripping good time, and saved you a
lot of bother and annoyance. Why, the girl in the plaid waistcoat
would have married you months ago.”
“Not she! I’m not so easily married as all that!” rejoined the other
indignantly.
“I am much relieved to hear it. I am glad you remember Uncle
Dan’s instructions. I was afraid they were beginning to slip out of
your head, and bearing them in mind, I think the sooner, for all
parties, that you clear out of Shirani the better.”
“I am not going to budge,” said Jervis resolutely; “and you know
the reason.”
Waring blew away a mouthful of smoke, and then drawled out
—“Of course—Miss Gordon.”
“No; my father,” reddening like a girl. “You know he lives within
forty miles of this, and that was what made me so keen to come to
Shirani.”
“Yes, I understand perfectly; and so keen to stay!”
“I wrote to him,” ignoring this innuendo, “and said I would wait on
here till October, hoping to see him.”
“You’ll never see him,” now bringing a volume of smoke down his
nostrils.
“Time will tell—I hope I shall.”
“And time stands still for no man! The Athertons and Miss Potter
start in ten days, and I shall accompany them; there is nothing like
travelling with a young lady for advancing one’s interests—as you
know, my boy. Now, don’t be angry. Yes, I’m off. I’m not heir to a
millionaire, and I must consult my interests. If you will take my
advice, you will join the little party.”
“No, thank you; I shall stay here.”
“Do you mean to say that you will stick to this dead-and-alive place
for the next four months?”
“I do—at any rate till my father sends for me”—and he paused for
a second—“or until the end of the season.”
“In fact, in plain English, until the Brandes go down,” repeated
Clarence significantly; and rising, and tossing away the end of his
cigarette, he strolled over to the adjacent mess.
CHAPTER XX.
MISS PASKE DEFIES HER AUNT.