|
||||||||||
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.JLabel
bb.gui.JLabel2
public class JLabel2
This subclass of JLabel adds exactly one new bit of functionality to its superclass: it is interested in mouse events.
This class was originally written to enable popup menus to be associated with JLabels. This forum posting provides more discussion.
The fundamental reason why this class needed to be written was because, at present, Swing is designed to not pass mouse events to any lightweight component that does not have at least registered mouse listener, a design flaw that has been reported as a bug but which Sun has yet to fix.
Like typical java gui code, this class is not multithread safe:
it expects to only be called by EventQueue
's dispatch thread
.
Nested Class Summary | |
---|---|
static class |
JLabel2.UnitTest
See the Overview page of the project's javadocs for a general description of this unit test class. |
Nested classes/interfaces inherited from class javax.swing.JLabel |
---|
JLabel.AccessibleJLabel |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
private static long |
serialVersionUID
|
Fields inherited from class javax.swing.JLabel |
---|
labelFor |
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, 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 javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JLabel2()
Creates a JLabel2 instance with with an empty string for the title and a null image. |
|
JLabel2(Icon image)
Creates a JLabel2 instance with the specified image. |
|
JLabel2(Icon image,
int horizontalAlignment)
Creates a JLabel2 instance with the specified image and horizontal alignment. |
|
JLabel2(String text)
Creates a JLabel2 instance with the specified text and a null image. |
|
JLabel2(String text,
Icon icon,
int horizontalAlignment)
Creates a JLabel2 instance with the specified text, image, and horizontal alignment. |
|
JLabel2(String text,
int horizontalAlignment)
Creates a JLabel2 instance with the specified text and horizontal alignment, along with a null image. |
Method Summary |
---|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private static final long serialVersionUID
Constructor Detail |
---|
public JLabel2()
JLabel2
instance with with an empty string for the title and a null image.
The label is aligned against the leading edge of its display area, and centered vertically.
public JLabel2(String text)
JLabel2
instance with the specified text and a null image.
The label is aligned against the leading edge of its display area, and centered vertically.
text
- The text to be displayed by the labelpublic JLabel2(String text, int horizontalAlignment)
JLabel2
instance with the specified text and horizontal alignment, along with a null image.
The label is centered vertically in its display area.
text
- The text to be displayed by the labelhorizontalAlignment
- One of the following constants defined in SwingConstants
:
LEFT
, CENTER
, RIGHT
, LEADING
, or TRAILING
public JLabel2(Icon image)
JLabel2
instance with the specified image.
The label is centered vertically and horizontally in its display area.
image
- The image to be displayed by the labelpublic JLabel2(Icon image, int horizontalAlignment)
JLabel2
instance with the specified image and horizontal alignment.
The label is centered vertically in its display area.
image
- The image to be displayed by the labelhorizontalAlignment
- One of the following constants defined in SwingConstants
:
LEFT
, CENTER
, RIGHT
, LEADING
or, TRAILING
public JLabel2(String text, Icon icon, int horizontalAlignment)
JLabel2
instance with the specified text, image, and horizontal alignment.
The label is centered vertically in its display area.
The text is on the trailing edge of the image.
text
- The text to be displayed by the labelicon
- The image to be displayed by the labelhorizontalAlignment
- One of the following constants defined in SwingConstants
:
LEFT
, CENTER
, RIGHT
, LEADING
, or TRAILING
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |