|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container javax.swing.JComponent javax.swing.JComboBox net.mariottini.swing.JColorComboBox
public final class JColorComboBox
A combo box that lets the user choose a color.
The appaerance of the combo box is fully customizable:
It can show colored lines, rectangles or text:
Line | Rect | Text | |
---|---|---|---|
Closed: | |||
Open: |
Line | Rect |
---|---|
Copyright © 2006, 2007 Roberto Mariottini. All rights reserved. Permission is granted to anyone to use this software in source and binary forms for any purpose, with or without modification, including commercial applications, and to alter it and redistribute it freely, provided that the following conditions are met: o Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. o The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. o Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JComboBox |
---|
JComboBox.KeySelectionManager |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Field Summary | |
---|---|
static int |
LINE
Show the color with a colored line. |
static int |
RECT
Show the color with a colored rectangle. |
static int |
TEXT_ONLY
Show the color with a colored string. |
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 | |
---|---|
JColorComboBox(int type)
Create a color combo box of the specified type. |
|
JColorComboBox(int type,
boolean showText)
Create a color combo box of the specified type, optionally showing also colors names. |
|
JColorComboBox(int type,
Color[] colors)
Create a color combo box of the specified type, offering the specified colors. |
|
JColorComboBox(int type,
Color[] colors,
String[] colorNames)
Create a color combo box of the specified type, offering the specified colors and color names. |
Method Summary | |
---|---|
int |
getColorThickness()
Returns the current color line thickness/rectangle height. |
int |
getColorWidth()
Returns the width of the color line/rectangle. |
int |
getItemHeight()
Returns the current height of the combo box list item. |
Color |
getSelectedColor()
Returns the selected color. |
boolean |
getShowText()
Returns the text showing status. |
int |
getType()
Returns the type of this combo box. |
void |
setColorThickness(int thickness)
Set the thickness of the color line (if type is LINE )
or the height of the color rectangle (if type is RECT ). |
void |
setColorWidth(int width)
Sets the width of the color line/rectangle. |
void |
setFont(Font font)
Sets the font to use for this combo box. |
void |
setItemHeight(int height)
Sets the height of the combo box list item. |
void |
setSelectedColor(Color color)
Select a color. |
void |
setSelectedItem(Object color)
Select a color. |
void |
setShowText(boolean showText)
Call this function to enable/disable the showing of colors names. |
void |
setType(int type)
Set this combo box of the specified type. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int LINE
public static final int RECT
public static final int TEXT_ONLY
Constructor Detail |
---|
public JColorComboBox(int type)
Color
. Only graphics
(or only text if type is TEXT_ONLY) is shown.
type
- one of LINE
, RECT
or TEXT_ONLY
.public JColorComboBox(int type, boolean showText)
Color
.
type
- one of LINE
, RECT
or TEXT_ONLY
.showText
- true to show color names also, false to show only color
graphics (if type is TEXT_ONLY then this is assumed to be true).public JColorComboBox(int type, Color[] colors)
type
- one of LINE
or RECT
(TEXT_ONLY
is invalid and ignored).colors
- the colors used to fill the combo box.public JColorComboBox(int type, Color[] colors, String[] colorNames)
type
- one of LINE
, RECT
or TEXT_ONLY
.colors
- the colors used to fill the combo box.colorNames
- the color names to use.Method Detail |
---|
public void setShowText(boolean showText)
showText
- true to show color names, false to show only color
graphics (if the type is TEXT_ONLY then this is assumed to be true).getShowText()
public boolean getShowText()
setShowText(boolean)
public void setType(int type)
type
- one of LINE
, RECT
or TEXT_ONLY
.public int getType()
LINE
, RECT
or TEXT_ONLY
.setType(int)
public void setColorThickness(int thickness)
LINE
)
or the height of the color rectangle (if type is RECT
).
The line thickness can't be less than one, and the retangle height
also has an inferior limit. Calling this function will reset the item height.
thickness
- the line thickness or the rectangle height.setItemHeight(int)
public int getColorThickness()
setColorThickness(int)
public void setItemHeight(int height)
height
- the list item heightpublic int getItemHeight()
setItemHeight(int)
public void setColorWidth(int width)
width
- the color line/rectangle width.public int getColorWidth()
setColorWidth(int)
public void setFont(Font font)
setFont
in class JComponent
font
- the font to use to render textsetShowText(boolean)
public Color getSelectedColor()
public void setSelectedColor(Color color)
color
- the color to select. If the color is not present in the color
list, this function has no effectpublic void setSelectedItem(Object color)
setSelectedItem
in class JComboBox
color
- the color to select. If the color is not present in the color
list, this function has no effectsetSelectedColor(java.awt.Color)
|
|||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |