| Enable copy and paste functionality between Swing's JTables and Excel |
|
JTables and Excel charts are commonly used to display data in a grid or table. Often, the data that the user wishes to enter into a JTable already exists in Excel spreadsheets. The Excel format is used for export-import functionality by software other than Excel. Because of this, it is important that Java software also provide common clipboard functionality, like copy and paste, between JTables and Excel. This article shows how to enable Java programs to copy data from JTables into Excel using the system clipboard. Using the adapter class presented in this Java Tip, the ability to copy and paste information to and from your JTables and Excel can be added with only one line of code. Submitted: Dec 06, 1999
|
| Instruction on loading bitmap files in a Java app |
|
A step-by-step guide to loading bitmap files in a Java application: Currently, only GIF and JPEG images are supported by the standard getImage() method. While Java routines exist for PNG (Portable Network Graphics) format images, we don't know of any reader existing for Microsoft Windows bitmap images. This tip, authored by Jeff West, provides code for loading Windows bitmap images. Submitted: Dec 06, 1999
|
| Cut, copy, and paste in Java |
|
Considering that all modern programs include clipboard facilities, you must have been anxiously waiting for JDK 1.1 in order to add the functionality to your Java applications or applets. Throughout this article, we'll explore all aspects of clipboard operations, including how to transfer text, Java objects, or any other type of data. Submitted: Dec 06, 1999
|
| Learn how to implement the Command pattern in Java |
|
Sometimes it's necessary to issue requests to objects without knowing anything about the operation being requested or the receiver of the request. In procedural languages, this type of communication is accomplished via a callback: a function that is registered somewhere to be called at a later point. Commands are the object-oriented equivalent of callbacks and encapsulate the callback function. In this tip, Bala Paranj demonstrates how to make use of the Command pattern in Java. Submitted: Dec 06, 1999
|
| Glossary: Java Gotchas |
|
A gotcha is a nasty surprise in the Java language or the standard libraries. Some might call them bugs, some features. Sometimes they are the result of incompetence or carelessness on the part of the language designers and sometimes they are just quirky things that cannot be helped. Here is a chart of the some dangerous waters. Submitted: Feb 15, 2005
|
| How to play audio in applications |
|
Current support of audio playback in Java applets makes the task quite simple, but support in applications is lacking. This tip shows you how to play audio clips in your Java applications. Submitted: Dec 06, 1999
|
| Java Bean FAQ |
|
A Java Beans FAQ (with answers). Submitted: Nov 23, 1999
|
| How to extract Java resources from JAR and zip archives |
|
Bundling an assortment of Java resources in a Java ARchive (JAR) file is an excellent way to reduce download time, increase security, and increase manageability. This tip shows you how to easily extract the resources from JAR files for your own use. Submitted: Dec 06, 1999
|
| Saving bitmap files in Java |
|
Although Java provides several mechanisms for opening images, saving them is not one of its strengths. This tip will teach you how to save an image in a 24-bit bitmap file. Plus: Jean-Pierre provides all the code necessary to write a bitmap file from an image object. Submitted: Dec 06, 1999
|
| Interact with garbage collector to avoid memory leaks |
|
In model-view-controller (MVC) applications, models often accumulate references to unused view objects. These references prevent the view objects from being garbage-collected, even after the user disposes of views that can no longer be used. This tip shows you how to implement your own models to remove unneeded listeners automatically, thus preventing memory leaks. A simple application is included to demonstrate the problem and solution. Submitted: Dec 06, 1999
|
| Singletons vs. class (un)loading |
|
JavaSoft has tightened up the specification for loading and unloading classes in the upcoming Java 1.2 release. The changes to the specification and the JDK 1.2 implementation allow Java programmers to (finally) safely take advantage of the traditional implementation of the Singleton pattern. Submitted: Dec 06, 1999
|
| Compile Java code without the JDK |
|
Along with the Java virtual machine (JVM) interpreter and runtime system, a Java compiler is built into the Navigator 2.0 browser. So you can now brew some of your own Java without having to get and set up the complete Java Development Kit (JDK), which can be pretty painful on some computers. Submitted: Dec 06, 1999
|
| Java Native Interface Tips |
|
Various Java Native Interface Tips resources and FAQ's, including the book "Java Native Interface: Programmer's Guide and Specification", the JNI FAQ for the Java 2 SDK, and various other resources. Submitted: Nov 23, 1999
|
| General FAQ |
|
This collection of frequently asked questions (FAQ) provides brief answers to many common questions about the Sun JavaTM Platform, programming language, and the Java Development Kit (JDKTM). Submitted: Nov 16, 1999
|
| Build dynamically extensible frameworks |
|
Using property objects and dynamic class loading, tip author Fredrik Rubensso helps you build well-designed, easily extensible frameworks that are data-independent. This tip includes a simple example of how the framework technique works, and it shows you how to use interfaces in framework design. Submitted: Dec 06, 1999
|
| Control browsers from your Java application |
|
It's great that Java applets and browsers are so tightly integrated, but what if you want to have your Java application display a URL? There's no API call in any Java package that can help you with that... The class I have written, called BrowserControl takes the above into account and will work for both Windows and Unix platforms. For the Unix platform, you must have Netscape installed and in your path in order for this to work unmodified. If you're a Mac user and know how to invoke a browser from within a Java application, let me know... Submitted: Dec 06, 1999
|
| Integrating Java with C++ |
|
Learn how to use C++ code from within a Java application and how to call from C++ to a Java object. Submitted: Dec 06, 1999
|
| Programming user-friendly double clicks |
|
What to do when the default handling of a double-click event isn't good enough: Double-click mouse events are "synthetic." They are really a fiction created by the system/application. The basic idea is that if you click a mouse button twice in succession in the same location fast enough then a double-click event will be created... Unfortunately, the "normal" AWT behavior for double-click handling seems to be hard-coded into the Java AWT implementation. The AWT definitions for "same location" and "fast enough" are also not very user friendly for folks who are a bit slow on mouse buttons or for people who have shaky hands... Submitted: Dec 06, 1999
|
| Redirecting streams |
|
How to change the standard input, output, and error streams to files of your choice. Submitted: Dec 06, 1999
|
| Build data-type-independent JDBC applications |
|
Database programming often requires working with data from external data sources, such as plain text files. In this article, Sesh Venugopal presents an improved technique for converting plain text data to actual types in a database, using DatabaseMetaData, the JDBC (Java Database Connectivity) metadata interface, along with the execution of precompiled SQL. He gives you a tip on how to discover database-specific data types at runtime and translate external text data. Submitted: Dec 06, 1999
|
| Calculating holidays and their observances |
|
Determining the actual and observed dates for holidays often is a painful task - unless you have Java. This tip will demystify the convoluted calculations of a number of U.S. holidays. Submitted: Dec 06, 1999
|
| Cascading menus |
|
Here's a tip on how to make multiple levels of cascading menus. Submitted: Dec 06, 1999
|
| Fast launcher for Java apps |
|
This Java Tip will show you how to start Java applications as easily as you start your native apps. Plus, you'll learn how to use menu shortcuts for testing the apps with multiple JDK versions. Submitted: Dec 06, 1999
|
| HotJava FAQ |
|
This collection of frequently asked questions (FAQ) provides brief answers to common questions about Sun's HotJava World Wide Web Browser. Submitted: Nov 16, 1999
|
| Resize applets within browser frames |
|
Many n-tier architectures deploy applets as a GUI frontend for applications. Frequently, the browser then acts as the applet's frame. This helps prevent the user from assuming that the browser window is a separate application and accidentally closing it. The problem with this approach is that the applet does not resize itself as the user resizes the browser frame. This article presents a technique to enable dynamic resizing of applets embedded within browser frames. The approach is simple and uses JavaScript-to-Java communication. Submitted: Dec 06, 1999
|
| Sound FAQ |
|
This collection of frequently asked questions (FAQ) provides brief answers to many common questions about JavaTM Sound. Submitted: Nov 23, 1999
|
| Creating in-memory images in Java |
|
Save network bandwidth by creating images at run time. Submitted: Dec 06, 1999
|
| Explicit and recursive programming in Java |
|
Sometimes it is very easy to become too involved in attempting to prematurely optimize Java code in terms of code size or speed. This can result in code that is hard to read, and therefore difficult to maintain and debug. This article will show you how - by programming in a style that explicitly and simply states the intent of the code - performance need not be compromised, thereby making your programming life easier. Submitted: Dec 06, 1999
|
| FAQ for programmers using theJavaTM language |
|
This Java FAQs collection is intended for people who already have some programming experience, though maybe not in the JavaTM programming language. Submitted: Nov 23, 1999
|
| Media Framework FAQ |
|
This collection of frequently asked questions (FAQ) provides brief answers to many common, general questions about the JavaTM Media Framework API (JMF). Submitted: Nov 23, 1999
|
| The trick to "Iterator Observers" |
|
Factor out common code and make your Iterators observable: Examples of the Iterator and Observer pattern can be found in most object-oriented systems and class libraries. Using these two patterns together to create Iterator Observers can help reduce code duplication and promote the degree to which software components depend on each other (coupling). The looser the coupling between components or subsystems the easy they are to interchange and maintain. Submitted: Dec 06, 1999
|
| The trick to using Java networking applets behind firewalls |
|
Learn how to get around the security restriction placed on Java applets behind firewalls. Submitted: Dec 06, 1999
|
| Write Java apps that work with proxy-based firewalls |
|
How to use Java to connect with HTTP servers outside your corporate firewall. Submitted: Dec 06, 1999
|
| You'll flip over Java images -- literally! |
|
Avoid filtering when flipping, scaling, and cropping images -- with Java 1.1. Submitted: Dec 06, 1999
|
| Dan Crintea's Java Page |
|
Java, wireless, various resources. Submitted: Dec 10, 2003
|
| How to decouple the Observer/Observable object model |
|
Here's a tip, complete with code samples and illustrations, for optimizing the performance of updates to the Observer. Submitted: Dec 06, 1999
|
| Our first Java Tip of the Week winner! |
|
This tip features code that shows how two applets on two separate pages can communicate with each other. Submitted: Dec 06, 1999
|
| Applet parameterization -- initializing arrays |
|
Parameterizing an applet is often a tedious chore, involving many repetitive lines of code in the applet's init() method. Last month, Java tipster Yvon Sauvageau showed you how to reduce all those lines of code to just one, thanks to the class reflection mechanism. He did not, however, demonstrate how to implement array initialization. This tip shows you the ins and outs of automating array initialization. Submitted: Dec 06, 1999
|
| Applet parameterization via class reflection |
|
Parameterizing an applet is usually a tedious chore involving many repetitive lines of code in the applet's init() method. What you may not have known is that all these lines can be replaced by a single one. This tip shows you how it can be done, thanks to the class reflection mechanism. Submitted: Dec 06, 1999
|
| Avoid 'constructor madness' |
|
Tired of creating overloaded constructors for every conceivable set of initialization properties for your classes? Find out how to design secondary configuration classes for initialization parameters instead. Submitted: Dec 06, 1999
|
| Create new event types in Java |
|
Learn how to make event classes for components in JDK 1.1. Submitted: Dec 06, 1999
|
| Create objects from jar files! |
|
Here's your chance to put the expertise you gleaned from two previous Java Tips to use! In the new Java Tip, John takes you through the intricacies of loading class files and instantiating the objects of those classes. Submitted: Dec 06, 1999
|
| Development and testing |
|
Java development and testing from home -- without a network. Submitted: Dec 06, 1999
|
| How to create mutually exclusive menus in Java |
|
Java 1.1 offers a cleaner, more self-contained method of extending the Menu class. Submitted: Dec 06, 1999
|
| POSTing via Java |
|
Learn how to POST data to Web servers in Java. Submitted: Dec 06, 1999
|
| Reloading applets in Netscape |
|
Five ways to force Netscape Navigator to reload your Java applet: This week we explore various methods to coerce Netscape's Navigator to reload Java applets without having to exit and restart the browser. Submitted: Dec 06, 1999
|
| Returning data in reference arguments via JNI |
|
This tip shows how a C/C++ native method can use the Java Native Interface (JNI) to populate an object's data fields when a reference to that object is passed as an argument to the native method. The article also shows how a native method can create an object and populate its data fields before returning the object to Java. Submitted: Dec 06, 1999
|
| Tech Tips |
|
Tech Tips is an electronic mailing sent to Java Developer ConnectionSM (JDC) members who elect to subscribe when they register. Each mailing contains tips, techniques, and sample code on various topics of interest to developers of the JavaTM programming language and platform... Here is a complete listing of previous issues by date and topic... Submitted: Nov 24, 1999
|
| Use dynamic messaging in Java |
|
Developers in a variety of dynamic languages (such as SmallTalk and Objective C) have enjoyed the ability to send dynamic methods to objects at runtime. Unlike Java, these languages permit a method to be invoked that doesn't actually exist, with the resulting error trapped in a doesNotUnderstand method. Dynamic messaging is not possible in Java source code, as all methods are type-checked by the compiler. This article explains how dynamic messaging can be easily used and how it can be used to implement the doesNotUnderstand method. Submitted: Dec 06, 1999
|
| Write native methods on Linux |
|
Here's a step-by-step recipe for writing and using native methods on the Linux platform. Submitted: Dec 06, 1999
|
| EJB Factory |
|
A technical description of Enterprise Java Beans(EJB)architecture, as per Sun Microsystems' EJB Specifications Version 1.0. Submitted: Jul 11, 2000
|
| Measure data transfer speeds via Sun's ORB in JDK 1.2 beta 4 |
|
In this brief tip, you'll get a simple Java benchmark for data transfer speeds using CORBA. Source code is provided, which means you can modify the program. The benchmark consists of client and server applications that use Sun Microsystems's Naming Service. Submitted: Dec 06, 1999
|
| Object transport via datagram packets |
|
Transport Java objects over the network with datagram packets. Submitted: Dec 06, 1999
|
| On the Parameter Constants Pattern |
|
In order to achieve the conflicting goals of decoupling and containment, constants that are usually defined in a class can alternatively be defined in a nested interface. Any client class that makes substantial use of the constants is free to implement the nested interface and use the constants more conveniently by not prefixing them with the class name. This design pattern can be augmented with nested classes to provide type safety for parameters constants. Submitted: Dec 06, 1999
|
| Protect your bytecodes from reverse engineering/decompilation |
|
Learn how the Crema obfuscator can help protect your Java code from decompilers such as Mocha. Submitted: Dec 06, 1999
|
| Save typing time |
|
Reduce your typing effort in Java. Submitted: Dec 06, 1999
|
| The Java Tutorial FAQ |
|
This page attempts to answer the questions that readers most frequently send to the tutorial e-mail address. We hope this information helps you get your answers. So, in the Q & A style of great columnists everywhere, Khwarazm and Me answer your questions... Submitted: Nov 23, 1999
|
| 2D FAQ |
|
This collection of frequently asked questions (FAQ) provides brief answers to many common questions about Java 2D. Submitted: Nov 23, 1999
|
| Activator FAQ |
|
This is the Java[TM] Plug-In FAQ. Java Plug-in was formerly known as Project Java Activator during its early access phases. Submitted: Nov 23, 1999
|
| Finally -- how to use a basic Java 1.1 network and file class loader |
|
Having trouble with that class loader? Here's how to use one in Java 1.1 that works either over the 'Net or from a local file. Submitted: Dec 06, 1999
|
| Get rid of those empty black squares in your text editor |
|
The representation of the line separator depends on the operating system. Unfortunately, different conventions lead to special effects which may hinder you in your actual work. An example for this is the representation of a text that was written using one convention but is read on a system with a different convention. This tip provides you with an application to solve such problems and explains how Java handles the line separator. Submitted: Dec 06, 1999
|
| How to deal with applet resizing in Netscape - Continued |
|
Continued discussion of how to deal with applet resizing in Netscape Navigator: We discuss further the interaction of threads and resizing. Last time we presented Noah Green's take on how to deal with threads in the face of Netscape Navigator's resizing behavior. A couple of readers suggested a different approach with different tradeoffs that may work better for you. Submitted: Dec 06, 1999
|
| How to improve Java's I/O performance |
|
The JDK 1.0.2 java.io package has meant problems for I/O performance, but here's a tip for making the situation better - plus an extra tip on turning off synchronization. Submitted: Dec 06, 1999
|
| Implementing callback routines in Java |
|
Using interfaces to implement the equivalent of callback functions in Java. Submitted: Dec 06, 1999
|
| Java constants |
|
Constants and conditional compilation help speed code. Submitted: Dec 06, 1999
|
| Launch Java applications quickly from Windows 95 |
|
Tired of shelling to a DOS prompt and running the Java interpreter every time you want to run a standalone app? Find out how to save yourself some time -- with DOS command shortcuts. Submitted: Dec 06, 1999
|
| Lazy instantiation |
|
The balance between the performance of software and the resources it consumes has been an issue since the birth of computers. It stems from the need to conserve valuable resources such as memory, possibly at the expense of performance. This tip examines one way to reduce memory usage in Java programs - by deferring the creation of objects until they are actually required. Submitted: Dec 06, 1999
|
| Polymorphism and Java |
|
What to do when switch statements start reappearing in your code. Submitted: Dec 06, 1999
|
| Share Java objects using e-mail |
|
The Serializable interface, new with JDK 1.1, simplifies object persistence. Here's how to transfer an object to another user via SMTP e-mail. Submitted: Dec 06, 1999
|
| Test your Java/CORBA server from the inside |
|
Testing a server class can be difficult. A test sequence written as a client program may have only limited access to the features of the server class. Likewise, a freestanding test program may not provide a realistic context for the server class. This tip will show you how to execute tests of your server class from within the virtual machine of the running server. This technique will even allow you to execute tests or diagnostic sequences that did not exist when the server was started. Submitted: Dec 06, 1999
|
| Use Java 1.2's Authenticator class |
|
You have probably experienced the frustration of trying to access a URL, not knowing beforehand that a document is password-protected. Now with Java 1.2, you can more easily access URLs requiring the input of a username and password. Submitted: Dec 06, 1999
|
| Use nested classes for better organization |
|
Top-level nested classes (static inner classes) act like top-level classes except they use the enclosing class as a namespace. This tip suggests designing supporting classes as top-level nested classes inside the primary class. This approach makes the coupling between the primary and the supporting classes clear and leads to an implementation that is easier to understand, use, and maintain. Submitted: Dec 06, 1999
|
| Web Server FAQ |
|
The Java Web Server FAQ has the following sections: Installation/Configuration ... commonly encountered installation and configuration problems and questions, Server ... information about server administration, Servlets ... information about servlets, Security ... information about server and servlet security, Reference ... further general links and information related to servers and the World Wide Web. Submitted: Nov 23, 1999
|
| Browser Upgrades |
|
Find out how to upgrade your browser to support JDK 1.1. Submitted: Dec 06, 1999
|
| How to deal with applet resizing in Netscape |
|
This week's tip comes from Noah Green. Noah discusses his solution to the weird behavior of applets when they are resized. Submitted: Dec 06, 1999
|
| How to eliminate debugging problems for RMI-based applications |
|
Debugging RMI-based programs - a painful chore - can be made vastly easier through the use of an in-process server mechanism that allows us to use any JDK 1.1-compatible debugger to develop RMI-based client/server code. This tip shows you how! Submitted: Dec 06, 1999
|
| How to use Visual J++ with the JDK 1.1 beta |
|
Here's a step-by-step guide to using the JDK 1.1 beta with Visual J++. Submitted: Dec 06, 1999
|
| Implementing a timeout feature for the JDK 1.0.2 DatagramSocket |
|
How to time and unblock the receiving of a datagram packet. Submitted: Dec 06, 1999
|
| Improve your applet's download performance using Navigator's Java console |
|
Here's how to optimize your zip file components to achieve quicker applet startup. Submitted: Dec 06, 1999
|
| JDK 1.0.2 Source FAQ |
|
Questions about obtaining the source for our JDK 1.0.2 release. Submitted: Nov 16, 1999
|
| Licensing FAQ |
|
Questions concerning licensing, trademark, and copyright information. Submitted: Nov 16, 1999
|
| Management API |
|
JavaTM Management Extention (JMX) frequently asked questions. Submitted: Nov 23, 1999
|
| Recycle broken objects in resource pools |
|
Many distributed (and some local) Java systems use resource pooling to improve performance. Resource pools may also be used when object resources are scarce and objects need to be shared between a number of clients. In this article, Philip and Nigel examine some of the issues involved in using resource pools and develop the recycler idiom, which is used to manage broken complex resources in an object pool. Using recyclers can improve the longevity and performance of Java server systems, for example, where robustness is a key design issue. Submitted: Dec 06, 1999
|
| Security FAQ |
|
Questions concerning security features in Java and in Java-enabled browsers, such as Netscape 2.0 and the JDK applet viewer. Submitted: Nov 16, 1999
|
| So what browser is this, anyway? |
|
The Java runtime environment your code runs in holds many secrets - not the least of which is the name of the browser currently running your applet. Find out how to unlock the secrets of the runtime with this simple tip. Submitted: Dec 06, 1999
|
| Speed and portability |
|
How to use native methods without restricting class usability. Submitted: Dec 06, 1999
|
| The structures FAQ |
|
The Frequently Asked Questions page for the structures package. Submitted: Nov 24, 1999
|
| Type safe constants in C++ and Java |
|
Let your compiler check that constant values passed as parameters are valid. Submitted: Dec 06, 1999
|
| Use archive files to speed up applet loading |
|
Crank up the perceived performance of your applet by making it load faster: This tip shows you how to create an archive containing all of your class files so that Netscape-browser users can download your applet in record time! Submitted: Dec 06, 1999
|
| Work around a major performance bug in JDK 1.2 Beta 3 for Windows NT/95 |
|
Sun's JDK 1.2 Beta 3 contains a bug whereby every font in the Windows font directory is read into memory at the beginning of each JVM execution. This tip shows you how to work around this problem so you can do useful work with1.2B3. Submitted: Dec 06, 1999
|
| Write a custom security manager that gathers execution information |
|
You can trace the origin of a method call using a custom SecurityManager class: In the process of debugging a Java program, at times you have probably found yourself wishing that a method could figure out the class that was calling it... The SecurityManager class contains a handy method that returns the class context of the current method call. In other words, it gives you an array of Class objects that represent the classes involved in making the current method call. Submitted: Dec 06, 1999
|
|