66 |
|
|
67 |
|
|
68 |
/** |
/** |
69 |
* JMenuBar |
* <p> |
70 |
|
* JMenuBar is a container for menu's. For a menu bar to be seen on the |
71 |
|
* screen, at least one menu should be added to it. Just like adding |
72 |
|
* components to container, one can use add() to add menu's to the menu bar. |
73 |
|
* Menu's will be displayed in the menu bar in the order they were added. |
74 |
|
* The JMenuBar uses selectionModel to keep track of selected menu index. |
75 |
|
* JMenuBar's selectionModel will fire ChangeEvents to its registered |
76 |
|
* listeners when the selected index changes. |
77 |
|
* </p> |
78 |
*/ |
*/ |
79 |
public class JMenuBar extends JComponent implements Accessible, MenuElement |
public class JMenuBar extends JComponent implements Accessible, MenuElement |
80 |
{ |
{ |
84 |
/** Fired in a PropertyChangeEvent when the "model" changes. */ |
/** Fired in a PropertyChangeEvent when the "model" changes. */ |
85 |
public static final String MODEL_CHANGED_PROPERTY = "model"; |
public static final String MODEL_CHANGED_PROPERTY = "model"; |
86 |
|
|
87 |
|
/** Fired in a PropertyChangeEvent when the "margin" changes. */ |
88 |
|
public static final String MARGIN_CHANGED_PROPERTY = "margin"; |
89 |
private static final long serialVersionUID = -8191026883931977036L; |
private static final long serialVersionUID = -8191026883931977036L; |
90 |
|
|
91 |
/** JMenuBar's model. It keeps track of selected menu's index */ |
/** JMenuBar's model. It keeps track of selected menu's index */ |
122 |
} |
} |
123 |
|
|
124 |
/** |
/** |
125 |
* DOCUMENT ME! |
* This method overrides addNotify() in the Container to register |
126 |
|
* this menu bar with the current keyboard manager. |
127 |
*/ |
*/ |
128 |
public void addNotify() |
public void addNotify() |
129 |
{ |
{ |
227 |
} |
} |
228 |
|
|
229 |
/** |
/** |
230 |
* DOCUMENT ME! |
* Returns number of menu's in this menu bar |
231 |
* |
* |
232 |
* @return DOCUMENT ME! |
* @return number of menu's in this menu bar |
233 |
*/ |
*/ |
234 |
public int getMenuCount() |
public int getMenuCount() |
235 |
{ |
{ |
237 |
} |
} |
238 |
|
|
239 |
/** |
/** |
240 |
* Returns selection model for this menu bar. |
* Returns selection model for this menu bar. SelectionModel |
241 |
|
* keeps track of the selected menu in the menu bar. Whenever |
242 |
|
* selected property of selectionModel changes, the ChangeEvent |
243 |
|
* will be fired its ChangeListeners. |
244 |
* |
* |
245 |
* @return selection mdoel for this menu bar. |
* @return selection model for this menu bar. |
246 |
*/ |
*/ |
247 |
public SingleSelectionModel getSelectionModel() |
public SingleSelectionModel getSelectionModel() |
248 |
{ |
{ |
333 |
} |
} |
334 |
|
|
335 |
/** |
/** |
336 |
* DOCUMENT ME! |
* A string that describes this JMenuBar. Normally only used |
337 |
|
* for debugging. |
338 |
* |
* |
339 |
* @return DOCUMENT ME! |
* @return A string describing this JMenuBar |
340 |
*/ |
*/ |
341 |
protected String paramString() |
protected String paramString() |
342 |
{ |
{ |
344 |
} |
} |
345 |
|
|
346 |
/** |
/** |
347 |
* DOCUMENT ME! |
* Process key events forwarded from MenuSelectionManager. This method |
348 |
|
* doesn't do anything. It is here to conform to the MenuElement interface. |
349 |
|
* |
350 |
|
* @param event event forwarded from MenuSelectionManager |
351 |
|
* @param path path to the menu element from which event was generated |
352 |
|
* @param manager MenuSelectionManager for the current menu hierarchy |
353 |
* |
* |
|
* @param e DOCUMENT ME! |
|
|
* @param path DOCUMENT ME! |
|
|
* @param manager DOCUMENT ME! |
|
354 |
*/ |
*/ |
355 |
public void processKeyEvent(KeyEvent e, MenuElement[] path, |
public void processKeyEvent(KeyEvent e, MenuElement[] path, |
356 |
MenuSelectionManager manager) |
MenuSelectionManager manager) |
359 |
} |
} |
360 |
|
|
361 |
/** |
/** |
362 |
* DOCUMENT ME! |
* Process mouse events forwarded from MenuSelectionManager. This method |
363 |
|
* doesn't do anything. It is here to conform to the MenuElement interface. |
364 |
|
* |
365 |
|
* @param event event forwarded from MenuSelectionManager |
366 |
|
* @param path path to the menu element from which event was generated |
367 |
|
* @param manager MenuSelectionManager for the current menu hierarchy |
368 |
* |
* |
|
* @param event DOCUMENT ME! |
|
|
* @param path DOCUMENT ME! |
|
|
* @param manager DOCUMENT ME! |
|
369 |
*/ |
*/ |
370 |
public void processMouseEvent(MouseEvent event, MenuElement[] path, |
public void processMouseEvent(MouseEvent event, MenuElement[] path, |
371 |
MenuSelectionManager manager) |
MenuSelectionManager manager) |
374 |
} |
} |
375 |
|
|
376 |
/** |
/** |
377 |
* DOCUMENT ME! |
* This method overrides removeNotify() in the Container to |
378 |
|
* unregister this menu bar from the current keyboard manager. |
379 |
*/ |
*/ |
380 |
public void removeNotify() |
public void removeNotify() |
381 |
{ |
{ |
384 |
} |
} |
385 |
|
|
386 |
/** |
/** |
387 |
* DOCUMENT ME! |
* Sets painting status of the border. If 'b' is true then menu bar's |
388 |
|
* border will be painted, and it will not be painted otherwise. |
389 |
* |
* |
390 |
* @param b DOCUMENT ME! |
* @param b indicates if menu bar's border should be painted. |
391 |
*/ |
*/ |
392 |
public void setBorderPainted(boolean b) |
public void setBorderPainted(boolean b) |
393 |
{ |
{ |
402 |
} |
} |
403 |
|
|
404 |
/** |
/** |
405 |
* DOCUMENT ME! |
* Sets help menu for this menu bar |
406 |
* |
* |
407 |
* @param menu DOCUMENT ME! |
* @param menu help menu |
408 |
*/ |
*/ |
409 |
public void setHelpMenu(JMenu menu) |
public void setHelpMenu(JMenu menu) |
410 |
{ |
{ |
411 |
} |
} |
412 |
|
|
413 |
/** |
/** |
414 |
* DOCUMENT ME! |
* Sets the menu bar's "margin" bound property, which represents |
415 |
|
* distance between the menubar's border and its menus. |
416 |
|
* icon. When marging property is modified, PropertyChangeEvent will |
417 |
|
* be fired to menuBar's PropertyChangeListener's. |
418 |
|
* |
419 |
|
* @param m distance between the menubar's border and its menus. |
420 |
* |
* |
|
* @param m DOCUMENT ME! |
|
421 |
*/ |
*/ |
422 |
public void setMargin(Insets m) |
public void setMargin(Insets m) |
423 |
{ |
{ |
424 |
|
if (m.equals(this.margin)) |
425 |
|
{ |
426 |
|
Insets oldMargin = this.margin; |
427 |
|
this.margin = m; |
428 |
|
firePropertyChange(MARGIN_CHANGED_PROPERTY, oldMargin, margin); |
429 |
|
} |
430 |
|
|
431 |
this.margin = m; |
this.margin = m; |
432 |
} |
} |
433 |
|
|
434 |
/** |
/** |
435 |
* Changes menu bar's selection to the specifies menu. |
* Changes menu bar's selection to the specified menu. |
436 |
* This method updates selected index of menu bar's model, |
* This method updates selected index of menu bar's selection model, |
437 |
* which results in a model firing change event. |
* which results in a model firing change event. |
438 |
* |
* |
439 |
* @param sel menu to select |
* @param sel menu to select |