|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectBreezySwing.Format
public class Format
The class Format contains methods to format data that are left-justified, right-justified, or centered within a given number of columns.
Constructor Summary | |
---|---|
Format()
|
Method Summary | |
---|---|
static java.lang.String |
justify(char leftRight,
char ch,
int width)
Converts a character to a string and returns it formatted formatted according to the justification type and the specified width. |
static java.lang.String |
justify(char leftRight,
double x,
int width,
int precision)
Converts a double to a string and returns it formatted according to the justification type and the specified width and precision. |
static java.lang.String |
justify(char leftRight,
long x,
int width)
Converts a long to a string and returns it formatted formatted according to the justification type and the specified width. |
static java.lang.String |
justify(char leftRight,
java.lang.String str,
int width)
|
static void |
testJustify()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Format()
Method Detail |
---|
public static java.lang.String justify(char leftRight, java.lang.String str, int width)
public static java.lang.String justify(char leftRight, char ch, int width)
leftRight
- the type of justification ('l', 'c', or 'r').ch
- the character to be formatted.width
- the number of columns in which the character is placed.public static java.lang.String justify(char leftRight, long x, int width)
leftRight
- the type of justification ('l', 'c', or 'r').x
- the long integer to be formatted.width
- the number of columns in which the integer is placed.public static java.lang.String justify(char leftRight, double x, int width, int precision)
leftRight
- the type of justification ('l', 'c', or 'r').x
- the number to be formatted.width
- the number of columns in which the number is placed.precision
- the number of places of precision retained in the formatted number.
Examples:
String fourPlaces = Format.justify('r', 3.1416, 7, 4); String threePlaces = Format.justify('r', 3.1416, 7, 3); String twoPlaces = Format.justify('r', 3.1416, 7, 2); String noPlaces = Format.justify('r', 3.1416, 7, 0); fourPlaces now refers to " 3.1416" threePlaces now refers to " 3.142" twoPlaces now refers to " 3.14" noPlaces now refers to " 3"
public static void testJustify()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |