Professional Documents
Culture Documents
Java
Java
Codesamples
Examplets from The Java Developers Almanac 2000
Table of Contents
Accessibility (javax.accessibility)
Arrays (java.lang)
Applets (java.applet)
Application and System (java.lang)
(java.awt)
AWT (Abstract Windowing Toolkit)
(java.awt.datatransfer)
Clipboard (java.awt.dnd)
Drag and Drop (java.awt.event)
Events (java.awt.font)
Fonts (java.awt.geom)
Shapes (java.util.zip)
Compression (java.util.jar)
JAR files (java.sql)
(java.util)
Database - JDBC
(java.io)
Data Structures and Algorithms (java.awt.image)
Files, Streams, I/O (java.text)
Images (java.beans)
Internationization (javax.naming)
JavaBeans TM (javax.naming.directory)
JNDI (javax.naming.event)
Directory (javax.naming.ldap)
(java.math)
Event
(java.net)
Ldap (java.awt.print)
Math (java.lang.ref)
Networking (java.lang.reflect)
Printing (java.rmi)
Reference Objects (java.security)
Reflection
RMI (javax.sound.sampled)
(javax.sound.midi)
Security
(java.lang)
Sound (javax.swing)
Sampled (javax.swing.event)
Midi (javax.swing.filechooser)
Strings (java.awt and javax.swing)
Swing (javax.swing.tree)
Events (javax.swing.text)
File Chooser (java.lang)
(java.lang)
Layout
(javax.naming)
Tree (javax.naming.directory)
Text (javax.naming.event)
Threads (javax.naming.ldap)
Time (javax.rmi)
javax.rmi (javax.swing.undo)
javax.swing.undo
Accessibility (javax.accessibility)
The Quintessential Accessible Object
Setting an Accessible Name for an Image Button
Setting a Description for Image Icons
Setting a Mnemomic for Buttons
Setting a Mnemonic for a Menu
Associating a Label with a Component
Setting a Keyboard Accelerator for a Menu Item
Applets (java.applet)
The Quintessential Applet
Getting an Applet Parameter
Making the Browser Visit a URL
Showing a Message in the Browser's Status Bar
Loading and Playing Audio in an Applet
Loading and Playing Audio in an Application
Loading and Painting an Image in an Applet
Animating an Array of Images in an Applet
AWT (Abstract Windowing Toolkit) (java.awt)
The Quintessential Drawing Program
Drawing Basic Shapes
Filling Basic Shapes
Loading an Image
Drawing an Image
Scaling, Shearing, Translating, and Rotating a Drawn
Image
Drawing Simple Text
Drawing Rotated Text
Getting the Dimensions of Text
Drawing Anti-Aliased Text and Graphics
Drawing with Alpha
Setting the Clipping Area with a Shape
Changing the Thickness of the Stroking Pen
Creating a Shape from a Stroked Shape
Stroking or Filling a Shape
Stroking or Filling with a Color
Stroking or Filling with a Gradient Color
Stroking or Filling with a Texture
Animating an Array of Images in an Application
Connecting to a Database
Creating a Database Table
Entering a New Row into a Database Table
Getting All Rows from a Database Table
Getting Particular Rows from a Database Table
Updating a Row of Data in a Database Table
Using a Prepared SQL Statement
Data Structures and Algorithms (java.util)
Creating a Set
Creating a List
Creating a Hash Table
Truncating a List
Converting a Collection to an Array
Converting an Array to a Collection
Implementing a Queue
Implementing a Stack
Iterating the Elements of a Collection
Sorting an Array
Finding an Element in a Sorted Array
Finding an Element in a Sorted List
Inserting an Element into a Sorted List
Generating a Random Number
Breaking a String into Words
Reading Properties from a Properties File
Creating Date Object From a Particular Date
Parsing a Date Using a Pattern
Reading and Writing a Properties File
Getting and Setting Properties
Scheduling a Timer Task to Run at a Certain Time
Scheduling a Timer Task to Run Repeatedly
Files, Streams, I/O (java.io)
Constructing a Path
Reading Text from Standard Input
Reading Text from a File
Writing to a File
Creating a Directory
Appending to a File
Deleting a File
Deleting a Directory
Creating a Temporary File
Using a Random Access File
Listing the File System Roots
Setting File Modification Time
Serializing an Object
Deserializing an Object
Traversing a Directory
Reading UTF-8 Encoded Data
Writing UTF-8 Encoded Data
Reading ISO Latin-1 Encoded Data
Writing ISO Latin-1 Encoded Data
Images (java.awt.image)
Converting an Image to a Buffered Image
Getting Pixels from a Buffered Image
Getting a Sub-Image of an Image
Creating and Drawing on a Buffered Image
Scaling, Shearing, Translating, and Rotating an Image
Converting a Color Image to Gray
Blurring an Image
Sharpening an Image
Embossing an Image
Internationization (java.text)
Formatting and Parsing a Locale-specific Number
Formatting and Parsing Locale-specific Currency
Formatting and Parsing a Locale-specific Percentage
Formatting and Parsing a Locale-specific Date
Formatting and Parsing Locale-specific Time
Formatting and Parsing a Locale-specific Date and Time
Determining the Type of a Character
Comparing Strings in a Locale-independent Way
Determining the Character Boundaries in a Unicode String
Determining the Word Boundaries in a Unicode String
Determining the Sentence Boundaries in a Unicode String
Reflection (java.lang.reflect)
Getting a Class Object
Getting the Modifiers of a Class Object
Getting the Interfaces of a Class Object
Getting the Methods of a Class Object
Getting a Constructor of a Class Object
Creating an Object Using a Constructor Object
Getting the Field Objects of a Class Object
Getting and Setting the Value of a Field
Invoking a Method Using a Method Object
Getting the Modifiers of a Member Object
Getting the Name of a Class or Member Object
Determining if an Object Is an Array
Determining the Dimensions of an Array
Getting the Component Type of an Array
Creating an Array
Expanding an Array
Getting and Setting the Value of an Element in an Array
Overriding Default Access
Creating a Proxy Object
RMI (java.rmi)
Starting Up the RMI Registry
Defining and Exporting a Remote Object
Looking Up a Remote Object and Invoking a Method
Passing Parameters to a Remote Method
Returning Values from a Remote Method
Throwing an Exception from a Remote Method
Sound
Sampled (javax.sound.sampled)
Loading and Playing Sampled Audio
Determining the File Format of a Sampled Audio File
Determining the Encoding of a Sampled Audio File
Determining the Duration of a Sampled Audio File
Playing Streaming Sampled Audio
Continuously Playing a Sampled Audio File
Determining the Position of a Sampled Audio Player
Determining When a Sampled Audio Player has
Finished Playing
Controlling the Volume of Playing Sampled Audio
Midi
Creating a Slider
Creating a Split Pane
Creating a Tabbed Pane
Creating a Text Field
Creating a Password Text Field
Creating a Table
Creating a Text Area
Displaying Simple HTML Files
Creating a Toolbar
Creating a Borderless Window
Showing a Dialog Box
Creating Key Strokes and Binding Them to Actions
Adding an InputMap to a Component
Setting a Tool Tip
Laying Out Components in a Row or Column
Separating Components in a Row or Column
Laying Out Components in a Flow (Left-to-Right,
Top-to-Bottom)
Laying Out Components in a Grid
Laying Out Components Using Absolute Coordinates
Setting a Border
Adding a Title to a Border
Creating a Compound Border
Determining the Available Look and Feels
Setting the Look and Feel
Painting the Background of a Container with an Image
Pattern
Events (javax.swing.event)
Handling Hyperlink Events
Handling Changes to a List Component
File Chooser (javax.swing.filechooser)
Adding a Filter to a File Chooser Dialog
Tree (javax.swing.tree)
Creating a Tree
Handling Selection Events in a Tree Component
Text (javax.swing.text)
Inserting Styled Text in a Text Pane
Inserting an Image into a Text Pane
Inserting a Component into a Text Pane
java.lang
The Quintessential Java Application
Exiting a Java Program
The Quintessential Thread
Making an Object Cloneable
Constructing a String
Getting a Substring from a String
Searching a String
Replacing Characters in a String
Replacing Substrings in a String
Converting a String to Upper or Lower Case
Converting a String to a Number
Shifting Elements in an Array
Copying Elements from One Array to Another
Retrieving the SuperClass of an Object
Getting the Package of an Object
Implementing a Work Queue
Executes a Command
Reading Output from a Command
Sending Input to a Command
Pausing
Getting the Current Time
Getting the Value of a System Property
Setting the Value of a System Property
Using a Thread-local Variable
Loading Native Code
Converting Unicode to UTF-8
Converting UTF-8 to Unicode
Determining a Character's Unicode Block
JNDI
Creating an Initial Context to the Naming Service
Looking Up an Object From the Naming Service
Listing a Context in the Naming Service
Adding, Replacing, Removing, and Renaming a Binding in
the Naming Service
Creating and Destroying a Subcontext in the Naming
Service
Getting an Object's Fully Qualified Name
Using a URL as a Name to the Initial Context
Parsing a Composite Name
Parsing a Compound Name
Directory (javax.naming.directory)
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
Welcome to the
Java Developer
ConnectionSM! A User ID Password
JavaTM
technologies.
Developer
Edition Intrigued by the Java 2D art
Resources applet last month? This article tells
Early Access the story behind the applet, with lots
Downloads of code and screenshots of Forte CE
Bug Database
in action, and use of the Swing Timer
class. (July 21, 2000)
Bug Submission
Technical Support AWT Fundamentals Short Course The
Human Interface Design
latest Abstract Window Toolkit (AWT)
tutorial! Learn how to build graphical
user interfaces, display Java widgets
Hot! from the JDC
and make them respond to physical
Tutorials
events, and how to create windows
Technical Articles and menus for standalone
Bookshelf applications. (July 17, 2000)
Early Access Downloads
Tech Tips Tech Tips: Read about using
Newsletters Shutdown hooks to gain control when
Quizzes shutting down applications, and how
Java Forums to automate GUI programs with
java.awt.Robot. (July 11, 2000)
Programming Centers J2EETM Deployathon Online! See this
New-to-Java online demonstration of application
Programming Center portability across various
Applets J2EE-compliant servers. You'll find
Code Samples that with J2EE's portability features,
there's little or no need to rewrite
Technology Centers code for different servers. J2SE v 1.3 Refreshed for
Java 2 Platform (July 10, 2000) Solaris and Linux (July 10, 00)
Standard Edition Java 3DTM 1.2 Beta API for
JDC BOOKSHELF LATEST
Enterprise Edition Direct3D
(July 05, 00)
Micro Edition Professional JSP Two chapters from
K Virtual Machine this popular new book, one covering Java Naming and Directory
JSP Architecture, and the other giving InterfaceTM(JNDI) DNS Service
Jini Technology
a case study using J2EETM, EJBsTM and Provider 1.2
XML (June 28, 00)
Tag Libraries. (July 26, 2000)
Consumer & Embedded JavaTM Web Start 0.4
LDAP Programming with Java TM Two
(June 06, 00)
Get the Connection chapters covering how to use LDAP
with Java and JavaBeansTM Java Embedded ServerTM 2.0
Java Platform
technologies. (July 05, 2000) Early Access (June 06, 00)
C & E Technologies
Jini Connection Core Servlets and JavaServer PagesTM JavaTM Accessibility Helper 1.0
(June 05, 00)
Beans Connection Two chapters from this practical guide
to using the Java Platform for More...
Swing Connection
web-enabled applications and
XML Developer dynamic web sites. Chapters cover:
Connection generating the server response, and
Solaris Developer defining your own tags. (June 02, 00)
Connection Notable Contributions
More. . .
Sun Developer JavaWorld
Connection
Java Q & A
Developer Programs Discover the Secrets of the
TALKING ABOUT JAVA
Developer Certification JavaTM Serialization API
Sun Training Programs Java Live! Chat with experts on a (July 28, 00)
Test Infect Your Enterprise
Source Code Licensing variety of hot topics in the JavaTM JavaBeansTM
Enterprise programming language. These (July 06, 00)
Infrastructure sessions are held on Tuesdays (unless Develop WAP Applications with
and Software otherwise noted) at 11:00 a.m. Servlets and JavaServer
Development PST/7:00 p.m. GMT. PagesTM
(June 27, 00)
Developer News Next session:
Java Technology User's August 1 - What's New for AWT in jGuru
Groups JDKTM 1.3? Version 1.3 of the jGuru FAQ
JavaTM 2 SDK includes a number of
interesting enhancements to the Gamelan
Reader's Poll Abstract Window Toolkit (AWT). Ask the Experts
Tell us about your For example, it adds a new Robot
needs for JDBCTM and class for automating user input and
J2EETM technologies in
this special survey.
mouse movements. Find out more
about AWT enhancements from
Sun engineer Richard Ray.
Future sessions:
business-to-business relationships
with Sun Consumer & Embedded
constituents and vendors.
New Java Series books are now
available. This is the authorized series
of books on the Java 2 Platform and
APIs, directly from the creators of
Java technology. Order the series
online now.
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
Documentation
and Training
Popular Picks
Optional Packages
General Documentation
Java History
Back to Top
Tech Tips
Newsletters
JDC Bookshelf
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
Online Support
Use the self-help options on this page to find the answers to your
technical problems. As a member of the Java Developer
ConnectionSM (JDC) you have access to areas restricted ( ) to
members only. If you want to give feedback on our products and
APIs, contact us.
Search
Discussion Forums
Need a quick answer to a technical problem? Join a discussion
forum or create your own forum, where you can post a
question and get expert advice from the developer
community. See the Forums page for active forums and
complete information. Join a forum today.
HotDispatch Marketplace for Java(tm) Technology
Support
Put your question on the HotDispatch Marketplace for
Java(tm) Technology Support, and specify the price you're
willing to pay for an answer. This third-party program is a
pay-per incident forum powered by HotDispatch, Inc. The
3. Report a Problem
5. Contact Us
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
Community Discussion
Welcome to the JavaTM Community. Here you can join ongoing
forums on a variety of Java topics, chat with Java experts, access
community resources, and more.
FORUMS
Future sessions:
Aug. 8. Core Servlets and JavaServer PagesTM Technology
Aug. 15. Accessibility Support in the JavaTM 2 Platform
Aug. 22. J2SETM v1.3 Security Features
See transcripts of recently held sessions.
Other Chats
Use the ChatClient applet to join chats started by others, or to start
your own.
RELATED LINKS
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.accessibility
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
import javax.accessibility.*;
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.accessibility
Code Samples Index
These code examples and other materials are subject to Sun Microsystems, Inc.
Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.accessibility
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.accessibility
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.accessibility
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.accessibility
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.accessibility
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.applet
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
import java.applet.*;
import java.awt.*;
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.applet
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
String s = getParameter("p");
Here is a sample HTML file containing a value for the parameter
\meta{p}.
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.applet
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.applet
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.applet
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.applet
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
URL url = new URL("http://hostname/audio.au");
AudioClip ac = Applet.newAudioClip(url);
ac.play();
} catch (MalformedURLException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.applet
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Image image;
public void init() {
image = getImage(getDocumentBase(),
"http://hostname/image.gif");
}
public void paint(Graphics g) {
g.drawImage(image, 0, 0, this);
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.applet
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
import java.applet.*;
import java.awt.*;
images[1] = getImage(getDocumentBase(),
"http://hostname/image1.gif");
}
public void start() {
(thread = new Thread(this)).start();
}
public void stop() {
thread = null;
}
public void paint(Graphics g) {
g.drawImage(images[frame], 0, 0, this);
}
public void run() {
int delay = 1000; // 1 second
try {
while (thread == Thread.currentThread()) {
frame = (frame+1)%images.length;
repaint();
Thread.sleep(delay);
}
} catch (Exception e) {
}
}
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
import java.awt.*;
import javax.swing.*;
g2d.drawOval(0, 0, getSize().width-1,
getSize().height-1);
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Loading an Image
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Drawing an Image
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Text only
g2d.setRenderingHint(
RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
drawGraphics(g2d);
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
drawGraphic1(g2d);
drawGraphic2(g2d);
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
g2d.setClip(shape);
drawGraphics(g2d);
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// A solid stroke
BasicStroke stroke = new BasicStroke(strokeThickness);
g2d.setStroke(stroke);
drawShape(g2d);
// A dashed stroke
float miterLimit = 10f;
float[] dashPattern = {10f};
float dashPhase = 5f;
stroke = new BasicStroke(
strokeThickness, BasicStroke.CAP_BUTT,
BasicStroke.JOIN_MITER, miterLimit,
dashPattern, dashPhase);
g2d.setStroke(stroke);
drawShape(g2d);
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// A non-cyclic gradient
GradientPaint gradient = new GradientPaint(
startX, startY, startColor,
endX, endY, endColor);
g2d.setPaint(gradient);
drawShape(g2d);
// A cyclic gradient
gradient = new GradientPaint(
startX, startY, startColor,
endX, endY, endColor, true);
g2d.setPaint(gradient);
drawShape(g2d);
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
import java.awt.*;
import javax.swing.*;
try {
while (true) {
frame = (frame+1)%images.length;
repaint();
Thread.sleep(delay);
}
} catch (Exception e) {
}
}
(new Thread(app)).start();
}
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
component.setCursor(Cursor.getPredefinedCursor(
Cursor.HAND_CURSOR));
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.datatransfer
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Transferable t =
Toolkit.getDefaultToolkit().getSystemClipboard().
getContents(null);
try {
if (t != null && t.isDataFlavorSupported(
DataFlavor.stringFlavor)) {
String s = (String)t.getTransferData(
DataFlavor.stringFlavor);
process(s);
}
} catch (UnsupportedFlavorException e) {
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.datatransfer
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
StringSelection ss =
new StringSelection("aString");
Toolkit.getDefaultToolkit().getSystemClipboard().
setContents(ss, null);
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.dnd
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
public DraggableComponent() {
dragSource = new DragSource();
dragSource.createDefaultDragGestureRecognizer(
this, DnDConstants.ACTION_COPY_OR_MOVE, this);
}
public void dragGestureRecognized(
DragGestureEvent evt) {
Transferable t = new StringSelection(
"aString");
dragSource.startDrag (
evt, DragSource.DefaultCopyDrop, t, this);
}
public void dragEnter(DragSourceDragEvent evt) {
// Called when the user is dragging this drag
// source and enters the drop target.
}
public void dragOver(DragSourceDragEvent evt) {
// Called when the user is dragging this drag
// source and moves over the drop target.
}
public void dragExit(DragSourceEvent evt) {
// Called when the user is dragging this drag
// source and leaves the drop target.
}
public void dropActionChanged(
DragSourceDragEvent evt) {
// Called when the user changes the drag
// action between copy or move.
}
public void dragDropEnd(DragSourceDropEvent evt) {
// Called when the user finishes or cancels
// the drag operation.
}
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.dnd
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.dnd
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
if (t.isDataFlavorSupported(
DataFlavor.stringFlavor)) {
evt.acceptDrop(
DnDConstants.ACTION_COPY_OR_MOVE);
String s = (String)t.getTransferData(
DataFlavor.stringFlavor);
evt.getDropTargetContext().dropComplete(true);
process(s);
} else {
evt.rejectDrop();
}
} catch (IOException e) {
evt.rejectDrop();
} catch (UnsupportedFlavorException e) {
evt.rejectDrop();
}
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
java.awt.event
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
component.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent evt) {
}
});
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.event
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.event
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
component.addKeyListener(new MyKeyListener());
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.event
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
component.addMouseListener(new MyMouseListener());
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.event
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
component.addMouseMotionListener(
new MyMouseMotionListener());
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.event
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
component.addMouseListener(new MyMouseListener());
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.event
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
component.addFocusListener(new MyFocusListener());
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.font
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
String fontNames[] = ge.getAvailableFontFamilyNames();
for (int i=0; i<fontNames.length; i++) {
process(fontNames[i]);
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.font
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
float y = 0.0f;
while (linebreaker.getPosition() <
paragraph.length()) {
TextLayout tl =
linebreaker.nextLayout(width);
y += tl.getAscent();
tl.draw(g, 0, y);
y += tl.getDescent() + tl.getLeading();
}
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
java.awt.font
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Shape getTextShape(
Graphics2D g2d, String str, Font font) {
TextLayout tl = new TextLayout(
str, font, g2d.getFontRenderContext());
return tl.getOutline(null);
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.font
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.geom
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.geom
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.geom
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Combining Shapes
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.geom
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util.zip
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Compressing a File
This example creates a ZIP file with one entry.
try {
String inFilename = "infile";
String outFilename = "outfile.zip";
FileInputStream in = new FileInputStream(
inFilename);
ZipOutputStream out = new ZipOutputStream(
new FileOutputStream(outFilename));
out.closeEntry();
out.close();
in.close();
} catch (IOException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util.zip
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Decompressing a File
This example reads a ZIP file and decompresses the first entry.
try {
String inFilename = "infile.zip";
String outFilename = "outfile";
ZipInputStream in = new ZipInputStream(
new FileInputStream(inFilename));
OutputStream out = new FileOutputStream(
outFilename);
ZipEntry entry;
byte[] buf = new byte[1024];
int len;
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
java.util.zip
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
ZipFile zf = new ZipFile(filename);
} catch (IOException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util.zip
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util.jar
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
JarFile jarfile = new JarFile(filename);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.sql
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Connecting to a Database
This example uses the JDBC-ODBC bridge to connect to a database
called ``mydatabase''.
try {
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.sql
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
Statement stmt =
connection.createStatement();
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.sql
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
Statement stmt = connection.createStatement();
stmt.executeUpdate("INSERT INTO mytable
VALUES ('Patrick Chan', 123, 1.23)");
connection.close();
} catch (SQLException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.sql
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
Statement stmt = connection.createStatement();
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.sql
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
Statement stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery(
"SELECT * FROM mytable WHERE COL_A =
'Patrick Chan'");
rs.next();
String s = rs.getString("COL_A");
int i = rs.getInt("COL_B");
float f = rs.getFloat("COL_C");
process(s, i, f);
} catch (SQLException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.sql
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
Statement stmt = connection.createStatement();
int numUpdated = stmt.executeUpdate(
"UPDATE mytable SET COL_A =
'John Doe' WHERE COL_B = 123");
connection.close();
} catch (SQLException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.sql
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Retrieving rows from the database.
PreparedStatement stmt =
connection.prepareStatement(
"SELECT * FROM mytable WHERE COL_A = ?");
int colunm = 1;
stmt.setString(colunm, "Patrick Chan");
ResultSet rs = stmt.executeQuery();
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Creating a Set
// Some operations.
set.add(value);
boolean b = set.contains(value);
set.remove(value);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Creating a List
// doubly-linked list
List list = new LinkedList();
// list implemented as growable array
list = new ArrayList();
// Some operations.
list.add(value);
list.get(0);
list.remove(value);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Some operations.
map.put(key, value);
value = map.get(key);
map.remove(key);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Truncating a List
list.subList(index, list.size()).clear();
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
objectArray = set.toArray();
array = (AnObject[])set.toArray(
new AnObject[set.size()]);
objectArray = map.keySet().toArray();
array = (AnObject[])map.keySet().toArray(
new AnObject[set.size()]);
objectArray = map.values().toArray();
array = (AnObject[])map.values().toArray(
new AnObject[set.size()]);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Ungrowable list.
List list = Arrays.asList(array);
// Growable list.
list = new LinkedList(Arrays.asList(array));
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Implementing a Queue
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Implementing a Stack
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Sorting an Array
// Case-insensitive sort.
Arrays.sort(strArray,
String.CASE_INSENSITIVE_ORDER);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
if (index < 0) {
// not found
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
if (index < 0) {
// not found
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
if (index < 0) {
sortedList.add(-index-1, object);
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
while (parser.hasMoreTokens()) {
processWord(parser.nextToken());
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
ResourceBundle bundle =
ResourceBundle.getBundle("basename");
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
SimpleDateFormat formatter =
new SimpleDateFormat("EEEE, MMMM dd, yyyy");
Date d = formatter.parse(
"Tuesday, January 03, 1956");
d = formatter.parse("Tue, 01 3, 56");
process(d);
} catch (ParseException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
properties.store(new FileOutputStream(
"outfilename"), null);
} catch (IOException e) {
}
# a comment
! a comment
a = a string
b = a string with escape sequences \t
\n \r \\ \" \' \ (space) \u0123
c = a string with a continuation line \
contination line
d.e.f = another string
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Date timeToRun =
new Date(System.currentTimeMillis()+
numberOfMillisecondsInTheFuture);
Timer timer = new Timer();
timer.schedule(new TimerTask() {
public void run() {
// Task here
}
}, timeToRun);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.util
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
timer.scheduleAtFixedRate(new TimerTask() {
public void run() {
// Task here
}
}, delay, period);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Constructing a Path
On Windows, this example creates the path \blash a\blash b. On
Unix, the path would be /a/b.
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
String str = "";
while (str != null) {
System.out.print("> prompt ");
str = in.readLine();
process(str);
}
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
BufferedReader in = new BufferedReader(
new FileReader("infilename"));
String str;
while ((str = in.readLine()) != null) {
process(str);
}
in.close();
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Writing to a File
If the file does not already exist, it is automatically created.
try {
BufferedWriter out = new BufferedWriter(
new FileWriter("outfilename"));
out.write("aString");
out.close();
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Creating a Directory
(new File("directoryName")).mkdir();
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Appending to a File
try {
BufferedWriter out = new BufferedWriter(
new FileWriter("filename", true));
out.write("aString");
out.close();
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Deleting a File
(new File("filename")).delete();
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Deleting a Directory
(new File("directoryName")).delete();
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Create temp file.
File temp = File.createTempFile(
"pattern", ".suffix");
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
File f = new File("filename");
RandomAccessFile raf = new RandomAccessFile(f, "rw");
// Read a character.
char ch = raf.readChar();
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Serializing an Object
The object to be serialized must implement java.io.Serializable.
try {
ObjectOutput out = new ObjectOutputStream(
new FileOutputStream("filename.ser"));
out.writeObject(object);
out.close();
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Deserializing an Object
This example deserializes a java.awt.Button object.
try {
ObjectInputStream in = new ObjectInputStream(
new FileInputStream("filename.ser"));
AnObject object = (AnObject) in.readObject();
in.close();
} catch (ClassNotFoundException e) {
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Traversing a Directory
if (f.isDirectory()) {
String[] children = f.list();
for (int i=0; i<children.length; i++) {
traverse(new File(f, children[i]));
}
}
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
BufferedReader in = new BufferedReader(
new InputStreamReader(
new FileInputStream(
"infilename"), "UTF8"));
String str = in.readLine();
} catch (UnsupportedEncodingException e) {
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
Writer out = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(
"outfilename"), "UTF8"));
out.write(aString);
out.close();
} catch (UnsupportedEncodingException e) {
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
BufferedReader in = new BufferedReader(
new InputStreamReader(new FileInputStream(
"infilename"), "8859_1"));
String str = in.readLine();
} catch (UnsupportedEncodingException e) {
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.io
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
Writer out = new BufferedWriter(
new OutputStreamWriter(new FileOutputStream(
"outfilename"), "8859_1"));
out.write(aString);
out.close();
} catch (UnsupportedEncodingException e) {
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.image
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
return bufferedImage;
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
java.awt.image
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Set a pixel.
rgb = 0xFF00FF00; // green
bufferedImage.setRGB(x, y, rgb);
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.image
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// From an Image.
image = createImage(new FilteredImageSource(
image.getSource(), new CropImageFilter(x, y, w, h)));
// From a BufferedImage.
bufferedImage = bufferedImage.getSubimage(x, y, w, h);
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.image
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.image
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.image
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
ColorSpace cs = ColorSpace.getInstance(
ColorSpace.CS_GRAY);
ColorConvertOp op = new ColorConvertOp(cs, null);
bufferedImage = op.filter(bufferedImage, null);
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.image
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Blurring an Image
This example demonstrates a 3x3 kernel that blurs an image.
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.image
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Sharpening an Image
This example demonstrates a 3x3 kernel that sharpens an image.
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.image
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Embossing an Image
This example demonstrates a 3x3 kernel that embosses an image.
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.text
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Format
Locale locale = Locale.CANADA;
String string = NumberFormat.getNumberInstance(
locale).format(123.45);
// Parse
try {
Number number = NumberFormat.getNumberInstance(
locale).parse("123.45");
if (number instanceof Long) {
// Long value
} else {
// Double value
}
} catch (ParseException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.text
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Format
Locale locale = Locale.CANADA;
String string = NumberFormat.getCurrencyInstance(
locale).format(123.45);
// Parse
try {
Number number =
NumberFormat.getCurrencyInstance(
locale).parse("$123.45");
if (number instanceof Long) {
// Long value
} else {
// Double value
}
} catch (ParseException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.text
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Format
Locale locale = Locale.CANADA;
String string = NumberFormat.getPercentInstance(
locale).format(123.45);
// Parse
try {
Number number = NumberFormat.getPercentInstance(
locale).parse("123.45%");
if (number instanceof Long) {
// Long value
} else {
// Double value
}
} catch (ParseException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.text
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Format
Locale locale = Locale.FRENCH;
Date date = new Date();
String string = DateFormat.getDateInstance(
DateFormat.DEFAULT, locale).format(date);
// Parse
try {
//The next three lines should be in one line.
date = DateFormat.getDateInstance(
DateFormat.DEFAULT, locale).parse(
"15 nov. 98");
} catch (ParseException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.text
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Format
Locale locale = Locale.FRENCH;
Date date = new Date();
String string = DateFormat.getTimeInstance(
DateFormat.DEFAULT, locale).format(date);
// Parse
try {
date = DateFormat.getTimeInstance(
DateFormat.DEFAULT, locale).parse("01:37:11");
} catch (ParseException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.text
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Format
Locale locale = Locale.ITALIAN;
Date date = new Date();
String string = DateFormat.getDateTimeInstance(
DateFormat.DEFAULT,
DateFormat.DEFAULT, locale).format(date);
// Parse
try {
date = DateFormat.getDateTimeInstance(
DateFormat.DEFAULT,
DateFormat.DEFAULT, locale).parse(
"15-nov-98 1.45.12");
} catch (ParseException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.text
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
char ch = 'a';
if (Character.isLetter(ch)) {
} else if (Character.isDigit(ch)) {
} else if (Character.isLowerCase(ch)) {
} else if (Character.isUpperCase(ch)) {
}
// See Character for more methods.
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.text
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
if (compare < 0) {
// aString1 < aString2
} else if (compare > 1) {
// aString1 > aString2
} else {
// aString1 = aString2
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.text
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
BreakIterator iterator =
BreakIterator.getCharacterInstance(Locale.CANADA);
iterator.setText("aString");
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.text
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
BreakIterator iterator =
BreakIterator.getWordInstance(Locale.CANADA);
iterator.setText("a sentence");
index=iterator.next()) {
process(index);
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.text
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
BreakIterator iterator =
BreakIterator.getSentenceInstance(Locale.CANADA);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.text
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
BreakIterator iterator =
BreakIterator.getLineInstance(Locale.CANADA);
iterator.setText("line1\nline2");
process(index);
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.beans
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
import java.io.Serializable;
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
java.beans
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
int property;
public int getProperty() {
return property;
}
public void setProperty(
int newValue) {
property = newValue;
pceListeners.firePropertyChange(
"property"
,new Integer(property),
new Integer(newValue));
}
}
public synchronized void removePropertyChangeListener(
PropertyChangeListener listener) {
pceListeners.removePropertyChangeListener(
listener);
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.beans
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
int property;
public int getProperty() {
return property;
}
public void setProperty(int newValue) throws
PropertyVetoException {
try {
vceListeners.fireVetoableChange(
"property",
new Integer(property),
new Integer(newValue));
property = newValue;
} catch (PropertyVetoException e) {
throw e;
}
}
VetoableChangeListener
listener) {
vceListeners.removeVetoableChangeListener(
listener);
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.beans
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Instantiating a Bean
try {
MyBean bean = (MyBean)Beans.instantiate(
ClassLoader.getSystemClassLoader(), "MyBean");
} catch (ClassNotFoundException e) {
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.beans
Code Samples Index
These code examples and other materials are subject to Sun Microsystems, Inc.
Legal Terms
bean.addPropertyChangeListener(
new MyPropertyChangeListener());
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.beans
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
bean.addVetoableChangeListener(
new MyVetoableChangeListener());
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.math
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
bi1 = bi1.add(bi2);
bi1 = bi1.multiply(bi2);
bi1 = bi1.subtract(bi2);
bi1 = bi1.divide(bi2);
bi1 = bi1.negate();
int exponent = 2;
bi1 = bi1.pow(exponent);
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.math
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
bd1 = bd1.add(bd2);
bd1 = bd1.multiply(bd2);
bd1 = bd1.subtract(bd2);
bd1 = bd1.divide(bd2, BigDecimal.ROUND_UP);
bd1 = bd1.negate();
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.math
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
int decimalPlaces = 2;
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.net
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Creating a URL
try {
// With components.
URL url = new URL("http", "hostname", 80,
"index.html");
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.net
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Parsing a URL
try {
URL url = new URL(
"http://hostname:80/index.html#_top_");
String protocol = url.getProtocol(); // http
String host = url.getHost(); // hostname
int port = url.getPort(); // 80
String file = url.getFile(); // index.html
String ref = url.getRef(); // _top_
} catch (MalformedURLException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.net
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
URL url = new URL(
"http://hostname:80/index.html");
BufferedReader in = new BufferedReader(
new InputStreamReader(url.openStream()));
String str;
while ((str = in.readLine()) != null) {
process(str);
}
in.close();
} catch (MalformedURLException e) {
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.net
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Construct data.
String line = URLEncoder.encode("key1")
+ "=" + URLEncoder.encode("value1");
line += &" + URLEncoder.encode("key2")
+ "=" + URLEncoder.encode("value2");
// Send data.
URL url = new URL("http://hostname:80/cgi");
URLConnection conn = url.openConnection();
conn.setDoOutput(true);
OutputStreamWriter wr = new OutputStreamWriter(
conn.getOutputStream());
wr.write(line);
wr.flush();
wr.close();
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.net
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Resolving a Hostname
try {
InetAddress addr = InetAddress.getByName(
"java.sun.com");
} catch (UnknownHostException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.net
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
InetAddress addr = InetAddress.getByName(
"java.sun.com");
int port = 80;
Socket sock = new Socket(addr, port);
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.net
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
int port = 2000;
ServerSocket srv = new ServerSocket(port);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.net
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
BufferedReader rd = new BufferedReader(
new InputStreamReader(socket.getInputStream()));
String str;
while ((str = rd.readLine()) != null) {
process(str);
}
rd.close();
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.net
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
BufferedWriter wr = new BufferedWriter(
new OutputStreamWriter(socket.getOutputStream()));
wr.write("aString");
wr.flush();
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.net
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Sending a Datagram
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.net
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Receiving a Datagram
try {
byte[] inbuf = new byte[256]; // default size
DatagramSocket socket = new DatagramSocket();
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.net
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.net
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.net
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.print
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
import java.awt.*;
import java.awt.print.*;
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.print
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.print
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
if (portrait) {
pf.setOrientation(PageFormat.PORTRAIT);
} else {
pf.setOrientation(PageFormat.LANDSCAPE);
}
pjob.setPrintable(printable, pf);
try {
pjob.print();
} catch (PrinterException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.print
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// First part.
PageFormat landscape = pjob.defaultPage();
landscape.setOrientation(PageFormat.LANDSCAPE);
book.append(new Printable1(), landscape);
// Second part.
PageFormat portrait = pjob.defaultPage();
portrait.setOrientation(PageFormat.PORTRAIT);
book.append(new Printable2(), portrait, 5);
pjob.setPageable(book);
try {
pjob.print();
} catch (PrinterException e) {
}
}
static class Printable1 implements Printable {
public int print(Graphics g, PageFormat pf,
int pageIndex) {
drawGraphics(g, pf);
return Printable.PAGE_EXISTS;
}
}
static class Printable2 implements Printable {
public int print(Graphics g, PageFormat pf,
int pageIndex) {
drawGraphics(g, pf);
return Printable.PAGE_EXISTS;
}
}
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.print
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.awt.print
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.ref
Code Samples Index
These code examples and other materials are subject to Sun Microsystems, Inc.
Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.ref
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.ref
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// By way of an object.
Class cls = object.getClass();
// By way of a string
try {
cls = Class.forName("java.lang.String");
} catch (ClassNotFoundException e) {
}
// By way of .class
cls = java.lang.String.class;
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems, Inc.
Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
java.awt.Point obj = (
java.awt.Point)con.newInstance(
new Object[]{new Integer(123), new Integer(123)});
} catch (InstantiationException e) {
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Get value
field.getInt(object);
// Set value
field.setInt(object, 123);
} catch (IllegalAccessException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
Object result = method.invoke(
object, new Object[] {param1, param2, ..., paramN});
} catch (IllegalAccessException e) {
} catch (InvocationTargetException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Non-fully-qualified names.
name = cls.getName().substring(
cls.getPackage().getName().length()+1);
name = field.getName();
name = constructor.getName().substring(
cls.getPackage().getName().length()+1);
name = method.getName();
// Fully-qualified names.
name = cls.getName();
name = cls.getName()+"."+field.getName();
name = constructor.getName();
name = cls.getName()+"."+method.getName();
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
object.getClass().isArray();
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
object.getClass().getComponentType();
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Creating an Array
// An array of 10 ints.
int[] ints =
(int[])Array.newInstance(int.class, 10);
// An array of 10 int-arrays.
int[][] ints2 =
(int[][])Array.newInstance(int[].class, 10);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Expanding an Array
The length of an array cannot be changed. The closest thing to
expanding an array is to create a larger one of the same type and
copy the contents from the old array.
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
field.setAccessible(true);
constructor.setAccessible(true);
method.setAccessible(true);
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang.reflect
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
new Class[]{MyInterface.class},
new ProxyClass(new MyInterfaceImpl()));
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.rmi
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
> rmiregistry
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.rmi
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
import java.rmi.*;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
try {
RObject robj =
new RObjectImpl();
Naming.rebind(
"//localhost/RObjectServer", robj);
} catch (MalformedURLException e) {
} catch (UnknownHostException e) {
} catch (RemoteException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.rmi
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Look up remote object
RObject robj = (RObject) Naming.lookup(
"//localhost/RObjectServer");
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.rmi
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
import java.rmi.*;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
throws RemoteException {
super();
}
public void primitiveArg(int num)
throws RemoteException {
}
public void byValueArg(Integer num)
throws RemoteException {
}
public void byRefArg(ArgObject arg)
throws RemoteException {
}
}
3. Compile the remote object implementation.
try {
RObject robj = new RObjectImpl();
Naming.rebind("//localhost/RObjectServer", robj);
} catch (MalformedURLException e) {
} catch (UnknownHostException e) {
} catch (RemoteException e) {
}
6. Look up the remote object and pass the parameters.
try {
// Look up the remote object
RObject robj =
(RObject) Naming.lookup(
"//localhost/RObjectServer");
} catch (MalformedURLException e) {
} catch (UnknownHostException e) {
} catch (NotBoundException e) {
} catch (RemoteException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.rmi
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
import java.rmi.*;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
try {
RObject robj = new RObjectImpl();
Naming.rebind("//localhost/RObjectServer", robj);
} catch (MalformedURLException e) {
} catch (UnknownHostException e) {
} catch (RemoteException e) {
}
6. Look up the remote object, invoke the methods, and receive the
return values.
try {
// Look up the remote object
RObject robj = (RObject) Naming.lookup(
"//localhost/RObjectServer");
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.rmi
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
import java.rmi.*;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
try {
RObject robj = new RObjectImpl();
Naming.rebind("//localhost/RObjectServer", robj);
} catch (MalformedURLException e) {
} catch (UnknownHostException e) {
} catch (RemoteException e) {
}
6. Look up the remote object, invoke the method, and catch the
exception.
try {
// Look up the remote object.
RObject robj = (RObject) Naming.lookup(
"//localhost/RObjectServer");
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.sound.sampled
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// From file
AudioInputStream stream =
AudioSystem.getAudioInputStream(
new File("audiofile"));
// From URL
stream = AudioSystem.getAudioInputStream(
new URL("http://hostname/audiofile"));
// Start playing.
clip.start();
} catch (MalformedURLException e) {
} catch (IOException e) {
} catch (LineUnavailableException e) {
} catch (UnsupportedAudioFileException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.sound.sampled
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// From file
AudioFileFormat fformat =
AudioSystem.getAudioFileFormat(
new File("audiofile"));
// From URL
fformat = AudioSystem.getAudioFileFormat(
new URL("http://hostname/audiofile"));
if (fformat.getType() ==
AudioFileFormat.Type.AIFC) {
} else if (fformat.getType() ==
AudioFileFormat.Type.AIFF) {
} else if (fformat.getType() ==
AudioFileFormat.Type.AU) {
} else if (fformat.getType() ==
AudioFileFormat.Type.WAVE) {
}
} catch (MalformedURLException e) {
} catch (IOException e) {
} catch (UnsupportedAudioFileException e) {
// File format is not supported.
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.sound.sampled
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// From file
// The next three lines should be in one line
AudioInputStream stream =
AudioSystem.getAudioInputStream(
new File("audiofile"));
// From URL
stream = AudioSystem.getAudioInputStream(
new URL("http://hostname/audiofile"));
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
javax.sound.sampled
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.sound.sampled
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// From file
AudioInputStream stream =
AudioSystem.getAudioInputStream(
new File("audiofile"));
// From URL
stream = AudioSystem.getAudioInputStream(
new URL("http://hostname/audiofile"));
int numRead = 0;
byte[] buf = new byte[line.getBufferSize()];
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.sound.sampled
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Loop forever.
clip.loop(Clip.LOOP_CONTINUOUSLY);
// Start playing.
clip.start();
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.sound.sampled
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
double timeInSeconds =
dataline.getMicrosecondPosition()/1000000.0d;
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.sound.sampled
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
dataline.addLineListener(new LineListener() {
public void update(LineEvent evt) {
if (evt.getType() == LineEvent.Type.STOP) {
}
}
});
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.sound.sampled
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Set Volume
FloatControl gainControl =
(FloatControl)dataline.getControl(
FloatControl.Type.MASTER_GAIN);
double gain = .5d; // number between 0 and 1.
float dB = (float)(Math.log(gain)/Math.log(10.0)*20.0);
gainControl.setValue(dB);
// Mute On
//The next three lines should all be in one line
BooleanControl muteControl =
(BooleanControl)dataline.getControl(
BooleanControl.Type.MUTE);
muteControl.setValue(true);
// Mute Off
muteControl.setValue(false);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
javax.sound.midi
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
Sequencer sequencer = MidiSystem.getSequencer();
sequencer.open();
// From file
Sequence sequence = MidiSystem.getSequence(
new File("midifile"));
// From URL
sequence = MidiSystem.getSequence(new URL(
"http://hostname/midifile"));
sequencer.setSequence(sequence);
// Start playing.
sequencer.start();
}
catch (MalformedURLException e) {
}
catch (IOException e) {
}
catch (MidiUnavailableException e) {
}
catch (InvalidMidiDataException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.sound.midi
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// From file
MidiFileFormat fformat =
MidiSystem.getMidiFileFormat(new File(
"midifile"));
// From URL
fformat = MidiSystem.getMidiFileFormat(new URL(
"http://hostname/midifile"));
switch (fformat.getType()) {
case 0:
// mid
break;
case 1:
// rmf
break;
}
}
catch (MalformedURLException e) {
}
catch (IOException e) {
}
catch (InvalidMidiDataException e) {
// File format is not supported.
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.sound.midi
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
double durationInSecs =
sequencer.getMicrosecondLength() / 1000000.0;
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.sound.midi
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
Sequencer sequencer = MidiSystem.getSequencer();
sequencer.open();
// From file
InputStream is = new BufferedInputStream(
new FileInputStream(new File("midifile")));
// From URL
is = new BufferedInputStream(
new URL("http://hostname/rmffile").openStream());
sequencer.setSequence(is);
// Start playing.
sequencer.start();
}
catch (MalformedURLException e) {
}
catch (IOException e) {
}
catch (MidiUnavailableException e) {
}
catch (InvalidMidiDataException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.sound.midi
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.sound.midi
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
sequencer.addMetaEventListener(
new MetaEventListener() {
public void meta(MetaMessage event) {
if (event.getType() == 47) {
// Sequencer is done playing
}
}
});
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.sound.midi
Code Samples Index
These code examples and other materials are subject to Sun Microsystems, Inc.
Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.security
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.security
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.security
Code Samples Index
These code examples and other materials are subject to Sun Microsystems, Inc.
Legal Terms
keystore ".keystore";
grant signedBy "Duke" {
permission java.io.FilePermission "${user.dir}/-",
"read";
};
grant codeBase "http://someserver/myjar.jar" {
permission java.util.PropertyPermission "file.encoding",
"read";
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.security
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
http://java.sun.com/products/jdk/1.2/docs
/guide/security/PolicyFiles.html
for more information. The location of these file is specified in the
file java.home/lib/security/java.security. By default, this file specifies two
locations:
file:/java.home
/lib/security/java.policy
file:/user.home
/lib/security/.java.policy
The runtime's policy is the union of entries in these files. To specify
an additional policy file, you can add entries to the java.security file:
> appletviewer
-J-Djava.security.policy=someURL HTMLfile
To ignore the policies in the java.security file, and only use the
specified policy, use == instead of =:
>java -Djava.security.manager
-Djava.security.policy==someURL MyApp
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.security
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.security
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
KeyStore keyStore = KeyStore.getInstance(
KeyStore.getDefaultType());
java.security.cert.Certificate cert =
keyStore.getCertificate("Principal");
process(cert);
} catch (KeyStoreException e) {
} catch (java.security.cert.CertificateException e) {
} catch (NoSuchAlgorithmException e) {
} catch (java.io.IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.security
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
AccessController.checkPermission(new FilePermission(
"/tmp/*", "read,write"));
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.security
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
if (perm1.implies(perm2)) {
// perm1 implies perm2
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.security
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
import java.awt.*;
import javax.swing.*;
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
frame.setBounds(x, y, w, h);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Creating a Button
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Creating a ComboBox
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems, Inc. Legal
Terms
}
}
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems, Inc.
Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Create a menu.
JMenu menu = new JMenu("Menu Label");
menuBar.add(menu);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
menu.add(item1);
menu.add(new JSeparator());
menu.add(item2);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
int minimum = 0;
int maximum = 100;
JProgressBar progress = new JProgressBar(
minimum, maximum);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Creating a Slider
int minimum = 0;
int maximum = 100;
int initValue = 50;
// A horizontal slider.
JSlider hSlider = new JSlider(
JSlider.HORIZONTAL, minimum, maximum, initValue);
hSlider.addChangeListener(new MyChangeListener());
// A vertical slider.
JSlider vSlider = new JSlider(
JSlider.VERTICAL, minimum, maximum, initValue);
vSlider.addChangeListener(new MyChangeListener());
if (!slider.getValueIsAdjusting()) {
int value = slider.getValue();
process(value);
}
}
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
JTextField textfield =
new JTextField("Initial Text");
textfield.addActionListener(new MyActionListener());
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems, Inc.
Legal Terms
Creating a Table
A table fires change events when the contents of one of its cells is
modified.
Object[][] cellData = {
{"row1-col1", "row1-col2"},
{"row2-col1", "row2-col2"}};
String[] columnNames = {"col1", "col2"};
process(data);
}
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
String url = "http://java.sun.com";
JEditorPane editorPane = new JEditorPane(url);
editorPane.setEditable(false);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Creating a Toolbar
This example adds an image button to the toolbar.
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
<
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
component.getActionMap().put("actionName",
new AbstractAction("actionName") {
// The next two lines should be in one line
public void actionPerformed(
ActionEvent evt) {
process(evt);
}
}
);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Add a KeyStroke
inputMap.put(KeyStroke.getKeyStroke(
"F2"), "actionName");
inputMap.setParent(component.getInputMap(
JComponent.WHEN_FOCUSED));
component.setInputMap(
JComponent.WHEN_FOCUSED, inputMap);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
component.setToolTipText("aString");
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
int rows = 2;
int cols = 2;
// The next two lines should be in one line.
JPanel panel = new JPanel(new GridLayout(
rows, cols));
panel.add(component1);
panel.add(component2);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Setting a Border
This example lists the various borders that are available.
component.setBorder(
BorderFactory.createEmptyBorder());
component.setBorder(
BorderFactory.createLineBorder(
Color.black));
component.setBorder(
BorderFactory.createEtchedBorder());
component.setBorder(
BorderFactory.createRaisedBevelBorder());
component.setBorder(
BorderFactory.createLoweredBevelBorder());
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
component.setBorder(titledBorder);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
UIManager.LookAndFeelInfo[] info =
UIManager.getInstalledLookAndFeels();
for (int i=0; i<info.length; i++) {
String humanReadableName = info[i].getName();
String className = info[i].getClassName();
// The className is used with
// UIManager.setLookAndFeel()
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// The next three lines should all be in one line.
UIManager.setLookAndFeel(
"com.sun.java.swing.plaf.windows.
WindowsLookAndFeel");
} catch (InstantiationException e) {
} catch (ClassNotFoundException e) {
} catch (UnsupportedLookAndFeelException e) {
} catch (IllegalAccessException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
ImageBgPanel() {
texture = new TexturePaint(bufferedImage,
// The next two lines should be in one line.
new Rectangle(0, 0,
bufferedImage.getWidth(
), bufferedImage.getHeight()));
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing.event
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
String url = "http://java.sun.com";
JEditorPane editorPane = new JEditorPane(url);
editorPane.setEditable(false);
editorPane.addHyperlinkListener(
new MyHyperlinkListener());
} catch (IOException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing.event
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing.filechooser
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
JFileChooser fileChooser =
new JFileChooser(new File(filename));
fileChooser.addChoosableFileFilter(new MyFilter());
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
javax.swing.tree
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Creating a Tree
This example creates a tree component with a root node and a
child of the root node. You build the tree hierarchy by adding nodes
to nodes.
DefaultMutableTreeNode root =
new DefaultMutableTreeNode("Root Label");
root.add(new DefaultMutableTreeNode(
"Node Label"));
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing.tree
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
tree.addTreeSelectionListener(
new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent evt) {
DefaultMutableTreeNode node =
(DefaultMutableTreeNode)
(evt.getPath().getLastPathComponent());
process(node);
}
});
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing.text
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
JTextPane textPane = new JTextPane();
StyledDocument doc =
(StyledDocument)textPane.getDocument();
Style style = doc.addStyle("StyleName", null);
// Italic
StyleConstants.setItalic(style, true);
// Bold
StyleConstants.setBold(style, true);
// Font Family
StyleConstants.setFontFamily(style, "SansSerif");
// Font Size
StyleConstants.setFontSize(style, 30);
// Background Color
StyleConstants.setBackground(style, Color.blue);
// Foreground Color
StyleConstants.setForeground(style, Color.white);
// Append to document.
doc.insertString(doc.getLength(),
"Some Text", style);
} catch (BadLocationException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing.text
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
Style style = doc.addStyle("StyleName", null);
StyleConstants.setIcon(style,
new ImageIcon("imagefile"));
doc.insertString(doc.getLength(),
"ignored text", style);
} catch (BadLocationException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing.text
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
Style style = doc.addStyle("StyleName", null);
StyleConstants.setComponent(
style, new JButton("OK"));
doc.insertString(doc.getLength(),
"ignored text", style);
} catch (BadLocationException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Normal termination.
System.exit(0);
// Abnormal termination.
int errorCode = -1;
System.exit(errorCode);
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Constructing a String
If you are constructing a string with several appends, it may be
more efficient to construct it using a StringBuffer and then convert
it to an immutable String object.
// Modify
int index = 1;
buf.insert(index, "123"); // I123nitial Text
buf.append("456"); // I123nitial Text456
buf.delete(1, 4); // Initial Text456
buf.replace(12, 15, " XY"); // Initial Text XY
// Convert to string
String s = buf.toString(); // Initial Text XY
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
int start = 1;
int end = 4;
String substr =
"aString".substring(start, end); // Str
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Searching a String
// First occurrence.
int index = string.indexOf('S'); // 1
// Last occurrence.
index = string.lastIndexOf('i'); // 4
// Not found.
index = string.lastIndexOf('z'); // -1
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
int i = Integer.parseInt("123");
long l = Long.parseLong("123");
float f = Float.parseFloat("123.4");
double d = Double.parseDouble("123.4e10");
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems, Inc.
Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
class WorkQueue {
LinkedList queue = new LinkedList();
public synchronized void addWork(Object o) {
queue.addLast(o);
notify();
}
public synchronized Object getWork()
throws InterruptedException {
while (queue.size() == 0) {
wait();
}
return queue.removeFirst();
}
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Executes a Command
try {
String command = "ls";
Process child =
Runtime.getRuntime().exec(command);
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Execute command
String command = "ls";
Process child =
Runtime.getRuntime().exec(command);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Execute command
String command = "cat";
Process child =
Runtime.getRuntime().exec(command);
out.write("some text".getBytes());
out.close();
} catch (IOException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Pausing
try {
Thread.sleep(5000); // 5 seconds
} catch (InterruptedException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// One way
long time = System.currentTimeMillis();
// Another way
Date now = new Date();
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
// Set value.
tlData.set(o);
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
System.loadLibrary("libraryName");
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
String string = "\u5639\u563b";
byte[] utf8 = string.getBytes("UTF8");
} catch (UnsupportedEncodingException e) {
}
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
java.lang
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
char ch = '\u5639';
Character.UnicodeBlock block =
Character.UnicodeBlock.of(ch);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
Object obj = ctx.lookup("Sample");
} catch (NamingException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
NamingEnumeration enum = ctx.list("child");
while (enum.hasMore()) {
NameClassPair entry =
(NameClassPair)enum.next();
process(entry);
}
} catch (NamingException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Add a binding.
ctx.bind("Name", new SampleObjectImpl());
// Replace a binding.
ctx.rebind("Name", new SampleObjectImpl());
// Remove a binding.
ctx.unbind("Name");
// Rename a binding.
ctx.rename("Name", "NewSample");
} catch (NamingException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Create a subcontext.
ctx.destroySubcontext(
"child");
} catch (NamingException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
Context obj = (Context)childCtx.lookup(
"grandChild");
String fullname = obj.getNameInNamespace();
} catch (NamingException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
Object obj = new InitialContext().lookup(
"iiop://localhost/Sample");
} catch (NamingException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
CompositeName composite = new CompositeName(
"cn=John,o=hits/report/summary.txt");
String first = composite.get(0);
// summary.txt
String last = composite.get(composite.size()-1);
// cn=John,o=hits
// wiz.com/cn=John,o=hits/report/summary.txt
composite.add(0, "wiz.com");
// wiz.com/cn=John,o=hits/summary.txt
composite.remove(2);
} catch (NamingException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
javax.naming
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
NameParser parser = ctx.getNameParser("");
Name dn = parser.parse(
"cn=John, ou=People, o=JNDITutorial");
// ou=People
dn.remove(1);
// cn=John,o=JNDITutorial,c=us
dn.add(0, "c=us");
// cn=fs,cn=John,o=JNDITutorial,c=us
dn.add("cn=fs");
} catch (NamingException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
javax.naming.directory
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming.directory
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Specify the ids of the attributes to return
String[] attrIDs =
{"sn", "telephonenumber", "golfhandicap",
"mail"};
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
javax.naming.directory
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Specify the changes to make
ModificationItem[] mods =
new ModificationItem[3];
// Remove jpegphoto
mods[2] = new ModificationItem(
DirContext.REMOVE_ATTRIBUTE,
new BasicAttribute("jpegphoto"));
ou=People", mods);
} catch (NamingException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming.directory
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Create attributes to be associated with the
//new entry
// case-ignore
Attributes attrs = new BasicAttributes(true);
Attribute objclass = new BasicAttribute(
"objectclass");
objclass.add("top");
objclass.add("extensibleObject");
attrs.put(objclass);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
javax.naming.directory
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Create attributes to be associated with the
// new entry
// case-ignore
Attributes attrs =
new BasicAttributes(true);
Attribute objclass =
new BasicAttribute(
"objectclass");
objclass.add("top");
objclass.add("extensibleObject");
attrs.put(objclass);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming.directory
Code Samples Index
These code examples and other materials are subject to Sun Microsystems, Inc.
Legal Terms
try {
// Specify the ids of the attributes to return
String[] attrIDs = {"sn", "telephonenumber",
"golfhandicap", "mail"};
while (enum.hasMore()) {
SearchResult entry =
(SearchResult)enum.next();
process(entry);
}
} catch (NamingException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming.directory
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Specify the ids of the attributes to return
String[] attrIDs = {"sn", "telephonenumber",
"golfhandicap", "mail"};
while (enum.hasMore()) {
SearchResult entry = (SearchResult)enum.next();
process(entry);
}
} catch (NamingException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming.directory
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
SearchControls ctls = new SearchControls();
ctls.setSearchScope(SearchControls.SUBTREE_SCOPE);
while (enum.hasMore()) {
SearchResult entry = (SearchResult)enum.next();
process(entry);
}
} catch (NamingException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
javax.naming.directory
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Specify the attributes to match
// Ask for objects that have attribute
// "sn" == Geisel and the "mail" attribute
// ignore case
Attributes matchAttrs = new BasicAttributes(true);
matchAttrs.put(new BasicAttribute("sn", "Geisel"));
matchAttrs.put(new BasicAttribute("mail"));
if (enum.hasMore()) {
SearchResult entry =
(SearchResult)enum.next();
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming.directory
Code Samples Index
These code examples and other materials are subject to Sun Microsystems, Inc.
Legal Terms
try {
// Get context containing class definitions for
//cn=Ted Geisel entry
DirContext tedClasses = ctx.getSchemaClassDefinition(
"cn=Ted Geisel, ou=People");
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming.directory
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Get an attribute of that type
Attributes attrs = ctx.getAttributes("cn=Ted Geisel,
ou=People", new String[]{"cn"});
Attribute cnAttr = attrs.get("cn");
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming.directory
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming.event
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Get event context for registering listener
EventContext ctx = (EventContext)(new
InitialContext(env).lookup("ou=People"));
// Create listener
NamingListener listener =
new SampleNCListener();
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming.event
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Get event context for registering listener
EventDirContext ctx = (EventDirContext)(
new InitialContext(env).lookup("ou=People"));
// Create listener
NamingListener listener =
new SampleObjListener();
process(evt.getNewBinding());
process(evt.getOldBinding());
}
public void namingExceptionThrown(
NamingExceptionEvent evt) {
processException(evt.getException());
}
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming.ldap
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
// Create connection controls to use
Control[] connectCtls = new Control[]{
new SomeControl()};
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming.ldap
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
LdapContext ctx = new InitialLdapContext(
env, null);
// Enumerate answers
while (answer.hasMore()) {
NameClassPair item =
(NameClassPair)answer.next();
}
} catch (NamingException e) {
}
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming.ldap
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
LdapContext ctx = new InitialLdapContext(
env, null);
// Perform search
NamingEnumeration answer = ctx.search(
"ou=People", "(cn=*)", null);
// Enumerate answers
while (answer.hasMore()) {
SearchResult si =
(SearchResult)answer.next();
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.naming.ldap
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
try {
LdapContext ctx = new InitialLdapContext(
env, null);
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.rmi
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
> rmiregistry
If you are using RMI over the Internet Inter-ORB Protocol (IIOP),
start up the CORBA Common Object Services (COS) name server
so that you can create and export remote objects.
> tnameserv
Examplets TM provided by permission of the publisher, Addision-Wesley, and
Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.rmi
Code Samples Index
These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms
import java.rmi.*;
import java.rmi.*;
import java.rmi.server.UnicastRemoteObject;
import javax.naming.*;
import java.rmi.RemoteException;
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.rmi
Code Samples Index
These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms
import javax.naming.*;
import java.rmi.RemoteException;
import javax.rmi.PortableRemoteObject;
Examplets TM provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan.
Order this book from Amazon
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.
javax.swing.undo
Code Samples Index
These code examples and other materials are subject to Sun Microsystems,
Inc. Legal Terms
textarea.getActionMap().put("Undo",
new AbstractAction("Undo") {
public void actionPerformed(ActionEvent evt) {
try {
if (undo.canUndo()) {
undo.undo();
}
} catch (CannotUndoException e) {
}
}
});
textarea.getInputMap().put(KeyStroke.getKeyStroke(
"control Z"), "Undo");
textarea.getActionMap().put("Redo",
new AbstractAction("Redo") {
public void actionPerformed(ActionEvent evt) {
try {
if (undo.canRedo()) {
undo.redo();
}
} catch (CannotRedoException e) {
}
}
});
textarea.getInputMap().put(KeyStroke.getKeyStroke(
"control Y"), "Redo");
Products & APIs | Developer Connection | Docs & Training | Online Support
Community Discussion | Industry News | Solutions Marketplace | Case Studies
Glossary - Applets - Tutorial - Employment - Business & Licensing - Java Store - Java in the Real World
FAQ | Feedback | Map | A-Z Index
For more information on Java technology
and other software from Sun Microsystems, call:
(800) 786-7638
Outside the U.S. and Canada, dial your country's Copyright © 1995-2000 Sun Microsystems, Inc.
AT&T Direct Access Number first. All Rights Reserved. Terms of Use. Privacy Policy.