Skip to main content
View by: Most Recent | Topic | Community | Webloggers   
Monthly Archives:    

Blogs by topic J2SE and user malenkov

• Accessibility • Ajax • Blogging • Business • Community 
• Databases • Deployment • Distributed • Eclipse • Education 
• EJB • Extreme Programming • Games • GlassFish • Grid 
• GUI • IDE • Instant Messaging • J2EE • J2ME 
• J2SE • Jakarta • JavaFX • JavaOne • Jini 
• JSP • JSR • JXTA • LDAP • Linux 
• Mobility • NetBeans • Open Source • OpenSolaris • OSGi 
• P2P • Patterns • Performance • Porting • Programming 
• Research • RMI • RSS Feeds • Search • Security 
• Servlets • Struts • Swing • Testing • Tools 
• Virtual Machine • Web Applications • Web Design • Web Development Tools • Web Services and XML 


Caching of an empty array is a well-known pattern to improve performance. However, it is difficult to use it in generified classes. Out of curiosity, I created a custom implementation of the array creation method based on Array.newInstance. To cache empty arrays, I use synchronized WeakHashMap, which maps any given component type to a weak reference to the corresponding empty array. This is not...
on Dec 7, 2009
The Preferences API can be used by applications along with the installed security manager that enables using the preferences permission. However, WebStart-based applications cannot permit preferences only. You can permit all or deny all by using a jnlp-file. So, how to store user preferences for unsigned applications deployed through Java WebStart? Java provides the Preferences API to store and...
on Apr 21, 2009
I would like to discuss code conventions. In particular, the usage of the this keyword. Recently we have argued with one of my colleagues again. I always use the pattern to access class fields. Whereas he says that I should not differ from everybody else and use this to avoid shadowing only. Let me explain my position on the question. The this keyword is commonly used to access the...
on Apr 13, 2009
A PropertyEditor interface provides support for GUIs to enable editing a property value of a given type. The interface supports a variety of ways to display and update property values. One of these ways is to employ the string representation of a Java code fragment that can be obtained by getJavaInitializationString, the method all standard property editors implement. To test this feature, one...
on Dec 17, 2008
I needed to load the classes from the dt.jar archive on the fly. The path to the archive was generated automatically based on the "java.home" system property. The original idea was to use the <a href="">URLClassLoader</a>, but it could not find classes. I had to write a custom class loader which read an...
on Jul 25, 2008
I would like to discuss some proposed changes in the JColorChooser component. At present, the JColorChooser component contains the following default tabs: * Swatches: the predefined set of colors * HSB: color selection defined by hue, saturation, and brightness using a diagram * RGB: color selection defined by its constituents (Red, Green, and Blue) using a slider My suggestion is to combine the...
on Dec 19, 2007
Correct usage of constrained properties seems still remain unclear for many users. As is the convention in the Java, the IllegalArgumentException is thrown if a method receives illegal arguments which cannot be used to execute the method. However, this approach is not applicable for the set methods, since it is impossible to identify whether all values can be used or not. That is why using the...
on Nov 22, 2007
Lets talk about FeatureDescriptor, the superclass for all other descriptors. It enables to add extra metadata to describe the beans. The builder tool could use such metadata to provide enhanced functionality. You can use the getValue(String) method to retrieve metadata. For example: BeanInfo info = Introspector.getBeanInfo(JLabel.class);Object value = info.getBeanDescriptor().getValue("...
on Oct 4, 2007
The @ConstructorProperties annotation for constructors was introduced in JDK version 6. This annotation shows how the parameters of annotated constructor correspond to object's properties. The following code snippet shows the get methods of the x and y properties: public class Point {    private final int x;    private final int y;    <strong>@...
on Mar 20, 2007
I would like to start a discussion about XMLDecoder improvements. Some requests can be found in RFE 4864117. I don't want to discuss improvements of persistence delegation (XMLEncoder) here. How to read objects Usually the following code is used to read XML file that represents JavaBeans archive: public static Object[] readXML( InputStream stream ) {    List list = new ArrayList...
on Oct 31, 2006
This is a sequel of my first article about Enums encoding. As you may know, Type-Safe Enums were proposed by Joshua Bloch in Effective Java, but they are not supported by XMLEncoder. This article describes how to encode them into XML properly. Let's create a simple Type-Safe Enum with static method to test encoding into XML: import java.beans.XMLEncoder;import;...
on Aug 9, 2006
As you may know, Enums were introduced in Tiger, but they are not supported by XMLEncoder. This article describes how to encode them into XML properly. Let's create a simple Enum with static method to test encoding into XML: import java.beans.XMLEncoder;import;public enum TestEnum {    LEFT, RIGHT;    public static void main( String...
on Aug 7, 2006