public class SwingUtil extends JAXXUtil
Note : Replace previous class jaxx.runtime.swing.Utils in previous versions.
| Modifier and Type | Class and Description |
|---|---|
static class |
SwingUtil.TabbedPaneIterator<O>
A simple iterator on a
JTabbedPane. |
| Modifier and Type | Field and Description |
|---|---|
static String |
COLOR_PREFIX |
static String |
DECIMAL1_PATTERN
Pattern to use for decimal numeric values with 1 decimal digits in editors.
|
static String |
DECIMAL2_PATTERN
Pattern to use for decimal numeric values with 2 decimal digits in editors.
|
static String |
DECIMAL3_PATTERN
Pattern to use for decimal numeric values with 3 decimal digits in editors.
|
static String |
DECIMAL4_PATTERN
Pattern to use for decimal numeric values with 4 decimal digits in editors.
|
static String |
DEFAULT_ICON_PATH |
static String |
DEFAULT_ICON_PATH_PROPERTY |
static String |
ICON_PREFIX |
static String |
INT_3_DIGITS_PATTERN
Pattern to use for short numeric values in editors with max 3 digits.
|
static String |
INT_6_DIGITS_PATTERN
Pattern to use for integer numeric values in editors with max 6 digits.
|
static String |
INT_7_DIGITS_PATTERN
Pattern to use for integer numeric values in editors with max 7 digits.
|
static String |
LONG_10_DIGITS_PATTERN
Pattern to use for long numeric values in editors with max 10 digits.
|
| Constructor and Description |
|---|
SwingUtil() |
| Modifier and Type | Method and Description |
|---|---|
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 void |
addRowSelectionInterval(JTable table,
int rowIndex)
Add the given row index
rowIndex (from the model coordinate)
in the selection of the given table. |
static int |
askUser(Component ui,
String title,
Object message,
int typeMessage,
Object[] options,
int defaultOption) |
static int |
askUser(Component ui,
String title,
String message,
int typeMessage,
Object[] options,
int defaultOption) |
static int |
askUser(Frame ui,
JOptionPane pane,
String title,
Object[] options) |
static <V extends JComponent> |
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 |
createIcon(String classifier,
String name) |
static ImageIcon |
createImageIcon(String path) |
static void |
displayInfo(Component ui,
String title,
String text) |
static void |
displayWarning(Component ui,
String title,
String text) |
static boolean |
editCell(JTable table,
int row,
int colummn)
Used to edit a cell of a given table.
|
static void |
ensureColumnIndex(TableModel model,
int index) |
static void |
ensureRowIndex(TableModel model,
int rowIndex) |
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 KeyStroke |
findKeyStroke(String name,
String defaultValue) |
static void |
fixTableColumnWidth(JTable table,
int columnIndex,
int width) |
static String |
getAccText(KeyStroke actionKey) |
static Component |
getDeepestObjectAt(Component parent,
int x,
int y)
Gets the higest visible component in a ancestor hierarchy at
specific x,y coordinates
|
static Desktop |
getDesktopForBrowse() |
static char |
getFirstCharAt(String text,
char defaultValue)
Get the first char of a String, or return default value.
|
static <V extends JComponent> |
getLayer(V comp) |
static List<JComponent> |
getLayeredComponents(JAXXObject object) |
static <O> O |
getParent(Object top,
Class<O> clazz)
Find a parent of the given
top object using the container api to get up. |
static <O extends Container> |
getParentContainer(Object top,
Class<O> clazz)
Return parent's container corresponding to the Class clazz
|
static int |
getSelectedModelColumn(JTable table)
Return the selected column of the table in the model coordinate or
-1 if selection is empty. |
static int |
getSelectedModelRow(JTable table)
Return the selected row of the table in the model coordinate or
-1 if selection is empty. |
static int[] |
getSelectedModelRows(JTable table)
Return the selected rows of the table in the model coordinate or empty
array if selection is empty.
|
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 String |
keyStrokeToStr(KeyStroke actionKey) |
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 void |
makeTableTabFocusable(JTable table)
Add
KeyListener to focus next editable cell on TAB key |
static BooleanCellEditor |
newBooleanTableCellEditor(TableCellRenderer renderer) |
static TableCellRenderer |
newBooleanTableCellEditorAndRenderer(TableCellRenderer renderer) |
static TableCellRenderer |
newBooleanTableCellRenderer(TableCellRenderer renderer) |
static TableCellRenderer |
newBooleanTableCellRenderer(TableCellRenderer renderer,
Predicate<?> predicate) |
static DefaultComboBoxModel |
newComboModel(Object... items) |
static TableCellRenderer |
newDeleteCellRenderer(DefaultTableCellRenderer renderer) |
static EmptyNumberTableCellRenderer |
newEmptyNumberTableCellRenderer(TableCellRenderer renderer) |
static <E extends Enum<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 |
openLink(URI uri) |
static void |
scrollToTableSelection(JTable table)
Add to a given table a selec tion model listener to always scroll to
current cell selection.
|
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 |
setSelectionInterval(JTable table,
int rowIndex)
Select the given row index
rowIndex (from the model coordinate)
in the selection of the given table. |
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) |
applyDataBinding, applyDataBinding, castList, castMap, checkJAXXContextEntries, checkJAXXContextEntry, copyToClipBoard, decodeCompressedJAXXObjectDescriptor, decodeJAXXObjectDescriptor, destroy, destroy, findJaxxPropertyChangeListener, getDataBindingUpdateListener, getEventListener, getEventListener, getStringValue, initContext, invokeConstructor, newContextEntryDef, newContextEntryDef, newListContextEntryDef, newListContextEntryDef, newMapContextEntryDef, processDataBinding, reloadBinding, reloadBinding, removeAllDataBindings, removeDataBindingpublic static final String DEFAULT_ICON_PATH
public static final String DEFAULT_ICON_PATH_PROPERTY
public static final String ICON_PREFIX
public static final String COLOR_PREFIX
public static final String INT_3_DIGITS_PATTERN
public static final String INT_6_DIGITS_PATTERN
public static final String INT_7_DIGITS_PATTERN
public static final String LONG_10_DIGITS_PATTERN
public static final String DECIMAL1_PATTERN
public static final String DECIMAL2_PATTERN
public static final String DECIMAL3_PATTERN
public static final String DECIMAL4_PATTERN
public static Dimension newMinDimension()
public static Dimension newMaxXDimension()
public static Dimension newMaxYDimension()
public static Dimension newMaxXYDimension()
public static void setText(JTextComponent c, String text)
public static void fillComboBox(JComboBox combo, Collection<?> data, Object select)
combo - the combo to filldata - data ot inject in comboselect - the object to select in combo after reflling his modelpublic static void fillList(JList list, Collection<?> data, Object select)
list - the list to filldata - data ot inject in comboselect - the object to select in combo after reflling his model@Deprecated public static void fillComboBox(JAXXComboBox combo, Collection<?> data, Object select, boolean firstNull)
Fill a combo box model with some datas, and select after all the given object
combo - the combo to filldata - data ot inject in comboselect - the object to select in combo after reflling his modelfirstNull - add a first null elementpublic static <O extends Container> O getParentContainer(Object top, Class<O> clazz)
O - type of container to obtain from contexttop - the top containerclazz - desiredpublic static <O> O getParent(Object top, Class<O> clazz)
top object using the container api to get up.
Stop on parent when it is of the givenclazz type.
O - type of container to obtain from contexttop - the top containerclazz - desiredpublic static int computeTableColumnWidth(JTable table, Font font, int columnIndex, String suffix)
public static void fixTableColumnWidth(JTable table, int columnIndex, int width)
public static void setTableColumnEditor(JTable table, int columnIndex, TableCellEditor editor)
public static void setTableColumnRenderer(JTable table, int columnIndex, TableCellRenderer editor)
public static void setI18nTableHeaderRenderer(JTable table, String... libelles)
public static TableCellRenderer newStringTableCellRenderer(DefaultTableCellRenderer renderer, int length, boolean tooltip)
public static <V extends JComponent> org.jdesktop.jxlayer.JXLayer<V> boxComponentWithJxLayer(V component)
JXLayer.component - the component to boxJXLayer boxing the componentpublic static List<JComponent> getLayeredComponents(JAXXObject object)
public static <V extends JComponent> org.jdesktop.jxlayer.JXLayer<V> getLayer(V comp)
public static void setLayerUI(JComponent comp, org.jdesktop.jxlayer.plaf.LayerUI<JComponent> ui)
public static boolean isLayered(JComponent comp)
public static Map<String,JComponent> lookingForEditor(Class<?> clazz, Container container)
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
clazz - la classe ou recherche les champscontainer - le container ou rechercher les composants d'editionpublic static void center(Component parent, Component component)
Note: si le parent est null, alors on ne fait rien.
parent - le component parentcomponent - le component à centrerpublic static void initNimbusLoookAndFeel()
throws UnsupportedLookAndFeelException,
ClassNotFoundException,
InstantiationException,
IllegalAccessException
UnsupportedLookAndFeelException - if nimbus is not applicableClassNotFoundExceptionInstantiationExceptionIllegalAccessExceptionpublic static void loadUIConfig(String defaultUIConfig, String extraUIConfig) throws IOException
UIManager colors and
icons found.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)IOException - if could not load the ui.properties filepublic static void loadUIConfig(Properties incoming)
UIManager colors and
icons found.incoming - the ui resources to load.public static SwingUtil.TabbedPaneIterator<Component> newTabbedPaneIterator(JTabbedPane tabs)
JTabbedPane in natural order.
Says using method Container.getComponent(int)
tabs - thepublic static int[] getSelectedModelRows(JTable table)
table - the table to seekpublic static int getSelectedModelRow(JTable table)
-1 if selection is empty.table - the table to seek-1 if selection is empty.public static int getSelectedModelColumn(JTable table)
-1 if selection is empty.table - the table to seek-1 if selection is empty.public static void setSelectionInterval(JTable table, int rowIndex)
rowIndex (from the model coordinate)
in the selection of the given table.table - the table where to set the selectionrowIndex - the row index in the model coordinate to set as selectionpublic static void addRowSelectionInterval(JTable table, int rowIndex)
rowIndex (from the model coordinate)
in the selection of the given table.table - the table where to set the selectionrowIndex - the row index in the model coordinate to add to selectionpublic static int askUser(Component ui, String title, String message, int typeMessage, Object[] options, int defaultOption)
public static int askUser(Component ui, String title, Object message, int typeMessage, Object[] options, int defaultOption)
public static int askUser(Frame ui, JOptionPane pane, String title, Object[] options)
public static Component getDeepestObjectAt(Component parent, int x, int y)
parent - x - y - public static Component findComponentAt(Container cont, int width, int height, int x, int y)
public static TableCellRenderer newDeleteCellRenderer(DefaultTableCellRenderer renderer)
public static TableCellRenderer newBooleanTableCellRenderer(TableCellRenderer renderer)
public static TableCellRenderer newBooleanTableCellRenderer(TableCellRenderer renderer, Predicate<?> predicate)
public static TableCellRenderer newBooleanTableCellEditorAndRenderer(TableCellRenderer renderer)
public static BooleanCellEditor newBooleanTableCellEditor(TableCellRenderer renderer)
public static EmptyNumberTableCellRenderer newEmptyNumberTableCellRenderer(TableCellRenderer renderer)
public static <E extends Enum<E>> EnumTableCellRenderer<E> newEnumTableCellRenderer(TableCellRenderer renderer, Class<E> enumClass)
public static void openLink(HyperlinkEvent he)
HyperlinkEvent.
And try to open the link if an url in a browser.
he - the event to treatepublic static void openLink(String url)
public static void expandTree(JTree tree)
tree - the tree to expandpublic static void expandTreeTable(org.jdesktop.swingx.JXTreeTable treeTable)
FIXME : Voir pour enlever le copier coller
treeTable - the tree to expandpublic static void addExpandOnClickListener(JTree tree)
tree - the tree to treatepublic static void addExpandOnClickListener(org.jdesktop.swingx.JXTreeTable treeTable)
FIXME : Voir pour enlever le copier coller
treeTable - the tree to treatepublic static void setComponentWidth(Component component, int width)
component - the component to resizewidth - the new width to applypublic static void setComponentHeight(Component component, int height)
component - the component to resizeheight - the new height to applypublic static ImageIcon createImageIcon(String path)
path - the location of icons in root directory iconsgetIconPath()+pathpublic static Icon getUIManagerActionIcon(String key)
UIManager the icon prefixed by action.public static void makeTableTabFocusable(JTable table)
KeyListener to focus next editable cell on TAB keytable - to add TAB KeyListenerpublic static boolean editCell(JTable table, int row, int colummn)
table - the table to editrow - row index of cell to editingcolummn - column index of cell to editingfalse if for any reason the cell cannot be edited,
or if the indices are invalidpublic static void ensureRowIndex(TableModel model, int rowIndex) throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsExceptionpublic static void ensureColumnIndex(TableModel model, int index) throws ArrayIndexOutOfBoundsException
ArrayIndexOutOfBoundsExceptionpublic static void scrollToTableSelection(JTable table)
table - the tablepublic static char getFirstCharAt(String text, char defaultValue)
Used for example by generated code (i18nMnemonic).
text - the text to cutdefaultValue - default char value if text is null, or emptypublic static void openLink(URI uri)
public static Desktop getDesktopForBrowse()
public static DefaultComboBoxModel newComboModel(Object... items)
Copyright © 2008–2017 Ultreia.io. All rights reserved.