Displaying TOOL TIP message over an applet

Hi,
How to display a tooltip(hint) like message when the mouse moves over an applet. Here is the rough source code, Please do the needful.
import java.applet.*;
import java.awt.*;
public class Dis extends Applet implements MouseListner
     public void init()
          setLayout(null);
          ButtonAb b = new ButtonAb("click me"); //this is another class that is being called here, this class extends Component, I have written all ActionListeners and MouseListeners in this class only
          b.add();
     //public void addMouseListener(MouseEvent me)
When the mouse moves over the Button("click me"), a hint box or tooltip like message should be displayed. It is easy doing with VB or Swing, but I wanted to it with AWT. Please give me some source code also.
Thanks in advance
Uma

There are several ways to implement tooltip in awt. I prefere a general ToolTip class that can be added to any Component, and that is easy to use:
something like this:Button but;
but = new Button("Push");
add(but);
new ToolTip(but, "Push this button if you want to push this button");The code above should add a ToolTip to the java.awt.Button, so that everytime the mouse hoovers over the button, the message gets displayed.
The idea is to make a ToolTip that can be added to any java.awt.Component using one line of code only. How do one achive that? Ok, here is a pseudo implementation of the ToolTip class:class ToolTip extends java.awt.Canvas implements Runnable, MouseListener, MouseMotionListener
   private String m_strText;
   private Component m_Component;
   private Thread m_Thread;
   private int m_iX;
   private int m_iY;
   public ToolTip(Component comp, String strText);
      m_strText = strText;
      m_Component = comp;
      comp.addMouseMotionListener(this);
      comp.addMouseListener(this);
   public void run()
      try{
         Thread.sleep(500);
         // Here its time to display the tooltip:
         // We need to add it.
         Component comp = this;
         while((!comp instanceof Applet) &&
                 (!comp instanceof Frame))
            comp = comp.getParent();
         ((Container)comp).add(this);
         int x,y,w,h;
         x = m_iX+m_Component.getLocationOnScreen().x-comp.getLocationOnScreen.x;
         y = m_iY+m_Component.getLocationOnScreen().y - comp.getLocationOnScreen.y;
         h=30;
         w=getFontMetrics().stringWidth(m_strText);
         setBounds(x,y,w,h);
      cathc(InterruptedException e)
   public void mouseEntered(MouseEvent e)
      start(e.getX(), e.getY());
   private void start(int iX, int iY);
      m_iX = iX;
      m_iY = iY;
      m_Thread = new Thread(this);
      m_Thread.start();
   public void mouseExited(MouseEvent e)
      stop();
   public void mouseMoved(MouseEvent e)
      stop();
      start(e.getX(), e.getY());
   private void stop()
      if(m_Thread != null)
         m_Thread.interrupt();
      Container parent = getParent();
      if(parent != null)
         parent.remove(this);
   public void paint(Graphics g)
      g.drawString(m_strText, 0, 20);
      g.drawRect(0,0,getSize().width, getSize().height);
}The baseclass could be changed to java.awt.Window.
using Window gives the ToolTip the posibillity to extend beyond the borders of the Applet (or the Frame), but in IE it gives you the "warning applet window" displayed on the botton of every ToolTip.
Ragnvald Barth
Software engineer

Similar Messages

  • Updating Tool tip message of Query panel Operators

    I have a requirement to modify the tool tip message of Query panel operators. Currently the following messages are displayed when I hover over the 'CONTAINS' operators for the 'name' field in the query panel - "Operators for Name" & "Contains". I want to replace these messages with custom message. Please let me know if this possible. I understand that I can provide custom message for a 'Custom Operator' . But checking if there is a easier way of doing this.
    Any pointers will be appreciated.

    Hi,
    use the Resource Strings mentioned here http://docs.oracle.com/cd/E28280_01/apirefs.1111/e15862/toc.htm#query and look for how to skin these labels: http://docs.oracle.com/cd/E28280_01/web.1111/b31973/af_skin.htm#autoId10
    Frank

  • Customise Tool Tip Message

    Hi All,
    I have a Date Component on my page and basically I am trying to Disable the Saturadays and Sundays from the Calender which I did using the disabledDaysOfWeek attribute. By doing so, I am getting a default tool tip message (in Bold) that says
    Example: 11/29/1998
    Enter a date that falls on one of the following days: Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday
    So, I want to customize it by removing Saturday and Sunday from the above message. I tried shortDesc which did not work, instead displays the typed message (un-bolded) along with the above bold message.
    So, can I do achieve it? If not, I would like to disable this tool tip message.
    <af:inputDate value="#{bindings.SelectDate.inputValue}"
    label="Preferred Date :"
    required="true"
    shortDesc="#{bindings.SelectDate.hints.tooltip}"
    binding="#{backingBeanScope.beanName.id1}"
    id="id1"
    disabledDaysOfWeek="sat sun">
    <f:validator binding="#{bindings.SelectDate.validator}"/>
    <af:convertDateTime pattern="#{bindings.SelectDate.format}"/>
    </af:inputDate>
    Edited by: Saif Khan on May 14, 2012 4:23 PM

    Umesh,
    Thank you very much. I have just put the InputDate component onto the page and this code seems to be working in my Laptop with ver 11.1.2.1.0 and win XP. For some reason its not working in my work computer with win7 enterprise and ver 11.1.1.5.0. I will try to use the same code in work computer tomorrow and check.
    <?xml version='1.0' encoding='UTF-8'?>
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1" xmlns:f="http://java.sun.com/jsf/core"
    xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
    <jsp:directive.page contentType="text/html;charset=UTF-8"/>
    <f:view>
    <af:document title="untitled2.jspx" id="d1">
    <af:form id="f1">
    <af:inputDate label="Label 1" id="id1" disabledDaysOfWeek="sat sun"/>
    </af:form>
    </af:document>
    </f:view>
    </jsp:root>
    I will surely post you if its working in the work computer as well. And i am sorry to trouble you which I didnt mean to. :)

  • Tool Tip(Mouse Over)

    Hello All,
    I need to create a Tool Tip (Mouse Over) in BI. Requirement is *" I have a dashboard report which shows the different trends by arrows going up & down. When i take my mouse over the Up arrow, a text should come up which says 'Trend is up, because you gained as compared to last quarter'. similarly for Arrow going down. "*
    How to create such tool tip (mouse over) in BI. Please suggest.
    Regards,
    Ashish A.

    Hi Ashish, first of all, I am not sure to do a Tool-Tip-Text for Column Headers.
    As far as the column formulas, you can still use the code i sent and embed in the already updated column.
    Ex: Lets assume you have updated the formula of the column Products."Product ID" as REPLACE(Products."Product ID",'000','1111') || '_PD'. To show Products.Product_Name as a tool tip to the updated ProductID, you can embed the code as
    'OpenTag div title=" '|| Products.ProductName || ' " closetag' || REPLACE(Products."Product ID",'000','1111') || '_PD' || 'opentag /div closetag'
    Thanks
    Sai

  • Strange "tool tip:" message when reading blogs in Safari

    Today, I was reading a blog in Safari (latest version) in SnoLo (latest version). Something caught my eye. I looked at the lower part of the screen and noticed that the idle cursor that was positioned over a word in the blog had turned into a pointer hand, but there wasn't a hyperlink in the word. I just shrugged it off until I noticed it flick again and the hand had turned into a message, like a tool tio in most applications. The tip said "Discover what top martial artists & the Army don't want you to know"! Whaaaaa?
    I scrolled down the blog and waited. After a minute or so, the pointer changed to a hand and 30+ seconds later, displayed the same message. I took a screen snap, and was able to get it before the tool tip faded.
    http://www.michaelbradydesign.com/Transfer/AppleForum/Strange_tooltip.png
    I switched to another blog and was able to replicate it. This time the message said "Sign up for the #1 voted stock newsletter for free today."
    There was no such commercial message on either blog page, nor was the window sitting on top of another window with a web page with such an advertiser.
    What in the world is going on? Has anyone seen a similar thing?
    For the record, yesterday, I updated iTunes and a Java update.
    TIA and all that.

    Hi MIchael,
    You can disable tooltips using the Terminal app /Applications/Utilities.
    Instructions here.
    http://www.macosxtips.co.uk/index_files/disable-tooltips-safari-firefox.html
    Carolyn

  • Can anyone help me ? my iphone 3gs keeps displaying needs activation and connect to itunes when i do this nothing happens but the phone works fine but as soon as i disconect the phone it displays the same message over again and wont let me go any further

    my phone has just suddenly stopped working today was fine this morning then suddenly showed a message saying needs activating and connect to i tunes . i connected it to itunes and nothing happened but phone started to work fine  so i disconected it from the laptop it worked fine untill it went to lock then showed the same message again .please can anybody help as i am ready tear my hair out!

    In settings>general> cellular do you have it  turned ON?

  • Af:statusIndicator tool tip message .

    Hi All,
    I am using Jdev 11.1.2.0.0.
    How can i change the af:statusindicator tooptip message?.Suppose in idle stage its showing 'idle' but i want customize that messge.Is possible ?.
    Thanks,
    Vass Lee

    Hi,
    Thanks for yours response. i given my code for yours code.
    <af:panelGroupLayout
                                 inlineStyle="background-color:white; height:70px;" id="ptpgl2">
              <af:commandLink disabled="true" id="logoLink" action="index">
                <af:statusIndicator id="ptsi1" shortDesc="Calwin"/>
              </af:commandLink>
            </af:panelGroupLayout>
    af|statusIndicator::idle-icon
        content: url("/org/calwin/uimanager/images/CalWINLogoSmall.png");
       content: "Calwin";
        width: 60px;
        height: 5.7em;
    }Here what i have done in wrong thing ?please tell me?
    Thanks,
    Vass Lee

  • J Tool Tips - Strange and Awkward Bug

    Hello Everyone,
    I am having a very strange J Tool Tip bug. Okay first of all, the tool tip that I have created works when it is inside of a single panel for a single label. Basically, what I have is a number of J Labels - each having a unique tool tip. Here is the most basic of my code (notice that I have customized my own Tool Tip to have a yellow background and black foreground):
    currentLabel = new JLabel("LABEL TEST")
                // Extends the JLabel and overrides createToolTip() to return a custom tool tip:
                @Override
                public JToolTip createToolTip()
                    JToolTip toolTip = super.createToolTip();
                    toolTip.setComponent(this);
                    toolTip.setBackground(Color.YELLOW);
                    toolTip.setForeground(Color.BLACK);
                    return toolTip;
            currentLabel.setToolTipText("Testing Tool Tip Message");Okay, so here's the deal. Here's the tricky part. When I have this label nested inside of a Grid Bag Layout Panel, it works perfectly fine. It shows up when the user's mouse hovers over the label.
    Here's my problem. The project that I am working on is actually nested in many complicated panels. This project has about 100 java files, so I am just going to cut it short and let you know which kind of panels it is nested in.
    Starting from the lowest panel:
    1. J Panel (Grid Bag Layout)
    2. J Panel (Box Layout)
    3. J Panel (Border Layout)
    4. J Split Pane (Right Side)
    5. J Panel (Border Layout) (Largest Panel)
    One of the things I noticed is that now when I hover over the labels, a very small microscopic blue dot appears right to the left of the mouse cursor. I seriously think this is the Tool Tip, but for some reason it isn't showing any text. The strange thing is that the tool tip works when panels 2, 3, 4, and 5 are non-existent. If you guys have any ideas or suggestions, please let me know! I'd really appreciate it!
    Thanks,
    Brian

    What I might do is : see if listening for mouseEntered and mouseExited events work on the labels when in their complex arrangement. And make a little tooltip class based on JWindow (perhaps with a JLabel on its contentpane so you can display HTML). I found this approach more reliable. Though one would expect this is what is already implemented, the inbilt behaviour may overcomplicate things resulting in some no-shows. I seem to remember having this problem with tootips on table cell renderers.
    Edited by: kina_tji on Jul 23, 2008 6:33 PM

  • Tool Tip Text and JcomboBox/JList

    Is it possible to attach and display a different Tool Tip message for each item in a combobox or jlist.

    Hi try this code it will work
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.plaf.basic.*;
    public class ToolTipComboBoxExample extends JFrame {
    String[] items = {"Swing", "Applet", "RMI", "JDBC"};
    String[] tooltips = {"Swing ", "Applet", "RMI", "JDBC"};
    public ToolTipComboBoxExample() {
    super("ToolTip ComboBox Example");
    JComboBox combo = new JComboBox(items);
    combo.setRenderer(new MyComboBoxRenderer());
    getContentPane().setLayout(new FlowLayout());
    getContentPane().add(combo);
    class MyComboBoxRenderer extends BasicComboBoxRenderer {
    public Component getListCellRendererComponent( JList list,
    Object value, int index, boolean isSelected, boolean cellHasFocus) {
    if (isSelected) {
    setBackground(list.getSelectionBackground());
    setForeground(list.getSelectionForeground());
    if (-1 < index) {
    list.setToolTipText(tooltips[index]);
    } else {
    setBackground(list.getBackground());
    setForeground(list.getForeground());
    setFont(list.getFont());
    setText((value == null) ? "" : value.toString());
    return this;
    public static void main (String args[]) {
    ToolTipComboBoxExample frame = new ToolTipComboBoxExample();
    frame.addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
         System.exit(0);
    frame.setSize(300, 200);
    frame.setVisible(true);
    Thanks
    Paddy

  • How can I break the tool tips (tip strips) into to seveal lines?

    I use the tip in "Description and tip..." to display tool tips (tooltips, tip strips, help cues, the little yellow strips with helpful information about a control). Some of the help messages are long, but the tips are still displayed on one line. In some cases the whole text can not be read because the tip is wider than the screen. I would like to be able to specify a maximum width of the tip, or to be able to manually insert line breaks.

    Hi Nick
    Actually, I write multiline string up to 256 char long in worpad. Then, I copy and paste into de tip dialog from pop up menu and it works fine.
    Hope it helps.
    Alipio
    "Qod natura non dat, Salmantica non praestat"

  • How to display a select query record in a tool tip?

    hi,
    How to display a select query record in a tool tip?
    for example i have a report employee. when i move the mouse pointer over a employee name, the tool tip should display the respective department id, department name...of that employee name.
    select dep_id, dep_name ....from department where employee.....Is it possible?
    thanks

    Dear Skud,
    Yes its possible..select ''||ename||'' from emp
    other wise you can use jQuery tooptip or some other JScript bundles.
    Thanks and Regards
    Maheswara

  • Tool Tip Display Disappears/Bug/Glitch

    Hello,
    I am having an issue with the tool tip function. When i mouse over multipe triggers quickly and then stop. The tool tip displays comes on and then disppaears. This is happening on multiple sites that i have. here is one example.
    http://hoyin.gorillaboston.com/index.html
    If you mouse over the yellow boxes you will see the display come on. The yellow boxes are the triggers alone with a color fill provided by muse. If you scroll through them quickly and then stop at one, even if you are in the dead center of the trigger and it recognizes it's on rollover, the display will appear and disappear.
    HELP!
    Thanks Adobe Community!

    From more testing it seems that chrome is not recognizing when I mouse over the trigger for the tool tip to become active but instead stay on the mouse over state.

  • Displaying the full text as a tool tip from selectbox(combobox)

    Hi friends,
    I struggling with the following problem.
    In the struts application the selectbox contain the text but it is not displaying the total teat because of the text to large.but i want to display the text in the form of tool tip when the mouse over on the selectbox.
    please find out this problem

    Hi..
    <logic:notEmpty property="tooltip" name="goods">
    <html:text styleClass="maskenInfoTypo" property="prefix" size="3" maxlength="3" title="<bean:write name="goods" property="tooltip"/>"/>
    </ogic:notEmpty>
    The tooltip is not coming. Whatever you give in title attribute is being taken as a string. I tried with both single quote and double quote
    But if you give the same bean write in alert(given below) all the values are coming properly
    <script>
    <logic:notEmpty property="tooltip" name="goods">
    alert('<bean:write name="goods" property="tooltip"/>');
    </logic:notEmpty>
    </script>
    Please help me��.

  • JSlider + Display value in a text tool tip box

    Hello,
    I am new to Java. I want to display the value in a text tool tip box of the JSlider as the user moves the knob . Is there any way to achieve this.
    I tried setting up the value of text tool tip in the stateChanged method. But that didn't helped
    Ritesh

    Finally Got it working. Below I am attaching the code for reference
    Thanks for your code. It came very handy
    The only problem is that toolTextTip is appearing on one side rather than below the cursor.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.event.*;
    public class EventTest
    public static void main(String[] args)
    JFrame f = new JFrame();
    System.out.println("starting application");
    f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    f.getContentPane().add(new setSlider(),"North");
    JSlider slide = new JSlider();
    slide.setToolTipText("Hello");
    f.getContentPane().add(slide,"South");
    f.setSize(400,400);
    f.setLocation(200,200);
    f.setVisible(true);
    class setSlider extends JSlider implements ChangeListener, MouseMotionListener{
    public setSlider(){
    setToolTipText("hello " + new Integer(getValue()).toString());
    this.setMaximum(10);
    this.setMinimum(0);
    this.setValue(2);
    this.setMajorTickSpacing(2);
    this.setMinorTickSpacing(1);
    this.setPaintTicks(true);
    this.setPaintLabels(false);
    this.addMouseMotionListener(this);
    this.addChangeListener(this);
    public void stateChanged(ChangeEvent e) {
    setToolTipText(new Integer(getValue()).toString());
    System.out.println(this.getToolTipText());
    KeyStroke controlF1 = KeyStroke.getKeyStroke("control F1");
    ActionListener toolTipAction = getActionForKeyStroke( controlF1 );     
    if (toolTipAction != null)     {          
    ActionEvent postTip = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "");
    toolTipAction.actionPerformed( postTip );
    public void mouseDragged(MouseEvent e){
    System.out.println("here");
    setToolTipText(new Integer(getValue()).toString());
    System.out.println(this.getToolTipText());
    KeyStroke controlF1 = KeyStroke.getKeyStroke("control F1");
    ActionListener toolTipAction = getActionForKeyStroke( controlF1 );     
    if (toolTipAction != null)     {          
    ActionEvent postTip = new ActionEvent(this, ActionEvent.ACTION_PERFORMED, "");
    toolTipAction.actionPerformed( postTip );
    public void mouseMoved(MouseEvent e){

  • I would like to see the actual email address in a Tool Tip when I mouse over the From address

    I use Thunderbird to access my IMAP email account with a non-enormous ISP. Thunderbird is a great email client.
    One thing I really miss when using Thunderbird vs. going to my email using a browser: in the browser, when I mouse over the From email address, a tool tip pops up showing me the actual email address, not the alias (or whatever it's called). Please see the attached image for an example of the mouse over tool tip. Is there a way to do this in Thunderbird?

    more misinformation and urban myths here than facts.
    1. Thunderbird blocks remote images by default.
    2. Thunderbird does not allow scripts in mail. If they are there they do not run.
    3. The only link SPAMMERS or anybody in marketing gets to you is when you download their remote images, run scripts in the mail or click on links to go to their web sites.
    4. When I or a spammer send a mail to say [email protected] Most mail servers will refuse delivery unless the address exists on their server.
    5. True spammers do not care if a large percentage of the mail they send is to dead email addresses and they make little or no effort to validate active addresses. Corporations like Walmart, Woolworths here in Australia, Ebay and Paypal are very interested.
    With that knowledge, you are now aware that opening the mail tells a spammer nothing even in the remote chance they are interested.
    Oh and the source of the urban myth is Microsoft whose mail clients allow scripting, remote images and uses the file extension of the file not it's mime type to determine how to open it.
    That is the difference between a mail client where the developers think security first and one where the developers give the user what they want and try to tack on security after the fact.

Maybe you are looking for