|
LEONARDI Application Composer - 8.9.0.40 by W4 S.A. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
leon.view.win.swing.component.LyJMultiLineLabel
public class LyJMultiLineLabel
This example is from the book _Java in a Nutshell_ by David Flanagan.
Written by David Flanagan.
Copyright (c) 1998 O'Reilly & Associates.
You may study, use, modify, and distribute this example for any purpose. This example is provided
WITHOUT WARRANTY either expressed or implied.
Tilman 05/07/96: added a maxChars parameter to specify a maximum line length. If any of the lines is longer, it will be cut at the last space character before maxChars, until it fits into maxChars. Set maxChars to -1 if you don't care.
Van 07/30/96: added the removal of backslash-r from the multi-line string that might have been added by strings in Windows (which expect newlines to be indicated by backslash-r backslash-n)
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
javax.swing.JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Component |
---|
java.awt.Component.BaselineResizeBehavior |
Field Summary | |
---|---|
static java.lang.String |
__VERSION
|
static int |
CENTER
Center alignment constant. |
static int |
LEFT
Left alignment constant. |
static int |
RIGHT
Right alignment constant. |
Fields inherited from class javax.swing.JComponent |
---|
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
LyJMultiLineLabel()
Creates a new multiline label object from the specified attributes. |
|
LyJMultiLineLabel(java.lang.String label)
Creates a new multiline label object from the specified attributes. |
|
LyJMultiLineLabel(java.lang.String label,
int maxChars)
Creates a new multiline label object from the specified attributes. |
|
LyJMultiLineLabel(java.lang.String label,
int maxChars,
int alignment)
Creates a new multiline label object from the specified attributes. |
|
LyJMultiLineLabel(java.lang.String label,
int maxChars,
int margin_width,
int margin_height)
Creates a new multiline label object from the specified attributes. |
|
LyJMultiLineLabel(java.lang.String label,
int maxChars,
int margin_width,
int margin_height,
int alignment)
Creates a new multiline label object from the specified attributes. |
Method Summary | |
---|---|
void |
addNotify()
Invoked after our Canvas is first created but before it can actually be displayed. |
int |
getAlignment()
Gets the alignment policy of this component. |
java.lang.String |
getLabel()
Gets the label of this component. |
int |
getMarginHeight()
Gets the vertical margin for this component. |
int |
getMarginWidth()
Gets the horizontal margin for this component. |
java.awt.Dimension |
getMinimumSize()
(non-Javadoc). |
int |
getNumLines()
Returns the number of lines used to display label. |
java.awt.Dimension |
getPreferredSize()
(non-Javadoc). |
void |
paintComponent(java.awt.Graphics g)
Draws the label (applets use the same method). |
void |
setAlignment(int a)
Sets the alignment policy of this label. |
void |
setBigFont(java.awt.Font f)
Sets the biggest font for this component. |
void |
setFont(java.awt.Font f)
(non-Javadoc). |
void |
setForeground(java.awt.Color c)
(non-Javadoc). |
void |
setLabel(java.lang.String label)
Sets the label of this component. |
void |
setMarginHeight(int mh)
Sets the vertical margins of this component. |
void |
setMarginWidth(int mw)
Sets the horizontal margins of this component. |
void |
setMaxWidth(int maxWidth)
Sets the maximum number of characters per line |
void |
setMinimumWidth(int minimumWidth)
Set the minimum width of this component. |
void |
setNCols(int nCols)
Sets the number of columns, or -1 if automatic calculation. |
void |
setNRows(int nRows)
Sets the number of rows, or -1 if automatic calculation. |
Methods inherited from class javax.swing.JPanel |
---|
getAccessibleContext, getUI, getUIClassID, setUI, updateUI |
Methods inherited from class javax.swing.JComponent |
---|
addAncestorListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
Methods inherited from class java.awt.Container |
---|
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate |
Methods inherited from class java.awt.Component |
---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String __VERSION
public static final int LEFT
public static final int CENTER
public static final int RIGHT
Constructor Detail |
---|
public LyJMultiLineLabel(java.lang.String label, int maxChars, int margin_width, int margin_height, int alignment)
label
- the multiline labelmaxChars
- the maximum number of characters per linemargin_width
- the left and right marginsmargin_height
- the top and bottom marginsalignment
- the alignment of the textpublic LyJMultiLineLabel(java.lang.String label, int maxChars, int margin_width, int margin_height)
label
- the multiline labelmaxChars
- the maximum number of characters per linemargin_width
- the left and right marginsmargin_height
- the top and bottom marginspublic LyJMultiLineLabel(java.lang.String label, int maxChars, int alignment)
label
- the multiline labelmaxChars
- the maximum number of characters per linealignment
- the alignment of the textpublic LyJMultiLineLabel(java.lang.String label, int maxChars)
label
- the multiline labelmaxChars
- the maximum number of characters per linepublic LyJMultiLineLabel(java.lang.String label)
label
- the multiline labelpublic LyJMultiLineLabel()
Method Detail |
---|
public void setLabel(java.lang.String label)
label
- the new labelgetLabel()
public java.lang.String getLabel()
setLabel(String)
public void setBigFont(java.awt.Font f)
f
- the font that is the biggest for the measurement computationspublic void setFont(java.awt.Font f)
setFont
in class javax.swing.JComponent
Component.setFont(java.awt.Font)
public void setForeground(java.awt.Color c)
setForeground
in class javax.swing.JComponent
Component.setForeground(java.awt.Color)
public void setAlignment(int a)
public void setMarginWidth(int mw)
mw
- the margin width, in pixelsgetMarginWidth()
public void setMarginHeight(int mh)
mh
- the margin height, in pixelsgetMarginHeight()
public int getAlignment()
setAlignment(int)
public int getMarginWidth()
setMarginWidth(int)
public int getMarginHeight()
setMarginHeight(int)
public void addNotify()
JComponent.addNotify()
, this component font metrics is set and the measure()
method can be called to figure out how big the label is.
addNotify
in class javax.swing.JComponent
Component.addNotify()
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class javax.swing.JComponent
Component.getPreferredSize()
public void setMinimumWidth(int minimumWidth)
minimumWidth
- the new minimum width of the component (a negative value means that
there is no minimum width).public java.awt.Dimension getMinimumSize()
getMinimumSize
in class javax.swing.JComponent
Component.getMinimumSize()
public int getNumLines()
public void paintComponent(java.awt.Graphics g)
paintComponent
in class javax.swing.JComponent
JComponent.paintComponent(java.awt.Graphics)
public void setNCols(int nCols)
nCols
- the number of columnspublic void setNRows(int nRows)
nRows
- the number of rowspublic void setMaxWidth(int maxWidth)
maxWidth
- the maximum number of characters per line
|
(c) January 2013 - W4 S.A. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |