Sending event to display the ToolTipText

HI Coders
I've extended Jpanel and I draw an Image inside it so that Jpanel is the viewport of the image.
In usual circumstances when i mouse over the image's viewport the ToolTip execute ,but in my case I need to execute the ToolTipText without actually mouse over the image's viewport, instead I need to press a button which in turn execute the ToolTipText that registered with that image�s viewport.
this is the code i used but its doesnt work:
public class NewToolTipTest extends JFrame
    private JLabel l;
    private JButton showTip;
    public NewToolTipTest()
        Image i = Toolkit.getDefaultToolkit().getImage( "someImage.gif" );
        ImageIcon ii = new ImageIcon( i );
        l = new JLabel( ii );
        l.setToolTipText( "Look, it's a ToolTip!" );
        getContentPane().add( l, BorderLayout.CENTER );
        showTip = new JButton( "Show Tip" );
        // Don't give the button a tooltip!  It will replace the
        // tooltip you want to show!
        //showTip.setToolTipText( "Push Me!" );
        showTip.addActionListener( new TipActivate() );
        getContentPane().add( showTip, BorderLayout.SOUTH );
        addWindowListener( new ExitHandler() );
    public static void main( String[] args )
        NewToolTipTest nttt = new NewToolTipTest();
        nttt.pack();
        nttt.setVisible( true );
    private class ExitHandler extends WindowAdapter
        public void windowClosing( WindowEvent event )
            System.exit( 0 );
    private class TipActivate implements ActionListener
        public void actionPerformed( ActionEvent event )
            ToolTipManager theManager = ToolTipManager.sharedInstance();
            MouseEvent toolTipEvent = new MouseEvent( l, MouseEvent.MOUSE_ENTERED,
                    System.currentTimeMillis(), 0, 0, 0, 0, false );
            theManager.mouseMoved( toolTipEvent );
            System.out.println( "ActionEvent launched!" );
}im using version 1.3 (Swing).
thanks in advance
Shay Gaghe

Hi,
Here is the code to show the tooltip programmatically where you want :
import java.util.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class TestToolTip extends JPanel {
     Random r =new Random(System.currentTimeMillis());
     JButton b;
     ToolTipManager manager = ToolTipManager.sharedInstance();
     public TestToolTip() {
          manager.setInitialDelay(0);
          setPreferredSize(new Dimension(500,500));
          b= new JButton("Show tooltip at a random location");
          b.addActionListener(new ActionListener() {
               public void actionPerformed(ActionEvent e) {
                    showToolTip();
     public void showToolTip() {
          int x = r.nextInt(499);
          int y = r.nextInt(499);
          MouseEvent e = new MouseEvent(this, MouseEvent.MOUSE_MOVED, 0, 0,x,y,0,false);
          manager.mouseMoved(e);
     public String getToolTipText(MouseEvent e) {
          return("Position : ("+e.getX()+","+e.getY()+")");
     public static void main(String[] args) {
          JFrame f = new JFrame("Frame");
          TestToolTip t = new TestToolTip();
          f.getContentPane().add(t, BorderLayout.CENTER);
          f.getContentPane().add(t.b, BorderLayout.NORTH);
          f.pack();
          f.setVisible(true);
}I hope this helps,
Denis

Similar Messages

  • Why do Caldav calendars sending event invites from the wrong email address.

    I have iCloud enabled calendars alongside a caldav based account (Mac OS X Server) within iCal.  When I create events with attendees attached, from the caldav based account, the invites are always sent from the iCloud based email account (a former .mac email address).  This does not seem consistent with the way calendar invites used to work prior to the Mobile Me to iCloud changeover.  It is a privacy issue, that attendess become exposed to an email address that I do not want associated with that calendar's activity.
    From my searching, this appears to be a problem and has existed in various forms throughout many versions of OS X.  There seems to be no way within Lion to define the default email address used by a calendar.
    Previous solutions involved an entanglement of Mail's default account and Address Book email address entries.  I've called Apple, and there advanced applications support team don't know how to solve this.  Does anyone know?

    did you ever fix this . This is exactly what ios happening to me now. Help 
    I see this msg is from year and half ago...oh we;;

  • Sending mail but displaying the uncode in subject filed...some wht urgent

    Hi every one
    and Thanx to every one...for giving their precious help for every one
    Here i want to explain a small problem in java mail with unicode
    Here it is ....
    Iam sending a mail with some chinese characters in the subject field..internally these chineese characters are converting in to html unicode format like(主).
    the code goes like this :
    MimeMessage message =new MimeMesage();
    String subject=主的电
    message.setSubject(subject,"utf-8");
    ......remaining are setted properly i mean from ,to using InternetAddress
    Multipart multipart = new MimeMultipart();
    BodyPart messageBodyPart = new MimeBodyPart();
    messageBodyPart.setContent(content, "text/html");
    multipart.addBodyPart(messageBodyPart);
    message.setContent(multipart);
    Transport.send(message);
    Now
    It is sending mail to the receipents but in at the receiver side the mail's subject field contains unicode in stead of chinese characters....if i open and seen the viewsource from the page it is adding an extra &amp instead of &..i think it is not filtering th unicode ....here iam sending the mail to gmail...
    I didn't understand where iam doing the mistake please give some idea how to do this .....and let know where iam doing worng programming ....
    it s very urgent for me ...please
    Thanx in advance ......
    Srikanth

    hi bshannon
    i solved this problem .....i will explain what did here
    here iam getting the string literal from the DB as NCR formated string
    so i converted that string to unicode string ...(Ex: "&amp#220027;")
    This method will converts the NCR fomated string to UnicodeString:
    public static String NCR2UnicodeString(String str)
    StringBuffer ostr = new StringBuffer();
    int i1=0;
    int i2=0;
    while(i2<str.length())
    i1 = str.indexOf("&#",i2);
    if (i1 == -1 ) {
    ostr.append(str.substring(i2, str.length()));
    break ;
    ostr.append(str.substring(i2, i1));
    i2 = str.indexOf(";", i1);
    if (i2 == -1 ) {
    ostr.append(str.substring(i1, str.length()));
    break ;
    String tok = str.substring(i1+2, i2);
    try {
    int radix = 10 ;
    if (tok.trim().charAt(0) == 'x') {
    radix = 16 ;
    tok = tok.substring(1,tok.length());
    ostr.append((char) Integer.parseInt(tok, radix));
    } catch (NumberFormatException exp) {
    ostr.append('?') ;
    i2++ ;
    return new String(ostr) ;
    from this method i will get a string the unicode ...and iam setting this string to subject
    MimeMessage message =new MimeMessage();
    message.setSubject("string from the above method","utf-8");
    and remaing setting all are doing here
    finally
    Transport.send(message);
    I hope you are also expained the same thing ...
    and a lot thanx to you to solve my urgent problem...
    Thanx
    Srikanth

  • Outlook 2007 Calendar Monitoring: track send event for recurring meetings

    Hi,
    I'm working on an Outlook 2007, VSTO 2010, .NET 3.5 add-in which monitors AppointmentItem objects changed on the user's calendar. Specifically I'm tracking the send event of the currently selected appointment in the calendar view. Currently my add-in is
    set to cancel the send event and call Display() on the selected appointment instead.
    I'm testing with Outlook 2007 SP3. The event handler is fired correctly for non-recurring meetings when the user changes the start or end time of the meeting and for recurring meeting occurrences / exceptions when the user changes the end time, but not when
    the user changes the start time of a recurring meeting occurrence / exception. These are the specific steps:
    Create a recurring appointment with e.g. 3 occurrences, add at least one attendee and send the invitation.
    Set the Calendar to display a Week View.
    Select the top edge of the first occurrence of the appointment created in step 1 and drag it upwards to increase the length of the appointment by half an hour.
    Release the mouse button and press enter to confirm the change.
    Answer 'Save changes and send update' in the popup.
    At this point the addin should cancel the send event and display the appointment, but actually the event handler is not called. This behavior occurs only when I change the start time of an occurrence / exception. When I change the end time the event handler
    is called correctly.
    Do you have any clue why the event handler is only called for the one change and not for the other? How could I work around this issue?

    Hi Eugene,
    Thanks for your reply. Here is my code:
    public class ExplorerMonitor {private Explorer explorer;private AppointmentItem selectedAppointment;
    public ExplorerMonitor()
    this.explorer = Globals.ThisAddIn.Application.ActiveExplorer();
    this.explorer.SelectionChange += new ExplorerEvents_10_SelectionChangeEventHandler(Explorer_SelectionChange);
    private void Explorer_SelectionChange()
    Selection selection = null;
    object selectedItem = null;
    bool eventsHookedUp = false;
    try
    // first remove the listeners from the previously selected item
    this.StopSelectedItemMonitor();
    selection = this.explorer.Selection;
    if (selection.Count == 1)
    selectedItem = selection[1];
    AppointmentItem appointment = selectedItem as AppointmentItem;
    if (appointment != null)
    this.selectedAppointment = appointment;
    ((ItemEvents_10_Event)this.selectedAppointment).Send
    += new ItemEvents_10_SendEventHandler(SelectedAppointment_Send);
    // Stop monitoring when the item is opened in an explorer window.
    this.selectedAppointment.Open
    += new ItemEvents_10_OpenEventHandler(SelectedAppointment_Open);
    eventsHookedUp = true;
    catch (System.Exception exception)
    logger.Error("Caught in Explorer_SelectionChange", exception);
    finally
    if (!eventsHookedUp)
    // only release if we didn't start monitoring it
    ComMarshaler<object>.releaseComObject(ref selectedItem);
    ComMarshaler<Selection>.releaseComObject(ref selection);
    private void SelectedAppointment_Open(ref bool Cancel)
    this.StopSelectedItemMonitor();
    private void SelectedAppointment_Send(ref bool Cancel)
    Cancel = true;
    this.selectedAppointment.Display();
    private void StopSelectedItemMonitor()
    if (this.selectedAppointment != null)
    this.selectedAppointment.Open -= new ItemEvents_10_OpenEventHandler(SelectedAppointment_Open);
    ((ItemEvents_10_Event)this.selectedAppointment).Send
    -= new ItemEvents_10_SendEventHandler(SelectedAppointment_Send);
    ComMarshaler<AppointmentItem>.releaseComObject(ref this.selectedAppointment);
    public static class ComMarshaler<T>
    public static void releaseComObject(ref T anObject)
    if (anObject != null && Marshal.IsComObject(anObject))
    Marshal.ReleaseComObject(anObject);
    anObject = default(T);

  • Override the ToolTipText of the JTable with JButton ToolTipTex(pls see msg)

    Hi All,
    Could you please me to solve this problem?
    I have two Icons display on 2 JButtons (2 different ToolTipText for buttons). The Buttons are display on a JPanel. The Panel is display on one of the cell inside JTable. Is it possible that when I move the mouse over each Icon it will displays the ToolTipText of each of the JButton (I am try to replace the ToolTipText of the JTable with the ToolTipText of the JButton when mouse over and when I move the mouse to the next JButton I get a different ToolTipText). The reason I am using the JButton is that in the future I will add actionListener() to do something when the user click on it.
    I have try working with glassPane, addMouseMotionListener, MouseEvent.getPoint(), SwingUtilities.convertPoint, SwingUtilities.getDeepestComponentAt.
    Thank you in advance.
    Note: I am getting the Icons from Object [].

    Hello, the following is one ugly piece of code but I guess that's pretty much what you were after. Just test the tooltip and you'll see that it depends both on the cell and on which of the two buttons is hovered.import javax.swing.*;
    import javax.swing.table.TableCellRenderer;
    import java.awt.*;
    import java.awt.event.MouseEvent;
    public class TestTooltipTable {
         private static class CustomTableCellRenderer implements TableCellRenderer {
              private JButton theLeftButton;
              private JButton theRightButton;
              private JPanel thePanel;
              public CustomTableCellRenderer() {
                   theLeftButton = new JButton("left action");
                   theRightButton = new JButton("right action");
                   thePanel = new JPanel(new GridLayout(1, 2)) {
                        public String getToolTipText(MouseEvent e) {
                             Point p = e.getPoint();
                             Rectangle leftRect = theLeftButton.getBounds();
                             Rectangle rightRect = theRightButton.getBounds();
                             if (leftRect.contains(p)) {
                                  return theLeftButton.getToolTipText();
                             } else if (rightRect.contains(p)) {
                                  return theRightButton.getToolTipText();
                             return " ";
                   thePanel.add(theLeftButton);
                   thePanel.add(theRightButton);
              public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected,
                                                                        boolean hasFocus, int row, int column) {
                   String text = (String)value;
                   theLeftButton.setToolTipText("left action " + text);
                   theRightButton.setToolTipText("right action " + text);
                   return thePanel;
         public static void main(String[] args) {
              final JFrame frame = new JFrame(TestTooltipTable.class.getName());
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              Object[][] data = {{"1", "A"}, {"2", "B"}, {"3", "C"}};
              String[] columnNames = {"Number", "Letter"};
              JTable table = new JTable(data, columnNames) {
                   public String getToolTipText(MouseEvent event) {
                        return super.getToolTipText(event);
              table.setDefaultRenderer(Object.class, new CustomTableCellRenderer());
              ToolTipManager.sharedInstance().registerComponent(table);
              frame.getContentPane().add(new JScrollPane(table));
              SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                        frame.pack();
                        frame.show();
    }

  • How can I display event notes on the relevant event in week/day view?

    Hi folks,
    I'm looking for a way to display the event notes on the actual event in week or day view.
    This will greatly help plan out my week (especially for repetitive events with custom notes for each occurrence).
    I can understand that Apple ommitted this feature to avoid clutter on short-duration events perhaps?
    Clicking on the event (or using the Inspector) to see the notes is not an option. I need an overview that can be viewed at a glance or even printed.
    Looking forward to your suggestions...
    Trev

    Hi Trev,
    With iCal as it is the only suggestion I have would be to add the full text to the title of the events.
    FYI, this is a user to user forum. By posting here you are not guaranteed someone from Apple will read it. If you'd like Apple to know about this I suggest you send them feedback.
    Best wishes
    John M

  • CRM 2013: Iframe does not display the url set in onform load event with setSrc. How to make this work?

    I have a situation we need to display a url in Iframe when a form is loading. the url is set in code with setSrc, or updated the query string value. this worked in crm 2004 not any more in 2013.  MSDN states the below to avoid in OnLoad event. what
    is the best way to handle this situation?  Searched web people recommend using setInterval which i dont want to use.
    Any help on this issue is appreciated. 
    https://msdn.microsoft.com/en-us/library/gg328034(v=crm.6).aspx
    Avoid using the OnLoad Event. IFRAMES and web resources load asynchronously and the frame may not have finished loading before the Onload event script finishes. This can cause the src property of the IFRAME or web resource
    you have changed to be overwritten by the default value of the IFRAME or web resource URL property.

    Thank you for you reply.  this URL you send uses window.setInterval which i am not comfortable using it. we need to call clearInterval(),
    if not the IFrame refresh every second. 
    function SetURL()
    if(Xrm.Page.ui.controls.get("IFRAME_ActivitySmmary")!=null)
    Xrm.Page.ui.controls.get("IFRAME_ActivitySmmary").setSrc(reportUrl + "&id="+ customerId);
                    Xrm.Page.ui.controls.get("IFRAME_ActivitySmmary").setVisible(true);
    else
    { window.setInterval("SetURL()",1000);}

  • To display the typ, key field,info in the top-of -page event in OO ALV

    Hi all,
    I need to display the heading and the other select option details in the top-of-page  event in ooalv.How can the key ,typ and the info of top of event  in alv grid be passed in ooalv grid display.
    Regards,
    Arpita

    Check the blog.
    TOP_OF_PAGE in ALV  Using CL_GUI_ALV_GRID
    Now you have to use the method ADD_TEXT to populate the Select options details.
    I hope you know the Function to get the selection details
    RS_REFRESH_FROM_SELECTOPTIONS,. it will give into a table. so use that table and populate the TOP_OF_PAGE uisng the class CL_DD_DOCUMENT.

  • How can I get my 2010 mac book pro to send signal out through the mini display port?                      end signal out through the end video signal out through the

    How can I get my 2010 macbook pro to send signal out through the mini display port?

    First, what you said is contradictory. You say "can't get a video signal", then say"the Mac wallpaper is broadcast, the mouse pointer is visible". "No video signal" means an absolutely black,blank screen. It sounds like you have plenty of signal.
    I am supposing what you are seeing is actually a blank desktop, which is to be expected if your settings are such that you are extending the desktop, instead of mirroring it.
    Within the preference panes is a setting that allows you to change this. Open System Preferences, click Displays, and then click Arrangement. You will see that you are extending the desktop. Change that setting.

  • I wanted to know if others were having difficulties getting All Day Events appear in the Notification Center in iOS 7.   Currently my Calendar in the notification center will show events that are at certain times, but they will not display All Day Events.

    I wanted to know if others were having difficulties getting All Day Events appear in the Notification Center in iOS 7.
    Currently my Calendar in the notification center will show events that are at certain times, but they will not display All Day Events.

    Have you looked at the previous discussions listed on the right side of this page under the heading "More Like This"?

  • The calendar sync is recently not working correctly, not display "All events" but it only displays the last six months for my individual entries. My repeating entires do go back further, though. How do I fix?

    I have an iPad 5.1.1. The calendar sync has started to not work correctly. I have it checked "All events," but it only displays the last two months for my individual entries. My repeating entires do go back further, though. How do I fix?

    HI Jason269. Thanks for your reply, however I wrote that I already have "All events" checked. If All Events is checked and it doesn't diaplay all events, how do I fix? It seems this is a common issue, as I have read many others on here state the same problem.
    I believe my problem occurred when I synced my iMac calendar to my iPad calendar using yahoo. Yesterday, I unsynced them on my iMac controls. When I checked my iPad calendar, all of my old entries reappeared - but only for five seconds and disappeared again. So, the data is saved and still there but cannot be displayed, even when I have All events checked. In fact, it only shows my individual entries for the last two months, but does show all my recurring entries. If I switched to last six months, I will see everything for the last six months. If I switch back to all events, it is only for the last two months.
    As I mentioned, others on here have expressed exactly the same issue, including the two month example and having used yahoo.
    For legal purposes, I need to be able to use the information from my indidual calendar entries in an upcoming court case. So I really need to fix this ASAP!

  • When I send a mail from my iPhone, it displays the mail server name to the receiver if the mail and does nog display my name or e mail address. This only since upgrading my iPhone5 to iOS7

    When I send a mail from my iPhone, it displays the mail server name to the receiver if the mail and does not display my name or e mail address. This only since upgrading my iPhone5 to iOS7. I've checked all settings etc. anyone have a solution please?

    Rectory wrote:
    Please can someone tell me how  I can change this so when I send a mail from my phone and from the IPad that it reads from me.
    You need a separate email address but you've already ruled out that solution.

  • How to display the Logo by using TOP_OF_Page Event in OOPS

    Hi Gurus,
    I'm using TOP_OF_Page event to print Header and Logo in the same conatiner.
    Let me explain the case clearly,i have splitted the main conatiner in two parts like conatiner1 and conatainer2.
    i want to display logo and header in the container1, and i'm trying to use the * vertical_split * method ,but i'm unable to display the logo by splitting this conatiner vertically.........
    and if possible plz forward the sample code....
    Hence plz suggest me how to handle this.
    Thanks inadvance.

    Hi,
    In your top container i.e, container1, you can directly display the logo as well as text as there are methods already available in class  CL_DD_DOCUMENT(For eg, ADD_TEXT, ADD_PICTURE, ADD_ICON etc).
    Data:  lo_document TYPE REF TO cl_dd_document.
    CREATE OBJECT lo_document
        EXPORTING
          style = 'ALV_GRID'.
    CALL METHOD lo_document->add_text                   " To add text
        EXPORTING
          text         = text-006
          sap_fontsize = '18'
          sap_emphasis = cl_dd_area=>strong.               " For bold
      CALL METHOD lo_document->new_line.               " For new line
    CALL METHOD lo_document->add_text
        EXPORTING
          text         = text-018
          sap_emphasis = cl_dd_area=>strong.
      CALL METHOD lo_document->add_gap                 " To add gap in the same line
        EXPORTING
          width = 10.
    CALL METHOD lo_document->add_picture             " For picture
        EXPORTING
          picture_id       = 'TRVPICTURE01'
          width            =  '100'.
    CALL METHOD lo_document->display_document
        EXPORTING
          parent = lo_top_container1.
    Thanks and Regards,
    Himanshu

  • When I send an email it displays the full email address instead of just the name even thought the person is in my contacts. How to fix?

    When I send an email it displays the full email address instead of just the name even thought the person is in my contacts. How to fix?

    Hi Sunny C,
    Welcome to the Support Communities!  The "From" field should be showing by default, but you can check or change your settings for Mail with the instructions below:
    Mail (Yosemite): Set Mail preferences
    http://support.apple.com/kb/PH19178
    In the Composing pane, you can set the email account that you want to send new messages from.
    Also, check the View command on the Menu bar.  View > Message Attributes should have a checkmark beside the "From" field.
    Cheers,
    Judy

  • Is there a way to display the location of an event?

    I would like to display the location of an event in the appointment itself. Anyone know how to do this? Is it as simple as just putting it in the title instead of the event field?
    Thanks,
    Vinnie

    The only things you can get to display in the calendar view are the title and time. Therefore, if you put the location in the title, it will be displayed.
    Andrew T.

Maybe you are looking for

  • My camera takes forever to open. Why?

    MY camera takes forever to open. Can someone tell me what's up with that?

  • Data Collection in BPC

    Hi, How does the Data Collection(UCMON tcode) works in BPC?. Do we have any standard Data Manager Package to do the Data Collection?.How can we achieve this Would appreciate your time and response. Thanks.

  • DB 13 Message logs BR0988W Bitmap index /BI0/F0COPC_C08~08 selected for che

    Dear Exprts, We are getting following error in DB13 check DB, our server is BW Test and version BW3.5. Kindly Suggest. BR0988W Bitmap index /BI0/F0COPC_C08~08 selected for checking statistics - please activate the monitoring attribute for table SAPBW

  • Web Gallery security setting

    Hi, I have just created my gallery but run into a difficulty with the security setting. If I apply a password to my Album/Event, the Key Photo, number of photos, and scrolling feature is disabled in the My Gallery page. Is there a way of applying thi

  • ODI-10150: Work repository with ID 1 is not bound to master

    Hello, ODI 11g (11.1.1) with database 11g r2 I have created Master repository (odimrep) and work repository(odiwrep), created from Topology Before the next step, during this time I was able to login to connect to work repository and able to do all wo