com.sibvisions.rad.ui.swing.impl
Class SwingFactory

java.lang.Object
  extended by com.sibvisions.rad.ui.awt.impl.AwtFactory
      extended by com.sibvisions.rad.ui.swing.impl.SwingFactory
All Implemented Interfaces:
IFactory

public class SwingFactory
extends AwtFactory

The SwingFactory class encapsulates methods to create and access Swing components.

See Also:
AwtFactory

Constructor Summary
SwingFactory()
          Creates a new instance of SwingFactory.
 
Method Summary
 IBorderLayout createBorderLayout()
          Creates a new instance of IBorderLayout.
 IButton createButton()
          Creates a new instance of IButton.
 ICellFormat createCellFormat(IColor pBackground, IColor pForeground, IFont pFont, IImage pImage, int pLeftIndent)
          Creates a new instance of ICellFormat.
 IChart createChart()
          Creates a new instance of IChart.
 ICheckBox createCheckBox()
          Creates a new instance of ICheckBox.
 ICheckBoxMenuItem createCheckBoxMenuItem()
          Creates a new instance of ICheckBoxMenuItem.
 IChoiceCellEditor createChoiceCellEditor()
          Creates a new instance of IChoiceCellEditor.
 IComponent createCustomComponent(Object pCustomComponent)
          Creates a new Instance of IComponent that contains any Custom Component.
 IContainer createCustomContainer(Object pCustomContainer)
          Creates a new Instance of IContainer that contains any Custom Container.
 IDateCellEditor createDateCellEditor()
          Creates a new instance of IDateCellEditor.
 IDesktopPanel createDesktopPanel()
          Creates a new instance of IDesktopPanel.
 IEditor createEditor()
          Creates a new instance of IEditor.
 IFlowLayout createFlowLayout()
          Creates a new instance of IFlowLayout.
 IFormLayout createFormLayout()
          Creates a new instance of IFormLayout.
 IFrame createFrame()
          Creates a new instance of IFrame.
 IGroupPanel createGroupPanel()
          Creates a new instance of IGroupPanel.
 IIcon createIcon()
          Creates a new instance of IIcon.
 IImageViewer createImageViewer()
          Creates a new instance of IImageViewer.
 IInternalFrame createInternalFrame(IDesktopPanel pDesktopPanel)
          Creates a new instance of IInternalFrame.
 ILabel createLabel()
          Creates a new instance of ILabel.
 ILinkedCellEditor createLinkedCellEditor()
          Creates a new instance of ILinkedCellEditor.
 IMenu createMenu()
          Creates a new instance of IMenu.
 IMenuBar createMenuBar()
          Creates a new instance of IMenuBar.
 IMenuItem createMenuItem()
          Creates a new instance of IMenuItem.
 INumberCellEditor createNumberCellEditor()
          Creates a new instance of INumberCellEditor.
 IPanel createPanel()
          Creates a new instance of IPanel.
 IPasswordField createPasswordField()
          Creates a new instance of IPasswordField.
 IPopupMenu createPopupMenu()
          Creates a new instance of IPopupMenu.
 IRadioButton createRadioButton()
          Creates a new instance of IRadioButton.
 IScrollPanel createScrollPanel()
          Creates a new instance of IScrollPanel.
 ISeparator createSeparator()
          Creates a new instance of ISeparator.
 ISplitPanel createSplitPanel()
          Creates a new instance of ISplitPanel.
 ITable createTable()
          Creates a new instance of ITable.
 ITabsetPanel createTabsetPanel()
          Creates a new instance of ITabsetPanel.
 ITextArea createTextArea()
          Creates a new instance of ITextArea.
 ITextCellEditor createTextCellEditor()
          Creates a new instance of ITextCellEditor.
 ITextField createTextField()
          Creates a new instance of ITextField.
 IToggleButton createToggleButton()
          Creates a new instance of IToggleButton.
 IToolBar createToolBar()
          Creates a new instance of IToolBar.
 IToolBarPanel createToolBarPanel()
          Creates a new instance of IToolBarPanel.
 ITree createTree()
          Creates a new instance of ITree.
 IWindow createWindow()
          Creates a new instance of IWindow.
 ICellEditor getDefaultCellEditor(Class<?> pClass)
          Gets the default ICellEditor for the given class.
static int getHorizontalAlignment(int pAlign)
          Gets the horizontal IAlignmentConstants alignment from given JVxConstants alignment.
static int getHorizontalSwingAlignment(int pAlign)
          Gets the horizontal JVxConstants alignment from given IAlignmentConstants alignment.
 IImage getImage(String pImageName)
          Searches the image if it is available as: File ClassLoader resource.
 IImage getImage(String pImageName, byte[] pData)
          Creates an image from byte data.
 String getImageMapping(String pMappingName)
          Gets the image name for the given mapping name.
 String[] getImageMappingNames()
          Gets all used mapping names.
static Key getKey(KeyStroke pKeyStroke)
          Gets the Key for a KeyStroke.
static KeyStroke getKeyStroke(Key pKey)
          Gets the KeyStroke for a Key.
 IColor getSystemColor(String pType)
          This encapsulate symbolic colors representing the color of native GUI objects on a system.
static int getVerticalAlignment(int pAlign)
          Gets the vertical IAlignmentConstants alignment from given JVxConstants alignment.
static int getVerticalSwingAlignment(int pAlign)
          Gets the vertical JVxConstants alignment from given IAlignmentConstants alignment.
 void invokeAndWait(Runnable pRunnable)
          Causes pRunnable.run() to be executed synchronously on the event dispatching thread.
 void invokeInThread(Runnable pRunnable)
          Causes pRunnable.run() to be executed asynchronously in a new thread.
 void invokeLater(Runnable pRunnable)
          Causes pRunnable.run() to be executed asynchronously on the event dispatching thread.
static boolean isLaFOpaque()
          Gets wheter the current Look and Feel draws its own background independent of the background color and opaque setting.
 void setDefaultCellEditor(Class<?> pClass, ICellEditor pCellEditor)
          Sets the default ICellEditor for the given class.
 void setImageMapping(String pMappingName, String pImageName)
          Gets the image name for the given mapping name.
static void setLookAndFeel(ILauncher pLauncher, String pClassName)
          Sets the look and feel which decorates all components.
 void setSystemColor(String pType, IColor pSystemColor)
          Sets the given IColor as SystemColor.
 
Methods inherited from class com.sibvisions.rad.ui.awt.impl.AwtFactory
createColor, createDimension, createFont, createInsets, createPoint, createRectangle, getAvailableFontFamilyNames, getCurrentModifiers, getMostRecentEventTime, getPredefinedCursor, getSystemCustomCursor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwingFactory

public SwingFactory()
Creates a new instance of SwingFactory.

Method Detail

getSystemColor

public IColor getSystemColor(String pType)
This encapsulate symbolic colors representing the color of native GUI objects on a system. For systems which support the dynamic update of the system colors (when the user changes the colors) the actual RGB values of these symbolic colors will also change dynamically. In order to compare the "current" RGB value of a SystemColor object with a non-symbolic Color object, getRGB should be used rather than equals.

Note that the way in which these system colors are applied to GUI objects may vary slightly from platform to platform since GUI objects may be rendered differently on each platform.

Parameters:
pType - the color type.
Returns:
the IColor
See Also:
IColor

setSystemColor

public void setSystemColor(String pType,
                           IColor pSystemColor)
Sets the given IColor as SystemColor. If pSystemColor is null the original SystemColor is restored.

Parameters:
pType - the color type.
pSystemColor - the IColor
See Also:
IColor

getImage

public IImage getImage(String pImageName)
Searches the image if it is available as: resource.

Parameters:
pImageName - the name of a resource containing pixel data in a recognized file format.
Returns:
an IImage which gets its pixel data from the specified file.
See Also:
IImage

getImage

public IImage getImage(String pImageName,
                       byte[] pData)
Creates an image from byte data.

Parameters:
pImageName - the name for the image. The name will be used for cache mechanism. If the name is set to null then the cache will ignore the image.
pData - the image data
Returns:
the image created from the byte data

getImageMapping

public String getImageMapping(String pMappingName)
Gets the image name for the given mapping name.

Parameters:
pMappingName - the mapping name.
Returns:
the image name.

setImageMapping

public void setImageMapping(String pMappingName,
                            String pImageName)
Gets the image name for the given mapping name.

Parameters:
pMappingName - the mapping name.
pImageName - the image name.

getImageMappingNames

public String[] getImageMappingNames()
Gets all used mapping names.

Returns:
the mapping names.

createLabel

public ILabel createLabel()
Creates a new instance of ILabel.

Returns:
the ILabel
See Also:
ILabel

createTextField

public ITextField createTextField()
Creates a new instance of ITextField.

Returns:
the ITextField
See Also:
ITextField

createPasswordField

public IPasswordField createPasswordField()
Creates a new instance of IPasswordField.

Returns:
the IPasswordField
See Also:
IPasswordField

createTextArea

public ITextArea createTextArea()
Creates a new instance of ITextArea.

Returns:
the ITextArea
See Also:
ITextArea

createIcon

public IIcon createIcon()
Creates a new instance of IIcon.

Returns:
the IIcon
See Also:
IIcon

createButton

public IButton createButton()
Creates a new instance of IButton.

Returns:
the IButton
See Also:
IButton

createToggleButton

public IToggleButton createToggleButton()
Creates a new instance of IToggleButton.

Returns:
the IToggleButton
See Also:
IToggleButton

createCheckBox

public ICheckBox createCheckBox()
Creates a new instance of ICheckBox.

Returns:
the ICheckBox
See Also:
ICheckBox

createRadioButton

public IRadioButton createRadioButton()
Creates a new instance of IRadioButton.

Returns:
the IRadioButton
See Also:
IRadioButton

createMenuItem

public IMenuItem createMenuItem()
Creates a new instance of IMenuItem.

Returns:
the IMenuItem
See Also:
IMenuItem

createCheckBoxMenuItem

public ICheckBoxMenuItem createCheckBoxMenuItem()
Creates a new instance of ICheckBoxMenuItem.

Returns:
the ICheckBoxMenuItem
See Also:
ICheckBoxMenuItem

createMenu

public IMenu createMenu()
Creates a new instance of IMenu.

Returns:
the IMenu
See Also:
IMenu

createMenuBar

public IMenuBar createMenuBar()
Creates a new instance of IMenuBar.

Returns:
the IMenuBar
See Also:
IMenuBar

createPopupMenu

public IPopupMenu createPopupMenu()
Creates a new instance of IPopupMenu.

Returns:
the IPopupMenu
See Also:
IPopupMenu

createSeparator

public ISeparator createSeparator()
Creates a new instance of ISeparator.

Returns:
the ISeparator
See Also:
ISeparator

createTable

public ITable createTable()
Creates a new instance of ITable.

Returns:
the ITable
See Also:
ITable

createTree

public ITree createTree()
Creates a new instance of ITree.

Returns:
the ITree
See Also:
ITree

createChart

public IChart createChart()
Creates a new instance of IChart.

Returns:
the IChart
See Also:
IChart

createCellFormat

public ICellFormat createCellFormat(IColor pBackground,
                                    IColor pForeground,
                                    IFont pFont,
                                    IImage pImage,
                                    int pLeftIndent)
Creates a new instance of ICellFormat.

Parameters:
pBackground - the background of the Cell.
pForeground - the foreground of the Cell.
pFont - the font of the Cell.
pImage - the image of the Cell.
pLeftIndent - the left indent.
Returns:
the ICellFormat
See Also:
ICellFormat

createEditor

public IEditor createEditor()
Creates a new instance of IEditor.

Returns:
the IEditor
See Also:
IEditor

getDefaultCellEditor

public ICellEditor getDefaultCellEditor(Class<?> pClass)
Gets the default ICellEditor for the given class. This function should always return an editor. It should look for best matching editor with Class.isAssignableFrom.

Parameters:
pClass - the class type to be edited.
Returns:
the ICellEditor
See Also:
ICellEditor

setDefaultCellEditor

public void setDefaultCellEditor(Class<?> pClass,
                                 ICellEditor pCellEditor)
Sets the default ICellEditor for the given class. This function should always return an editor. It should look for best matching editor with Class.isAssignableFrom. If the given ICellEditor is null, it is removed as editor for the given class.

Parameters:
pClass - the class type to be edited.
pCellEditor - the ICellEditor
See Also:
ICellEditor

createImageViewer

public IImageViewer createImageViewer()
Creates a new instance of IImageViewer.

Returns:
the IImageViewer
See Also:
IImageViewer

createChoiceCellEditor

public IChoiceCellEditor createChoiceCellEditor()
Creates a new instance of IChoiceCellEditor.

Returns:
the IChoiceCellEditor
See Also:
IChoiceCellEditor

createDateCellEditor

public IDateCellEditor createDateCellEditor()
Creates a new instance of IDateCellEditor.

Returns:
the IDateCellEditor
See Also:
IDateCellEditor

createLinkedCellEditor

public ILinkedCellEditor createLinkedCellEditor()
Creates a new instance of ILinkedCellEditor.

Returns:
the ILinkedCellEditor
See Also:
ILinkedCellEditor

createNumberCellEditor

public INumberCellEditor createNumberCellEditor()
Creates a new instance of INumberCellEditor.

Returns:
the INumberCellEditor
See Also:
INumberCellEditor

createTextCellEditor

public ITextCellEditor createTextCellEditor()
Creates a new instance of ITextCellEditor.

Returns:
the ITextCellEditor
See Also:
ITextCellEditor

createPanel

public IPanel createPanel()
Creates a new instance of IPanel.

Returns:
the IPanel
See Also:
IPanel

createToolBarPanel

public IToolBarPanel createToolBarPanel()
Creates a new instance of IToolBarPanel.

Returns:
the IToolBarPanel
See Also:
IToolBarPanel

createGroupPanel

public IGroupPanel createGroupPanel()
Creates a new instance of IGroupPanel.

Returns:
the IGroupPanel
See Also:
IGroupPanel

createScrollPanel

public IScrollPanel createScrollPanel()
Creates a new instance of IScrollPanel.

Returns:
the IScrollPanel
See Also:
IScrollPanel

createSplitPanel

public ISplitPanel createSplitPanel()
Creates a new instance of ISplitPanel.

Returns:
the ISplitPanel
See Also:
ISplitPanel

createTabsetPanel

public ITabsetPanel createTabsetPanel()
Creates a new instance of ITabsetPanel.

Returns:
the ITabsetPanel
See Also:
ITabsetPanel

createToolBar

public IToolBar createToolBar()
Creates a new instance of IToolBar.

Returns:
the IToolBar
See Also:
IToolBar

createDesktopPanel

public IDesktopPanel createDesktopPanel()
Creates a new instance of IDesktopPanel.

Returns:
the IDesktopPanel
See Also:
IDesktopPanel

createInternalFrame

public IInternalFrame createInternalFrame(IDesktopPanel pDesktopPanel)
Creates a new instance of IInternalFrame.

Parameters:
pDesktopPanel - the associated desktop for the internal frame
Returns:
the IInternalFrame
See Also:
IInternalFrame

createWindow

public IWindow createWindow()
Creates a new instance of IWindow.

Returns:
the IWindow
See Also:
IWindow

createFrame

public IFrame createFrame()
Creates a new instance of IFrame.

Returns:
the IFrame
See Also:
IFrame

createCustomComponent

public IComponent createCustomComponent(Object pCustomComponent)
Creates a new Instance of IComponent that contains any Custom Component.

Specified by:
createCustomComponent in interface IFactory
Overrides:
createCustomComponent in class AwtFactory
Parameters:
pCustomComponent - the custom Component.
Returns:
the IComponent custom component.

createCustomContainer

public IContainer createCustomContainer(Object pCustomContainer)
Creates a new Instance of IContainer that contains any Custom Container.

Specified by:
createCustomContainer in interface IFactory
Overrides:
createCustomContainer in class AwtFactory
Parameters:
pCustomContainer - the custom Container.
Returns:
the IContainer custom container.

createBorderLayout

public IBorderLayout createBorderLayout()
Creates a new instance of IBorderLayout.

Returns:
the IBorderLayout
See Also:
IBorderLayout

createFlowLayout

public IFlowLayout createFlowLayout()
Creates a new instance of IFlowLayout.

Returns:
the IFlowLayout
See Also:
IFlowLayout

createFormLayout

public IFormLayout createFormLayout()
Creates a new instance of IFormLayout.

Returns:
the IFormLayout
See Also:
IFormLayout

invokeLater

public void invokeLater(Runnable pRunnable)
Causes pRunnable.run() to be executed asynchronously on the event dispatching thread. This will happen after all pending events have been processed. This method should be used when an application thread needs to update the GUI.

Parameters:
pRunnable - the asynchronous call
See Also:
IFactory.invokeAndWait(Runnable)

invokeAndWait

public void invokeAndWait(Runnable pRunnable)
                   throws Exception
Causes pRunnable.run() to be executed synchronously on the event dispatching thread. This call blocks until all pending events have been processed and (then) pRunnable.run() returns. This method should be used when an application thread needs to update the GUI.

Parameters:
pRunnable - the call
Throws:
Exception - if the call causes an exception

invokeInThread

public void invokeInThread(Runnable pRunnable)
Causes pRunnable.run() to be executed asynchronously in a new thread. Action calls and UI Calls in the thread should be synchronized with the event dispatching thread by using invokeLater or invokeAndWait. To guarantee functionality of invokeLater in Threads, IFactory implementations should use InvokeLaterThread to create threads. The InvokeLaterThread calls all invokeLater notifications after the Thread. In thread loops InvokeLaterThread.executeInvokeLater can be called to invoke thread safe all invokeLater runnables immediate. This gives the IFactory implementation a chance to decide how and when to run the threads.

Parameters:
pRunnable - the call
See Also:
IFactory.invokeAndWait(Runnable), IFactory.invokeLater(Runnable)

getVerticalAlignment

public static int getVerticalAlignment(int pAlign)
Gets the vertical IAlignmentConstants alignment from given JVxConstants alignment.

Parameters:
pAlign - the alignment from JVxConstants
Returns:
alignment from IAlignmentConstants

getVerticalSwingAlignment

public static int getVerticalSwingAlignment(int pAlign)
Gets the vertical JVxConstants alignment from given IAlignmentConstants alignment.

Parameters:
pAlign - the alignment from IAlignmentConstants
Returns:
alignment from JComponent

getHorizontalAlignment

public static int getHorizontalAlignment(int pAlign)
Gets the horizontal IAlignmentConstants alignment from given JVxConstants alignment.

Parameters:
pAlign - the alignment from JVxConstants
Returns:
alignment from IAlignmentConstants

getHorizontalSwingAlignment

public static int getHorizontalSwingAlignment(int pAlign)
Gets the horizontal JVxConstants alignment from given IAlignmentConstants alignment.

Parameters:
pAlign - the alignment from IAlignmentConstants
Returns:
alignment from JComponent

setLookAndFeel

public static void setLookAndFeel(ILauncher pLauncher,
                                  String pClassName)
Sets the look and feel which decorates all components.

Parameters:
pLauncher - the launcher for which the LaF should be changed
pClassName - the full qualified class name of the look and feel

getKeyStroke

public static KeyStroke getKeyStroke(Key pKey)
Gets the KeyStroke for a Key.

Parameters:
pKey - the UI Key
Returns:
the swing KeyStroke

getKey

public static Key getKey(KeyStroke pKeyStroke)
Gets the Key for a KeyStroke.

Parameters:
pKeyStroke - the swing KeyStroke
Returns:
the UI Key

isLaFOpaque

public static boolean isLaFOpaque()
Gets wheter the current Look and Feel draws its own background independent of the background color and opaque setting.

Returns:
true whether the LaF has its own opaque drawind mechanism


Copyright © 2009 SIB Visions GmbH. All Rights Reserved.