|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--guk.editIM.MenuHelpers
MenuHelpers.java in guk.editIM: Simplify creation of buttons, menu items, checkboxes... Other menu related tasks.
Field Summary | |
(package private) java.awt.event.ActionListener |
ACTIONLISTENER
The action listener that will receive all events from menu elements generated by this class. |
(package private) java.awt.Component |
baseWin
The component relative to which centerMe will center things. |
(package private) boolean |
REALLYDISPATCH
Going through the event queue is broken. |
(package private) java.awt.Font |
theFont
The font which is used by the setSyncFont and syncFont methods. |
Constructor Summary | |
MenuHelpers(java.awt.event.ActionListener listener)
Tell the constructor what the action listener should be. |
Method Summary | |
void |
centerMe(java.awt.Component compo)
Centers the given component relative to the baseWin component. |
static void |
fixSize(javax.swing.JComponent compo,
java.awt.Dimension size)
Force minimum, maximum and preferred size of a component to a certain value. |
java.awt.Component |
getBaseWin()
Ask for the current centering base component. |
java.awt.event.ActionListener |
getListener()
Retrieve the current action listener value. |
javax.swing.JButton |
glyphXButton(java.lang.String label,
java.lang.String tooltip,
java.lang.String command)
Helper to create a mini button for special glyph functions with all settings in one go. |
static java.awt.Color |
hueByHash(java.awt.Color c,
int hash,
float offs)
Helper method: modify hue in HSB color space by some function of hash and by offset offs. |
(package private) javax.swing.JButton |
myJButton(java.lang.String label,
int mnemonic,
java.lang.String tooltip,
java.lang.String command)
Helper to create a JButton with all settings in one go. |
javax.swing.JMenuItem |
myJMenuItem(java.lang.String what,
java.lang.String label,
int mnemonic,
java.lang.String tooltip,
java.lang.String command)
Generic creation of box, item or menu type menu items. |
(package private) void |
posting(java.lang.Object target,
java.lang.Object event)
Dispatches either by dispatchEvent or by calling actionPerformed directly if dispatchEvent is not available. |
void |
setBaseWin(java.awt.Component compo)
Enable the centering functionality. |
void |
setListener(java.awt.event.ActionListener listener)
Use a new action listener in the future. |
void |
setSyncFont(java.awt.Font font)
Set up the font parameter for font syncing. |
void |
syncFont(java.awt.Component compo)
Sync the font used by the given component: Set it to the font selected by setSyncFont. |
void |
tellListener(java.awt.event.ActionListener whom,
java.awt.event.ActionEvent what)
Dispatch event to ANOTHER listener, using a given ActionEvent. |
void |
tellListener(java.awt.event.ActionListener whom,
java.lang.String what)
Dispatch event to ANOTHER listener, giving it a new ActionEvent (with id ACTION_PERFORMED) with the specified message. |
void |
tellListener(java.lang.String what)
Dispatch event to our listener, giving it a new ActionEvent (with id ACTION_PERFORMED) with the specified message. |
static java.lang.String |
toHex(int value)
Convert an int value into an hex String of a length which is a multiple of 4. |
Methods inherited from class java.lang.Object |
|
Field Detail |
final boolean REALLYDISPATCH
java.awt.event.ActionListener ACTIONLISTENER
java.awt.Font theFont
java.awt.Component baseWin
Constructor Detail |
public MenuHelpers(java.awt.event.ActionListener listener)
listener
- The action listener that will receive all
events from menu elements generated by this class.Method Detail |
public void setListener(java.awt.event.ActionListener listener)
listener
- The action listener that will receive all
events from menu elements generated here in the future.public java.awt.event.ActionListener getListener()
void posting(java.lang.Object target, java.lang.Object event)
target
- The target, a Component or
at least an ActionListener.event
- An ActionEvent (not AWTevent)
or command String to be sent.public void tellListener(java.lang.String what)
The
- string that will be used to generate
the sent action event.public void tellListener(java.awt.event.ActionListener whom, java.lang.String what)
whom
- The listener that should be notified.what
- The string that will be used to generate
the sent action event.public void tellListener(java.awt.event.ActionListener whom, java.awt.event.ActionEvent what)
whom
- The listener that should be notified.what
- The ActionEvent to be sent.public void setBaseWin(java.awt.Component compo)
compo
- The component relative to which centerMe
will center thingspublic java.awt.Component getBaseWin()
public void setSyncFont(java.awt.Font font)
font
- An arbitrary font.public void syncFont(java.awt.Component compo)
compo
- A component that you want to use the
font selected by setSyncFont.public javax.swing.JMenuItem myJMenuItem(java.lang.String what, java.lang.String label, int mnemonic, java.lang.String tooltip, java.lang.String command)
what
- can be "box", "item" or "menu" to select what
type of item (JCheckBoxMenuItem, JMenuItem, JMenu) we need.label
- The text for the item. If null, a default is used.mnemonic
- The key code that should be used as mnemonic.
Use -1 to indicate no mnemonic.tooltip
- The tool tip text, if any (null otherwise).command
- The action command that should be used. For
a menu, null should be used here.public javax.swing.JButton glyphXButton(java.lang.String label, java.lang.String tooltip, java.lang.String command)
label
- The text that the button should showtooltip
- The tool tip for the buttoncommand
- the action command for the button.javax.swing.JButton myJButton(java.lang.String label, int mnemonic, java.lang.String tooltip, java.lang.String command)
label
- The text for the item. If null, a default is used.mnemonic
- The key code that should be used as mnemonic.
Use -1 to indicate no mnemonic.tooltip
- The tool tip text, if any (null otherwise).command
- The action command that should be used.public static void fixSize(javax.swing.JComponent compo, java.awt.Dimension size)
compo
- The component that will have the size
hints changed.size
- The new value for the size hints.public static java.lang.String toHex(int value)
value
- An integer value, preferrably 0..65535public void centerMe(java.awt.Component compo)
compo
- A component that should be centered relative
to the component given to setBaseWin() (if none is known,
nothing will happen).public static java.awt.Color hueByHash(java.awt.Color c, int hash, float offs)
c
- input color, will be somewhat trimmedhash
- arbitrary integer as seed for the hue modificationoffs
- offset to the hue
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |