| javax.swing.JComponent com.izforge.izpack.util.MultiLineLabel
MultiLineLabel | public class MultiLineLabel extends JComponent (Code) | |
MultiLineLabel may be used in place of javax.swing.JLabel.
This class implements a component that is capable of displaying multiple lines of text. Line
breaks are inserted automatically whenever a line of text extends beyond the predefined maximum
line length. Line breaks will only be inserted between words, except where a single word is
longer than the maximum line length. Line breaks may be forced at any location in the text by
inserting a newline (\n). White space that is not valuable (i.e. is placed at the beginning of a
new line or at the very beginning or end of the text) is removed.
Note: you can set the maximum width of the label either through one of the constructors
or you can call setMaxWidth() explicitly. If this is not set,
MultiLineLabel will derive its width from the parent component.
version: 0.0.1 / 05-15-97 version: 1.0 / 04-13-02 author: Elmar Grom |
Constructor Summary | |
public | MultiLineLabel(String text, int horMargin, int vertMargin, int maxWidth, int justify) | public | MultiLineLabel(String label, int marginWidth, int marginHeight) Constructor using default max-width and alignment. | public | MultiLineLabel(String label, int alignment) Constructor using default max-width, and margin. | public | MultiLineLabel(String label) Constructor using default max-width, alignment, and margin. |
Method Summary | |
public void | addNotify() This method is called by the system after this object is first created. | int | breakWord(String word, FontMetrics fm) This method scans the input string until the max allowed width is reached. | public int | getAlignment() | public int | getMarginHeight() | public int | getMarginWidth() | public Dimension | getMinimumSize() This method is typically used by the layout manager, it reports the absolute minimum space
required to display the entire label. | int | getPosition(String target, int start, char[] source, int mode) This method searches the target string for occurences of any of the characters in the source
string. | public Dimension | getPreferredSize() This method is typically used by the layout manager, it reports the necessary space to
display the label comfortably. | protected void | measure() This method finds the font size, each line width and the widest line. | public void | paint(Graphics graphics) This method draws the label. | public void | setBounds(int x, int y, int width, int height) Moves and resizes this component. | public void | setColor(Color color) | public void | setFont(Font font) | public void | setJustify(int alignment) | public void | setMarginHeight(int margin) | public void | setMarginWidth(int margin) | public void | setMaxWidth(int width) | public void | setText(String labelText) |
CENTER | final public static int CENTER(Code) | | |
DEFAULT_ALIGN | final public static int DEFAULT_ALIGN(Code) | | |
DEFAULT_MARGIN | final public static int DEFAULT_MARGIN(Code) | | |
LEAST_ALLOWED | final public static int LEAST_ALLOWED(Code) | | |
LEFT | final public static int LEFT(Code) | | |
RIGHT | final public static int RIGHT(Code) | | |
alignment | protected int alignment(Code) | | |
lineAscent | protected int lineAscent(Code) | | |
lineDescent | protected int lineDescent(Code) | | |
lineHeight | protected int lineHeight(Code) | | |
lineWidth | protected int[] lineWidth(Code) | | |
marginHeight | protected int marginHeight(Code) | | |
marginWidth | protected int marginWidth(Code) | | |
maxWidth | protected int maxWidth(Code) | | |
numLines | protected int numLines(Code) | | |
MultiLineLabel | public MultiLineLabel(String text, int horMargin, int vertMargin, int maxWidth, int justify)(Code) | | Constructor
Parameters: text - the text to be displayed Parameters: horMargin - the horizontal margin for the label Parameters: vertMargin - the vertical margin for the label Parameters: maxWidth - the maximum allowed width of the text Parameters: justify - the text alignment for the label |
MultiLineLabel | public MultiLineLabel(String label, int marginWidth, int marginHeight)(Code) | | Constructor using default max-width and alignment.
Parameters: label - the text to be displayed Parameters: marginWidth - the horizontal margin for the label Parameters: marginHeight - the vertical margin for the label |
MultiLineLabel | public MultiLineLabel(String label, int alignment)(Code) | | Constructor using default max-width, and margin.
Parameters: label - the text to be displayed Parameters: alignment - the text alignment for the label |
MultiLineLabel | public MultiLineLabel(String label)(Code) | | Constructor using default max-width, alignment, and margin.
Parameters: label - the text to be displayed |
addNotify | public void addNotify()(Code) | | This method is called by the system after this object is first created.
|
breakWord | int breakWord(String word, FontMetrics fm)(Code) | | This method scans the input string until the max allowed width is reached. The return value
indicates the position just before this happens.
position character position just before the string is too long Parameters: word - word to break |
getAlignment | public int getAlignment()(Code) | | This method may be used to retrieve the text alignment for the label
alignment the text alignment currently in use for the label |
getMarginHeight | public int getMarginHeight()(Code) | | This method may be used to retrieve the vertical margin for the label
marginHeight the margin currently in use on the top and bottom of the label |
getMarginWidth | public int getMarginWidth()(Code) | | This method may be used to retrieve the horizontal margin for the label
marginWidth the margin currently in use to the left and right of the label |
getMinimumSize | public Dimension getMinimumSize()(Code) | | This method is typically used by the layout manager, it reports the absolute minimum space
required to display the entire label.
|
getPosition | int getPosition(String target, int start, char[] source, int mode)(Code) | | This method searches the target string for occurences of any of the characters in the source
string. The return value is the position of the first hit. Based on the mode parameter the
hit position is either the position where any of the source characters first was found or the
first position where none of the source characters where found.
position of the first occurence Parameters: target - the text to be searched Parameters: start - the start position for the search Parameters: source - the list of characters to be searched for Parameters: mode - the search mode FOUND = reports first found NOT_FOUND = reports first not found |
getPreferredSize | public Dimension getPreferredSize()(Code) | | This method is typically used by the layout manager, it reports the necessary space to
display the label comfortably.
|
measure | protected void measure()(Code) | | This method finds the font size, each line width and the widest line.
|
paint | public void paint(Graphics graphics)(Code) | | This method draws the label.
Parameters: graphics - the device context |
setBounds | public void setBounds(int x, int y, int width, int height)(Code) | | Moves and resizes this component. The new location of the top-left corner is specified by
x and y , and the new size is specified by width
and height .
Parameters: x - The new x-coordinate of this component. Parameters: y - The new y-coordinate of this component. Parameters: width - The new width of this component. Parameters: height - The new height of this component. |
setColor | public void setColor(Color color)(Code) | | This method may be used to set the color in which the text should be drawn
Parameters: color - the text color |
setFont | public void setFont(Font font)(Code) | | This method may be used to set the font that should be used to draw the label
Parameters: font - font to be used within the label |
setJustify | public void setJustify(int alignment)(Code) | | This method may be used to set the text alignment for the label
Parameters: alignment - the alignment, possible values are LEFT, CENTER, RIGHT |
setMarginHeight | public void setMarginHeight(int margin)(Code) | | This method may be used to set the vertical margin for the label
Parameters: margin - the margin on the top and bottom of the label |
setMarginWidth | public void setMarginWidth(int margin)(Code) | | This method may be used to set the horizontal margin
Parameters: margin - the margin to the left and to the right of the label |
setMaxWidth | public void setMaxWidth(int width)(Code) | | This method may be used to set the max allowed line width
Parameters: width - the max allowed line width in pixels |
setText | public void setText(String labelText)(Code) | | This method may be used to set the label text
Parameters: labelText - the text to be displayed |
Methods inherited from javax.swing.JComponent | public void addAncestorListener(AncestorListener listener)(Code)(Java Doc) public void addNotify()(Code)(Java Doc) public synchronized void addVetoableChangeListener(VetoableChangeListener listener)(Code)(Java Doc) public void computeVisibleRect(Rectangle visibleRect)(Code)(Java Doc) public boolean contains(int x, int y)(Code)(Java Doc) public JToolTip createToolTip()(Code)(Java Doc) public void disable()(Code)(Java Doc) public void enable()(Code)(Java Doc) public void firePropertyChange(String propertyName, boolean oldValue, boolean newValue)(Code)(Java Doc) public void firePropertyChange(String propertyName, int oldValue, int newValue)(Code)(Java Doc) public void firePropertyChange(String propertyName, char oldValue, char newValue)(Code)(Java Doc) protected void fireVetoableChange(String propertyName, Object oldValue, Object newValue) throws java.beans.PropertyVetoException(Code)(Java Doc) public AccessibleContext getAccessibleContext()(Code)(Java Doc) public ActionListener getActionForKeyStroke(KeyStroke aKeyStroke)(Code)(Java Doc) final public ActionMap getActionMap()(Code)(Java Doc) public float getAlignmentX()(Code)(Java Doc) public float getAlignmentY()(Code)(Java Doc) public AncestorListener[] getAncestorListeners()(Code)(Java Doc) public boolean getAutoscrolls()(Code)(Java Doc) public int getBaseline(int width, int height)(Code)(Java Doc) public BaselineResizeBehavior getBaselineResizeBehavior()(Code)(Java Doc) public Border getBorder()(Code)(Java Doc) public Rectangle getBounds(Rectangle rv)(Code)(Java Doc) final public Object getClientProperty(Object key)(Code)(Java Doc) protected Graphics getComponentGraphics(Graphics g)(Code)(Java Doc) public JPopupMenu getComponentPopupMenu()(Code)(Java Doc) public int getConditionForKeyStroke(KeyStroke aKeyStroke)(Code)(Java Doc) public int getDebugGraphicsOptions()(Code)(Java Doc) public static Locale getDefaultLocale()(Code)(Java Doc) public FontMetrics getFontMetrics(Font font)(Code)(Java Doc) public Graphics getGraphics()(Code)(Java Doc) public int getHeight()(Code)(Java Doc) public boolean getInheritsPopupMenu()(Code)(Java Doc) final public InputMap getInputMap(int condition)(Code)(Java Doc) final public InputMap getInputMap()(Code)(Java Doc) public InputVerifier getInputVerifier()(Code)(Java Doc) public Insets getInsets()(Code)(Java Doc) public Insets getInsets(Insets insets)(Code)(Java Doc) public T[] getListeners(Class<T> listenerType)(Code)(Java Doc) public Point getLocation(Point rv)(Code)(Java Doc) public Dimension getMaximumSize()(Code)(Java Doc) public Dimension getMinimumSize()(Code)(Java Doc) public Component getNextFocusableComponent()(Code)(Java Doc) public Point getPopupLocation(MouseEvent event)(Code)(Java Doc) public Dimension getPreferredSize()(Code)(Java Doc) public KeyStroke[] getRegisteredKeyStrokes()(Code)(Java Doc) public JRootPane getRootPane()(Code)(Java Doc) public Dimension getSize(Dimension rv)(Code)(Java Doc) public Point getToolTipLocation(MouseEvent event)(Code)(Java Doc) public String getToolTipText()(Code)(Java Doc) public String getToolTipText(MouseEvent event)(Code)(Java Doc) public Container getTopLevelAncestor()(Code)(Java Doc) public TransferHandler getTransferHandler()(Code)(Java Doc) public String getUIClassID()(Code)(Java Doc) public boolean getVerifyInputWhenFocusTarget()(Code)(Java Doc) public synchronized VetoableChangeListener[] getVetoableChangeListeners()(Code)(Java Doc) public Rectangle getVisibleRect()(Code)(Java Doc) public int getWidth()(Code)(Java Doc) public int getX()(Code)(Java Doc) public int getY()(Code)(Java Doc) public void grabFocus()(Code)(Java Doc) public boolean isDoubleBuffered()(Code)(Java Doc) public static boolean isLightweightComponent(Component c)(Code)(Java Doc) public boolean isManagingFocus()(Code)(Java Doc) public boolean isOpaque()(Code)(Java Doc) public boolean isOptimizedDrawingEnabled()(Code)(Java Doc) final public boolean isPaintingForPrint()(Code)(Java Doc) public boolean isPaintingTile()(Code)(Java Doc) public boolean isRequestFocusEnabled()(Code)(Java Doc) public boolean isValidateRoot()(Code)(Java Doc) public void paint(Graphics g)(Code)(Java Doc) protected void paintBorder(Graphics g)(Code)(Java Doc) protected void paintChildren(Graphics g)(Code)(Java Doc) protected void paintComponent(Graphics g)(Code)(Java Doc) public void paintImmediately(int x, int y, int w, int h)(Code)(Java Doc) public void paintImmediately(Rectangle r)(Code)(Java Doc) protected String paramString()(Code)(Java Doc) public void print(Graphics g)(Code)(Java Doc) public void printAll(Graphics g)(Code)(Java Doc) protected void printBorder(Graphics g)(Code)(Java Doc) protected void printChildren(Graphics g)(Code)(Java Doc) protected void printComponent(Graphics g)(Code)(Java Doc) protected void processComponentKeyEvent(KeyEvent e)(Code)(Java Doc) protected boolean processKeyBinding(KeyStroke ks, KeyEvent e, int condition, boolean pressed)(Code)(Java Doc) protected void processKeyEvent(KeyEvent e)(Code)(Java Doc) protected void processMouseEvent(MouseEvent e)(Code)(Java Doc) protected void processMouseMotionEvent(MouseEvent e)(Code)(Java Doc) final public void putClientProperty(Object key, Object value)(Code)(Java Doc) public void registerKeyboardAction(ActionListener anAction, String aCommand, KeyStroke aKeyStroke, int aCondition)(Code)(Java Doc) public void registerKeyboardAction(ActionListener anAction, KeyStroke aKeyStroke, int aCondition)(Code)(Java Doc) public void removeAncestorListener(AncestorListener listener)(Code)(Java Doc) public void removeNotify()(Code)(Java Doc) public synchronized void removeVetoableChangeListener(VetoableChangeListener listener)(Code)(Java Doc) public void repaint(long tm, int x, int y, int width, int height)(Code)(Java Doc) public void repaint(Rectangle r)(Code)(Java Doc) public boolean requestDefaultFocus()(Code)(Java Doc) public void requestFocus()(Code)(Java Doc) public boolean requestFocus(boolean temporary)(Code)(Java Doc) public boolean requestFocusInWindow()(Code)(Java Doc) protected boolean requestFocusInWindow(boolean temporary)(Code)(Java Doc) public void resetKeyboardActions()(Code)(Java Doc) public void reshape(int x, int y, int w, int h)(Code)(Java Doc) public void revalidate()(Code)(Java Doc) public void scrollRectToVisible(Rectangle aRect)(Code)(Java Doc) final public void setActionMap(ActionMap am)(Code)(Java Doc) public void setAlignmentX(float alignmentX)(Code)(Java Doc) public void setAlignmentY(float alignmentY)(Code)(Java Doc) public void setAutoscrolls(boolean autoscrolls)(Code)(Java Doc) public void setBackground(Color bg)(Code)(Java Doc) public void setBorder(Border border)(Code)(Java Doc) public void setComponentPopupMenu(JPopupMenu popup)(Code)(Java Doc) public void setDebugGraphicsOptions(int debugOptions)(Code)(Java Doc) public static void setDefaultLocale(Locale l)(Code)(Java Doc) public void setDoubleBuffered(boolean aFlag)(Code)(Java Doc) public void setEnabled(boolean enabled)(Code)(Java Doc) public void setFocusTraversalKeys(int id, Set<? extends AWTKeyStroke> keystrokes)(Code)(Java Doc) public void setFont(Font font)(Code)(Java Doc) public void setForeground(Color fg)(Code)(Java Doc) public void setInheritsPopupMenu(boolean value)(Code)(Java Doc) final public void setInputMap(int condition, InputMap map)(Code)(Java Doc) public void setInputVerifier(InputVerifier inputVerifier)(Code)(Java Doc) public void setMaximumSize(Dimension maximumSize)(Code)(Java Doc) public void setMinimumSize(Dimension minimumSize)(Code)(Java Doc) public void setNextFocusableComponent(Component aComponent)(Code)(Java Doc) public void setOpaque(boolean isOpaque)(Code)(Java Doc) public void setPreferredSize(Dimension preferredSize)(Code)(Java Doc) public void setRequestFocusEnabled(boolean requestFocusEnabled)(Code)(Java Doc) public void setToolTipText(String text)(Code)(Java Doc) public void setTransferHandler(TransferHandler newHandler)(Code)(Java Doc) protected void setUI(ComponentUI newUI)(Code)(Java Doc) public void setVerifyInputWhenFocusTarget(boolean verifyInputWhenFocusTarget)(Code)(Java Doc) public void setVisible(boolean aFlag)(Code)(Java Doc) public void unregisterKeyboardAction(KeyStroke aKeyStroke)(Code)(Java Doc) public void update(Graphics g)(Code)(Java Doc) public void updateUI()(Code)(Java Doc)
|
|
|