Java Swing - O Reilly set reaches a threshold (Top ten web hosting)

Java Swing - O Reilly set reaches a threshold (more than 9 attributes, by default), this method returns the original set (if it is mutable) with the specified attribute added. If the original set is immutable, a new mutable set (a SimpleAttributeSet) is returned. public synchronized AttributeSet addAttributes(AttributeSet old, AttributeSet attr) Adds the second set of attributes to the first and returns a new set. The same rules about returning new sets or reusing the original set apply, as for the previous method. public synchronized AttributeSet removeAttribute(AttributeSet old, Object name) Removes the specified attribute and returns a new set. public synchronized AttributeSet removeAttributes(AttributeSet old, AttributeSet attrs) Removes the second set of attributes from the first. public synchronized AttributeSet removeAttributes(AttributeSet old, Enumeration names) Removes the specified attributes from the given set. names should contain the keys for the attributes to be removed. public synchronized void reclaim(AttributeSet a) Tells the context that an attribute set is no longer being used, allowing it to be removed from the context. The following example shows how StyleContext can be used to share AttributeSets. Whenever the attributes in two small sets are equal, the same set is returned. Once the sets get too large, it is more efficient to use different sets, since matching all attributes in a large set would become too time consuming. // StyleContextExample.java// import javax.swing.text.*; import java.awt.*; public class StyleContextExample { public static void main(String[] args) { StyleContext con = new StyleContext(); // Create two different attribute sets . . . SimpleAttributeSet one = new SimpleAttributeSet(); SimpleAttributeSet two = new SimpleAttributeSet(); System.out.println(”Refs are initially to the same object? ” + (one == two)); // prints false // Add the same things to each set . . . AttributeSet oneA=con.addAttribute(one, StyleConstants.Bold, Boolean.TRUE); AttributeSet twoA=con.addAttribute(two, StyleConstants.Bold, Boolean.TRUE); System.out.println(”Refs are same after setting the ” + “same value? ” + (oneA == twoA)); // prints true - 707
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

Leave a Reply