Code Example Ts
Code Example Ts
It's also good practice to add catch clauses, as appropriate, to the examplets. If the code of an
examplet throws a checked exception, the code is surrounded by a try/catch statement. However, to
reduce space and distraction, the catch clause is left blank. Catch clauses should always handle the
exception and should never be left blank. So, at the very least, you should include a call to
e.printStackTrace() to display the exception on the console.
● Accessibility ● JNDI Events
● Applets ● JNDI LDAP
● AWT GUI Creation ● Language Essentials
● AWT Clipboard ● Math
● AWT Drag-n-Drop ● Networking
● AWT Events ● Printing
● AWT Fonts ● Reference Objects
● AWT Shapes ● Reflection
● Compression -- Zip Files ● RMI
● Compression -- JAR Files ● Sampled Sound
● Data Structures and Algorithms ● Sampled Sound -- MIDI
● Files, Streams, I/O ● Security
● Images ● Swing GUI Creation
● Internationization ● Swing Event Handling
● JavaBeans[tm] Technology ● Swing File Chooser
● JDBC[tm] Technology -- Database ● Swing Text Component
Access ● Swing Tree Component
● JNDI ● Swing Undo
● JNDI Directory
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
JNDI (javax.naming)
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 Se rvice
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
Math (java.math)
Operating With Big Integer Values
Operating With Big Decimal Values
Setting the Decimal Place of a Big Decimal Value
Networking (java.net)
Creating a URL
Parsing a URL
Reading Text from a URL
Calling a CGI Using POST Method
Resolving a Hostname
Creating a Client Socket
Creating a Server Socket
Reading Text from a Socket
Writing Text to a Socket
Sending a Datagram
Receiving a Datagram
Joining a Multicast Group
Receiving from a Multicast Group
Sending to a Multicast Group
Printing (java.awt.print)
Getting the Dimensions of a Printed Page
Setting the Orientation of a Printed Page
Printing Pages with Different Formats
Displaying the Page Format Dialog
Displaying the Print Dialog
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
Starting the Name Server
Defining and Exporting a Portable Remote Object
Looking Up a Portable Remote Object and Invoking a Method
Security (java.security)
Creating a New Key Pair and Self-signed Certificate
Creating and Signing a JAR File
Creating a New Policy File
Managing Policy Files
Creating a Keyed Digest Using MD5
Getting a Certificate from a Keystore
Checking Read/Write Permission for a Directory
Checking if One Permission Implies Another
Creating a Secure Random Number
These code examples and other materials are subject to Sun Microsystems, Inc. Legal Terms
ExampletsSM provided by permission of the publisher, Addision-Wesley, and Author Patrick Chan.
Unless otherwise licensed, code in all technical materials herein Copyright © 1995-2002 Sun Microsystems, Inc.
(including articles, FAQs, samples) is provided under this License. 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.*;
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
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();
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();
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
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();
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.*;
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
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
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
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
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
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
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);
}
}
}
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);
}
}
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);
}
}
);
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()));
}
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) {
}
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
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
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) {
}
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) {
}
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();
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) {
}
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();
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.