Home
Categories
Dictionary
Download
Project Details
Changes Log
Tutorials
FAQ
License

MessageAreaHandler



The MessageAreaHandler interface allow to get notified from interactions in the MessageArea:
  • Link selection and right link selection
  • Text edition if the MessageArea is editable

Registering the handler

The MessageAreaHandler can be registered to the MessageArea by using one of these methods:

Allowing right click

Main Article: allowing right click

By default only hyperlinks selection by left clicking on the hyperlink are allowed. It is however also possible to allows righ-clicking on these hyperlinks, but do allow that, you need to configure the area in the GUI application, but using the SwingMessageArea.setHandleRightClick(boolean) method.

Being notified from text edition

If the MessageArea is editable, the MessageAreaHandler.handleEditText(String) will be notified after the user has edited text in the area and pressed on Enter.

Examples

In the following application, we add a basic link to the area:
   MessageArea area = this.getMessageArea();
   area.addHandler(MyAreaLinkHandler());
   area.appendLink("My link", "link1");
You can perform in the handler:
   public void handleLinkSelection(String linkID) {
     System.out.println("The link ID: " + linkID));
   }
In the following application, we add a link with an associated Object to the area:
   File file =...
   MessageArea area = this.getMessageArea();
   area.addHandler(MyAreaLinkHandler());
   area.appendLink("My link", "link1", file);
You can perform in the handler:
   public void handleLinkSelection(String linkID, Object o) {
   - if (o instanceof File) {
       File file = (File)o;
       System.out.println("The file path: " + file.getPath()));
   }

Notes

  1. ^ The method only allows for one handler and is deprecated. It is preferable to use the MessageArea.addHandler(MessageAreaHandler) method instead

See also


Categories: General | Gui | Swing

Copyright 2006-2023 Herve Girod. All Rights Reserved. Documentation and source under the LGPL v2 and Apache 2.0 licences