Synergy Home Page

au.edu.swin.synergy.plugin.mod13.bwt
Class BSwingUtilities

java.lang.Object
  |
  +--au.edu.swin.synergy.plugin.mod13.bwt.BSwingUtilities

public class BSwingUtilities
extends Object

Because the current version of swing is not thread safe, all methods on swing components need to be called from the awt event thread. Due to the fact that Cohesion is so incredibly thread centric, this requires a central means for performing these tasks.

This class needs to provide a means of setting all the required methods with their given paramaters as needed. Obviously it won't cover everything and so needs to be updated as new requirements come to hand.

The alternative is to write a your own inner class for each method you call and call SwingUtilities.invokeLater() yourself

Author:
Team Synergy

Inner Class Summary
 class BSwingUtilities.BAddJComboItem
          Handles the add item method in the combo
 class BSwingUtilities.BAddTab
          Adds the given component to the table as a tab
 class BSwingUtilities.BListModelRefresh
          This provides a means of safely setting the contents of a BListModel from within the awt thread.
 class BSwingUtilities.BListModelSetContents
          This provides a means of safely setting the contents of a BListModel from within the awt thread.
 class BSwingUtilities.BRemoveAllJComboItems
          Handles the removeAllItems method of the combo
 class BSwingUtilities.BSetAccelerator
          Sets the user object in the given tree node
 class BSwingUtilities.BSetBorderTitle
          Sets the user object in the given tree node
 class BSwingUtilities.BSetFrameIcon
          Adds the given component to the table as a tab
 class BSwingUtilities.BSetFrameTitle
          Adds the given component to the table as a tab
 class BSwingUtilities.BSetJBorder
          Handles the set enabled on a JComponent
 class BSwingUtilities.BSetJButtonText
          Handles the set enabled on a JComponent
 class BSwingUtilities.BSetJComboItem
          Handles the add item method in the combo
 class BSwingUtilities.BSetJComponentEnabled
          Handles the set enabled on a JComponent
 class BSwingUtilities.BSetJLabelText
          Handles the set text on a JLabel
 class BSwingUtilities.BSetJMenuItemText
          Handles the set text on a JLabel
 class BSwingUtilities.BSetJText
          Handles the set text on a JTextComponents
 class BSwingUtilities.BSetMnemonic
          Sets the user object in the given tree node
 class BSwingUtilities.BSetPreferedSize
          Adds the given component to the table as a tab
 class BSwingUtilities.BSetTitleFor
          Adds the given component to the table as a tab
 class BSwingUtilities.BSetToolTip
          Sets the user object in the given tree node
 class BSwingUtilities.BSetUserObject
          Sets the user object in the given tree node
 class BSwingUtilities.BSetValueAt
          Handles the add item method in the combo
 
Constructor Summary
BSwingUtilities()
           
 
Method Summary
static void addTab(JTabbedPane tabbedPane, String title, JComponent component)
          Adds the given component to the given JTable as a tab
static void doBListModelRefresh(BListModel listModel)
          This will call the doRefresh method in list model provided
static void doJComboAddItem(JComboBox comboBox, Object item)
          This will call the addItem() method of the given combo box with the given object
static void doJComboRemoveAllItems(JComboBox comboBox)
          This will call the removeAllItems() method of the given combo box
static void doJComboSetItem(JComboBox comboBox, Object item)
          This will call the addItem() method of the given combo box with the given object
static ImageIcon getImage(Object loader, String location)
          Gets an image icon using the give objects class as the class loader and the given location as the path to the icon.
static void setBListModelContents(BListModel listModel, Vector contents)
          This accepts a BListModel and a Vector of contents for that model and performs the operation in the awt thread.
static void setBorder(JComponent fComponent, Border border)
          This accepts any JComponent and sets its enabled state to the given value
static void setBorderTitle(TitledBorder border, String title)
          Sets the title in the given title border
static void setFrameIcon(Frame frame, Image icon)
          Sets the frame icon for the given frame
static void setFrameTitle(Frame frame, String title)
          Sets the title for the given component on the given table to the given value!
static void setJButtonText(AbstractButton button, String fText)
          Sets the text in the given textComponent to the value provided
static void setJComponentEnabled(JComponent fComponent, boolean fEnabled)
          This accepts any JComponent and sets its enabled state to the given value
static void setJLabelText(JLabel fLabel, String fText)
          Sets the text in the given JLabel to the value provided
static void setJMenuItemText(JMenuItem menuItem, String fText)
          Sets the text in the given JMenuItem to the value provided
static void setJText(JTextComponent textComponent, String fText)
          Sets the text in the given textComponent to the value provided
static void setMenuAccererator(JMenuItem menuItem, KeyStroke keyStroke)
          Sets the accererator for the given menu item
static void setMnemonic(AbstractButton button, char mnemonic)
          Sets the mnemonic for the given abstract button
static void setMnemonic(AbstractButton button, int mnemonic)
          Sets the mnemonic for the given abstract button
static void setSize(Component component, Dimension size, boolean preferred)
          Sets the size or prefered size of the component
static void setTableModelValueAt(DefaultTableModel tableModel, Object value, int row, int column)
          Sets the value at the specified row and column to the given value
static void setTitleFor(JTabbedPane tabbedPane, JComponent component, String title)
          Sets the title for the given component on the given table to the given value!
static void setToolTip(JComponent component, String fText)
          Sets the tooltip text on the given JComponent to the value provided
static void setUserObject(DefaultMutableTreeNode node, Object value)
          Sets the user object in the given default mutable tree node
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BSwingUtilities

public BSwingUtilities()
Method Detail

setJLabelText

public static void setJLabelText(JLabel fLabel,
                                 String fText)
Sets the text in the given JLabel to the value provided
Parameters:
fLabel - The label to set the text of
fText - The text to set it to

setUserObject

public static void setUserObject(DefaultMutableTreeNode node,
                                 Object value)
Sets the user object in the given default mutable tree node
Parameters:
node - The node to set the user object in
value - The value to set

setTableModelValueAt

public static void setTableModelValueAt(DefaultTableModel tableModel,
                                        Object value,
                                        int row,
                                        int column)
Sets the value at the specified row and column to the given value
Parameters:
tableModel - The table model to set the value in
value - The value to set
row - The row to set the value in
column - The column to set the value in

setJButtonText

public static void setJButtonText(AbstractButton button,
                                  String fText)
Sets the text in the given textComponent to the value provided
Parameters:
fLabel - The label to set the text of
fText - The text to set it to

setToolTip

public static void setToolTip(JComponent component,
                              String fText)
Sets the tooltip text on the given JComponent to the value provided
Parameters:
component - The component to set the tool tip on
fText - The text to set it to

setSize

public static void setSize(Component component,
                           Dimension size,
                           boolean preferred)
Sets the size or prefered size of the component
Parameters:
component - The component to set the size of
size - The size to set it to
preferred - True to set the preferred size, false to set the size

setTitleFor

public static void setTitleFor(JTabbedPane tabbedPane,
                               JComponent component,
                               String title)
Sets the title for the given component on the given table to the given value!
Parameters:
component - The component to set the title for
tabbedPane - The tabbed pane to set the title on
String - The new title

setFrameTitle

public static void setFrameTitle(Frame frame,
                                 String title)
Sets the title for the given component on the given table to the given value!
Parameters:
frame - The frame to set the title of
String - The new title

setFrameIcon

public static void setFrameIcon(Frame frame,
                                Image icon)
Sets the frame icon for the given frame
Parameters:
frame - The frame to set the title of
icon - The icon to set on the frame

doBListModelRefresh

public static void doBListModelRefresh(BListModel listModel)
This will call the doRefresh method in list model provided
Parameters:
listModel - The list model to call refresh on

getImage

public static ImageIcon getImage(Object loader,
                                 String location)
Gets an image icon using the give objects class as the class loader and the given location as the path to the icon.

This should be used in the following manner:

ImageIcon icon = BSwingUtilities.getImage(this, "/au/edu/swin/synergy/plugin/mod13/images/logo.gif")

This will allow the images to be stored in a jar along with the classes. Make sure you have the slash on the front.

Parameters:
loader - The object to be used as the resource loader
location - The relative path to the icon

doJComboSetItem

public static void doJComboSetItem(JComboBox comboBox,
                                   Object item)
This will call the addItem() method of the given combo box with the given object
Parameters:
comboBox - The combo to add to
item - The item to add

doJComboAddItem

public static void doJComboAddItem(JComboBox comboBox,
                                   Object item)
This will call the addItem() method of the given combo box with the given object
Parameters:
comboBox - The combo to add to
item - The item to add

doJComboRemoveAllItems

public static void doJComboRemoveAllItems(JComboBox comboBox)
This will call the removeAllItems() method of the given combo box
Parameters:
comboBox - The combo box to remove all the items from

setJMenuItemText

public static void setJMenuItemText(JMenuItem menuItem,
                                    String fText)
Sets the text in the given JMenuItem to the value provided
Parameters:
menuItem - The menu item to set the text of
fText - The text to set it to

setMenuAccererator

public static void setMenuAccererator(JMenuItem menuItem,
                                      KeyStroke keyStroke)
Sets the accererator for the given menu item
Parameters:
menuItem - The menu item to set accererator for
keyStroke - The keystroke to set as the accelerator

addTab

public static void addTab(JTabbedPane tabbedPane,
                          String title,
                          JComponent component)
Adds the given component to the given JTable as a tab
Parameters:
table - The table add the component to
component - The component to add as a tab to the given table

setMnemonic

public static void setMnemonic(AbstractButton button,
                               int mnemonic)
Sets the mnemonic for the given abstract button
Parameters:
button - The button item to set mnemonic for
mnemonic - The mnemonic to set as the mnemonic

setMnemonic

public static void setMnemonic(AbstractButton button,
                               char mnemonic)
Sets the mnemonic for the given abstract button
Parameters:
button - The button item to set mnemonic for
mnemonic - The mnemonic to set as the mnemonic

setBorderTitle

public static void setBorderTitle(TitledBorder border,
                                  String title)
Sets the title in the given title border
Parameters:
border - The border to set the title of
title - The title to set

setJText

public static void setJText(JTextComponent textComponent,
                            String fText)
Sets the text in the given textComponent to the value provided
Parameters:
fLabel - The label to set the text of
fText - The text to set it to

setBorder

public static void setBorder(JComponent fComponent,
                             Border border)
This accepts any JComponent and sets its enabled state to the given value
Parameters:
fComponent - The component to set the border of
fEnabled - The new enabled state of the given component

setJComponentEnabled

public static void setJComponentEnabled(JComponent fComponent,
                                        boolean fEnabled)
This accepts any JComponent and sets its enabled state to the given value
Parameters:
fComponent - The component to set
fEnabled - The new enabled state of the given component

setBListModelContents

public static void setBListModelContents(BListModel listModel,
                                         Vector contents)
This accepts a BListModel and a Vector of contents for that model and performs the operation in the awt thread.
Parameters:
listModel - The list model to set the contents of
contents - The contents of the list model to set

Synergy Home Page