Batch Text Inserts with JTextPane

Part II of “Faster JTextPane Text Insertion” describes another technique for overcoming some of JTextPane‘s performance limitations when initiatializing large documents with complex styles. The ElementSpec class, defined as part of DefaultStyledDocument, provides a way to batch updates and apply them in bulk. Depending on size and complexity of the document, the speed boost can be significant.

4 January 2004 | GUI, Optimization | No Comments

Why are JTextPane inserts so slow?

Inserting a large amount of styled text into a JTextPane can be painfully slow. Part I of “Faster JTextPane Text Insertion” examines two sources of sluggishness and illustrates a simple solution for one of them. (Part II will describe an additional solution.)

2 January 2004 | GUI, Optimization | No Comments

Squid Corrupts Jar Files?

The open-source Squid web cache can be used to speed up the download of WebStart applications. Several weeks after such a deployment, however, corrupt jar file errors started appearing. “Squid Corrupts Jar Files?” explains the problem and describes the (simple) solution.

14 December 2003 | Hosting | No Comments

Missing Bold and Italic Fonts on Panther

Users of Microsoft Office on Panther (Mac OSX 10.3) may find that bold and italic fonts no longer work in JDK 1.4 applications. “Java Font Problems under Panther” describes a quick fix.

24 November 2003 | GUI | No Comments

Low-Memory Deep Copies

Faster Deep Copies of Java Objects” explains the concept of “deep copies” of Java objects and illustrates a common approach for copying objects using Java Object Serialization. “Low-Memory Deep Copy Technique for Java Objects” presents an alternate technique that trades speed for space.

22 November 2003 | Optimization | No Comments

Setting JTextPane Font and Color

Swing’s JTextPane supports styled text, embedded images and components, and other features not available in the AWT TextArea. However, basic operations like setting the font and color for the text are somewhat more complicated with JTextPane than with TextArea and other simpler text components. “Setting JTextPane Font and Color” illustrates the use of character attributes for setting these text properties.

12 November 2003 | GUI | No Comments

Speeding Up Deep Copies

You can use Java Object Serialization to make deep copies of Java objects, creating distinct copies of an object and all of the objects that it references. “Faster Deep Copies of Java Objects” explains the difference between deep copies and shallow copies (as implemented by the clone method), shows a common approach to using Java Object Serialization for copies, and then provides some simple optimizations to squeeze a bit more speed out of the deep copy process.

8 November 2003 | Optimization | No Comments

DateFormat/SimpleDateFormat Examples

Java’s DateFormat and SimpleDateFormat classes, introduced in Java 1.1, provide a simple way to parse and format dates. “DateFormat and SimpleDateFormat Examples” gives a basic overview of these classes.

4 November 2003 | Basics | No Comments

Vanishing Text Selections

In Java 1.3, opening a menu will temporarily hide selections in Swing text components. The glitch is mostly harmless, but can be disconcerting for users who are, for examples, selecting clipboard operations from a menu. “Fixing Disappearing Text Selections when a Menu is Opened” describes a simple fix for the problem.

3 November 2003 | GUI | No Comments

Before you sign up for a Virtual Dedicated Server…

Virtual Dedicated Servers (or Virtual Private Servers) provide a cost-effective alternative to dedicated servers for many kinds of application deployments. There are, however, some subtle issues with deploying Java applications on these systems. “Deploying Java Apps on a Virtual Dedicated Server” describes some questions you may want to ask before signing up with a VDS hosting service.

1 November 2003 | Hosting | No Comments

Copyright 2003-2016 - Philip Isenhour - All code samples may be freely used under the MIT Open-Source License