jaxx.runtime
Class SwingUtil

java.lang.Object
  extended by jaxx.runtime.JAXXUtil
      extended by jaxx.runtime.SwingUtil

public class SwingUtil
extends JAXXUtil

The runtime swing util class with some nice stuff.

Note : Replace previous class jaxx.runtime.swing.Utils in previous versions.

Since:
1.2
Author:
tchemit

Nested Class Summary
static class SwingUtil.TabbedPaneIterator<O>
          A simple iterator on a JTabbedPane.
 
Field Summary
static String COLOR_PREFIX
           
static String DEFAULT_ICON_PATH
           
static String DEFAULT_ICON_PATH_PROPERTY
           
static String ICON_PREFIX
           
 
Fields inherited from class jaxx.runtime.JAXXUtil
PARENT
 
Constructor Summary
SwingUtil()
           
 
Method Summary
static void addExpandOnClickListener(JTree tree)
          Add a listener of tree selection model to expand a new selected node when it is selected.
static void addExpandOnClickListener(org.jdesktop.swingx.JXTreeTable treeTable)
          Add a listener of tree table selection model to expand a new selected node when it is selected.
static
<V extends JComponent>
org.jdesktop.jxlayer.JXLayer<V>
boxComponentWithJxLayer(V component)
          Box a component in a JXLayer.
static void center(Component parent, Component component)
          Centrer un component graphique au center d'un autre component.
static int computeTableColumnWidth(JTable table, Font font, int columnIndex, String suffix)
           
static ImageIcon createActionIcon(String name)
           
static ImageIcon createI18nIcon(String name)
           
static ImageIcon createIcon(String path)
           
static ImageIcon createImageIcon(String path)
           
static void expandTree(JTree tree)
          Expand all childs of a tree.
static void expandTreeTable(org.jdesktop.swingx.JXTreeTable treeTable)
          Expand all childs of a tree table.
static void fillComboBox(JAXXComboBox combo, Collection<?> data, Object select, boolean firstNull)
          Deprecated. since 1.7.XXX this code is moved to JAXXComboBox
static void fillComboBox(JComboBox combo, Collection<?> data, Object select)
          Fill a combo box model with some datas, and select after all the given object
static void fillList(JList list, Collection<?> data, Object select)
          Fill a list model with some datas, and select after all the given object
static Component findComponentAt(Container cont, int width, int height, int x, int y)
           
static void fixTableColumnWidth(JTable table, int columnIndex, int width)
           
static Component getDeepestObjectAt(Component parent, int x, int y)
          Gets the higest visible component in a ancestor hierarchy at specific x,y coordinates
static
<V extends JComponent>
org.jdesktop.jxlayer.JXLayer<V>
getLayer(V comp)
           
static List<JComponent> getLayeredComponents(JAXXObject object)
           
static
<O extends Container>
O
getParentContainer(Object top, Class<O> clazz)
          Return parent's container corresponding to the Class clazz
static Icon getUIManagerActionIcon(String key)
          retreave for the UIManager the icon prefixed by action.
static Icon getUIManagerIcon(String key)
           
static void initNimbusLoookAndFeel()
          Try to load the Nimbus look and feel.
static boolean isLayered(JComponent comp)
           
static void loadUIConfig(Properties incoming)
          Load the ui.properties file and set in UIManager colors and icons found.
static void loadUIConfig(String defaultUIConfig, String extraUIConfig)
          Load the ui.properties file and set in UIManager colors and icons found.
static Map<String,JComponent> lookingForEditor(Class<?> clazz, Container container)
          recherche les composants portant le meme nom que les champs de la classe clazz.
static TableCellRenderer newBooleanTableCellRenderer(DefaultTableCellRenderer renderer)
           
static TableCellRenderer newDeleteCellRenderer(DefaultTableCellRenderer renderer)
           
static EmptyNumberTableCellRenderer newEmptyNumberTableCellRenderer(TableCellRenderer renderer)
           
static
<E extends Enum<E>>
EnumTableCellRenderer<E>
newEnumTableCellRenderer(TableCellRenderer renderer, Class<E> enumClass)
           
static JLabel newLabel(String text, Object iconKey, int aligment)
           
static Dimension newMaxXDimension()
           
static Dimension newMaxXYDimension()
           
static Dimension newMaxYDimension()
           
static Dimension newMinDimension()
           
static TableCellRenderer newStringTableCellRenderer(DefaultTableCellRenderer renderer, int length, boolean tooltip)
           
static SwingUtil.TabbedPaneIterator<Component> newTabbedPaneIterator(JTabbedPane tabs)
          Iterate the components of a JTabbedPane in natural order.
static void openLink(HyperlinkEvent he)
          Open a link coming from a HyperlinkEvent.
static void openLink(String url)
           
static void setComponentHeight(Component component, int height)
          Set the height of a given component.
static void setComponentWidth(Component component, int width)
          Set the width of the given component
static void setI18nTableHeaderRenderer(JTable table, String... libelles)
           
static void setLayerUI(JComponent comp, org.jdesktop.jxlayer.plaf.LayerUI<JComponent> ui)
           
static void setTableColumnEditor(JTable table, int columnIndex, TableCellEditor editor)
           
static void setTableColumnRenderer(JTable table, int columnIndex, TableCellRenderer editor)
           
static void setText(JTextComponent c, String text)
           
 
Methods inherited from class jaxx.runtime.JAXXUtil
applyDataBinding, applyDataBinding, assignment, assignment, assignment, assignment, assignment, assignment, assignment, assignment, assignment, castList, castMap, checkJAXXContextEntries, checkJAXXContextEntry, decodeCompressedJAXXObjectDescriptor, decodeJAXXObjectDescriptor, destroy, destroy, findJaxxPropertyChangeListener, getDataBindingUpdateListener, getEventListener, getEventListener, getStringValue, initContext, invokeConstructor, newContextEntryDef, newContextEntryDef, newListContextEntryDef, newListContextEntryDef, newMapContextEntryDef, processDataBinding, reloadBinding, reloadBinding, removeDataBinding
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ICON_PATH

public static final String DEFAULT_ICON_PATH
See Also:
Constant Field Values

DEFAULT_ICON_PATH_PROPERTY

public static final String DEFAULT_ICON_PATH_PROPERTY
See Also:
Constant Field Values

ICON_PREFIX

public static final String ICON_PREFIX
See Also:
Constant Field Values

COLOR_PREFIX

public static final String COLOR_PREFIX
See Also:
Constant Field Values
Constructor Detail

SwingUtil

public SwingUtil()
Method Detail

newMinDimension

public static Dimension newMinDimension()

newMaxXDimension

public static Dimension newMaxXDimension()

newMaxYDimension

public static Dimension newMaxYDimension()

newMaxXYDimension

public static Dimension newMaxXYDimension()

setText

public static void setText(JTextComponent c,
                           String text)

fillComboBox

public static void fillComboBox(JComboBox combo,
                                Collection<?> data,
                                Object select)
Fill a combo box model with some datas, and select after all the given object

Parameters:
combo - the combo to fill
data - data ot inject in combo
select - the object to select in combo after reflling his model

fillList

public static void fillList(JList list,
                            Collection<?> data,
                            Object select)
Fill a list model with some datas, and select after all the given object

Parameters:
list - the list to fill
data - data ot inject in combo
select - the object to select in combo after reflling his model

fillComboBox

@Deprecated
public static void fillComboBox(JAXXComboBox combo,
                                           Collection<?> data,
                                           Object select,
                                           boolean firstNull)
Deprecated. since 1.7.XXX this code is moved to JAXXComboBox

TODO move this to JAXXComboBox.

Fill a combo box model with some datas, and select after all the given object

Parameters:
combo - the combo to fill
data - data ot inject in combo
select - the object to select in combo after reflling his model
firstNull - add a first null element

getParentContainer

public static <O extends Container> O getParentContainer(Object top,
                                                         Class<O> clazz)
Return parent's container corresponding to the Class clazz

Type Parameters:
O - type of container to obtain from context
Parameters:
top - the top container
clazz - desired
Returns:
parent's container

computeTableColumnWidth

public static int computeTableColumnWidth(JTable table,
                                          Font font,
                                          int columnIndex,
                                          String suffix)

fixTableColumnWidth

public static void fixTableColumnWidth(JTable table,
                                       int columnIndex,
                                       int width)

setTableColumnEditor

public static void setTableColumnEditor(JTable table,
                                        int columnIndex,
                                        TableCellEditor editor)

setTableColumnRenderer

public static void setTableColumnRenderer(JTable table,
                                          int columnIndex,
                                          TableCellRenderer editor)

setI18nTableHeaderRenderer

public static void setI18nTableHeaderRenderer(JTable table,
                                              String... libelles)

newStringTableCellRenderer

public static TableCellRenderer newStringTableCellRenderer(DefaultTableCellRenderer renderer,
                                                           int length,
                                                           boolean tooltip)

boxComponentWithJxLayer

public static <V extends JComponent> org.jdesktop.jxlayer.JXLayer<V> boxComponentWithJxLayer(V component)
Box a component in a JXLayer.

Parameters:
component - the component to box
Returns:
the JXLayer boxing the component

getLayeredComponents

public static List<JComponent> getLayeredComponents(JAXXObject object)

getLayer

public static <V extends JComponent> org.jdesktop.jxlayer.JXLayer<V> getLayer(V comp)

setLayerUI

public static void setLayerUI(JComponent comp,
                              org.jdesktop.jxlayer.plaf.LayerUI<JComponent> ui)

isLayered

public static boolean isLayered(JComponent comp)

lookingForEditor

public static Map<String,JComponent> lookingForEditor(Class<?> clazz,
                                                      Container container)
recherche les composants portant le meme nom que les champs de la classe clazz. Cette methode est statique pour pouvoir eventuellement l'utiliser dans un autre context (je pense par exemple a la generation jaxx).

Si la recherche echoue pour quelque raison que se soit, aucune exception n'est leve, et la map retournee est tout simplement vide ou incomplete

Parameters:
clazz - la classe ou recherche les champs
container - le container ou rechercher les composants d'edition
Returns:
le dictionnaire des composants recherches.

center

public static void center(Component parent,
                          Component component)
Centrer un component graphique au center d'un autre component.

Note: si le parent est null, alors on ne fait rien.

Parameters:
parent - le component parent
component - le component à centrer

initNimbusLoookAndFeel

public static void initNimbusLoookAndFeel()
                                   throws UnsupportedLookAndFeelException,
                                          ClassNotFoundException,
                                          InstantiationException,
                                          IllegalAccessException
Try to load the Nimbus look and feel.

Throws:
UnsupportedLookAndFeelException - if nimbus is not applicable
ClassNotFoundException
InstantiationException
IllegalAccessException

loadUIConfig

public static void loadUIConfig(String defaultUIConfig,
                                String extraUIConfig)
                         throws IOException
Load the ui.properties file and set in UIManager colors and icons found.

Parameters:
defaultUIConfig - le path vers le fichier de la config d'ui par défaut (doit etre dansle class-path)
extraUIConfig - le path vers une surcharge de la config d'ui (doit etre dans le class-path)
Throws:
IOException - if could not load the ui.properties file

loadUIConfig

public static void loadUIConfig(Properties incoming)
Load the ui.properties file and set in UIManager colors and icons found.

Parameters:
incoming - the ui resources to load.
Since:
2.1

newTabbedPaneIterator

public static SwingUtil.TabbedPaneIterator<Component> newTabbedPaneIterator(JTabbedPane tabs)
Iterate the components of a JTabbedPane in natural order.

Says using method Container.getComponent(int)

Parameters:
tabs - the
Returns:
the iterator
Since:
1.4

newLabel

public static JLabel newLabel(String text,
                              Object iconKey,
                              int aligment)

getDeepestObjectAt

public static Component getDeepestObjectAt(Component parent,
                                           int x,
                                           int y)
Gets the higest visible component in a ancestor hierarchy at specific x,y coordinates

Parameters:
parent -
x -
y -
Returns:
the deppest component

findComponentAt

public static Component findComponentAt(Container cont,
                                        int width,
                                        int height,
                                        int x,
                                        int y)

newDeleteCellRenderer

public static TableCellRenderer newDeleteCellRenderer(DefaultTableCellRenderer renderer)

newBooleanTableCellRenderer

public static TableCellRenderer newBooleanTableCellRenderer(DefaultTableCellRenderer renderer)

newEmptyNumberTableCellRenderer

public static EmptyNumberTableCellRenderer newEmptyNumberTableCellRenderer(TableCellRenderer renderer)

newEnumTableCellRenderer

public static <E extends Enum<E>> EnumTableCellRenderer<E> newEnumTableCellRenderer(TableCellRenderer renderer,
                                                                                    Class<E> enumClass)

openLink

public static void openLink(HyperlinkEvent he)
Open a link coming from a HyperlinkEvent.

And try to open the link if an url in a browser.

Parameters:
he - the event to treate
Since:
1.6.0

openLink

public static void openLink(String url)

expandTree

public static void expandTree(JTree tree)
Expand all childs of a tree.

Parameters:
tree - the tree to expand

expandTreeTable

public static void expandTreeTable(org.jdesktop.swingx.JXTreeTable treeTable)
Expand all childs of a tree table.

FIXME : Voir pour enlever le copier coller

Parameters:
treeTable - the tree to expand

addExpandOnClickListener

public static void addExpandOnClickListener(JTree tree)
Add a listener of tree selection model to expand a new selected node when it is selected.

Parameters:
tree - the tree to treate

addExpandOnClickListener

public static void addExpandOnClickListener(org.jdesktop.swingx.JXTreeTable treeTable)
Add a listener of tree table selection model to expand a new selected node when it is selected.

FIXME : Voir pour enlever le copier coller

Parameters:
treeTable - the tree to treate

setComponentWidth

public static void setComponentWidth(Component component,
                                     int width)
Set the width of the given component

Parameters:
component - the component to resize
width - the new width to apply

setComponentHeight

public static void setComponentHeight(Component component,
                                      int height)
Set the height of a given component.

Parameters:
component - the component to resize
height - the new height to apply

createIcon

public static ImageIcon createIcon(String path)

createImageIcon

public static ImageIcon createImageIcon(String path)
Parameters:
path - the location of icons in root directory icons
Returns:
the icon at getIconPath()+path

getUIManagerIcon

public static Icon getUIManagerIcon(String key)
Parameters:
key - the key of the icon to retreave from UIManager
Returns:
the icon, or null if no icon found in UIManager

getUIManagerActionIcon

public static Icon getUIManagerActionIcon(String key)
retreave for the UIManager the icon prefixed by action.

Parameters:
key - the key of the action icon to retreave from UIManager
Returns:
the icon, or null if no icon found in UIManager

createActionIcon

public static ImageIcon createActionIcon(String name)

createI18nIcon

public static ImageIcon createI18nIcon(String name)


Copyright © 2008-2011 CodeLutin. All Rights Reserved.