Sample: Improved Master/Detail Implementation

Demonstration:

  1. public String()
  2. public String(StringBuffer buffer)
  3. public String(String original)
  4. public String(char[] value)
  5. public String(byte[] bytes)
Initializes a newly created String object so that it represents an empty character sequence. Note that use of this constructor is unnecessary since Strings are immutable.
Allocates a new string that contains the sequence of characters currently contained in the string buffer argument. The contents of the string buffer are copied; subsequent modification of the string buffer does not affect the newly created string. Parameters:
Initializes a newly created String object so that it represents the same sequence of characters as the argument; in other words, the newly created string is a copy of the argument string. Unless an explicit copy of original is needed, use of this constructor is unnecessary since Strings are immutable. Parameters:
Allocates a new String so that it represents the sequence of characters currently contained in the character array argument. The contents of the character array are copied; subsequent modification of the character array does not affect the newly created string. Parameters:
  • char[] value: the initial value of the string.
Constructs a new String by decoding the specified array of bytes using the platform's default charset. The length of the new String is a function of the charset, and hence may not be equal to the length of the byte array.

The behavior of this constructor when the given bytes are not valid in the default charset is unspecified. The java.nio.charset.CharsetDecoder class should be used when more control over the decoding process is required.

Parameters:
  • byte[] bytes: the bytes to be decoded into characters

Description:

The last master/detail has a slight flaw. Unselected items are hidden and selected items are shown. The CSS 'display' property is used, which does the right thing: it removes hidden elements from the flow so that they don't take up any space. However, the selected/shown element has a unique height, which is a function of the amount of content within it. So toggling items causes content below this feature to move up or down.

The main remedy to this problem is to use CSS positioning. We can assign a fixed height to the block containing all the descriptions and position all the blocks at the same location (since only one will ever be visible at any one time). You'll notice that the text below the feature is unaffected by any dynamic behavior.


References

[tbd]: javadocs - methods listing with method details. others?