Tooltip for a JLabel of a renderer

Hello,
I'd like to set a tooltip for certain labels (defined both with an icon and text) of a tree cell renderer and a table cell renderer, too (extended of superclasses javax.swing.tree.DefaultTreeCellRenderer and javax.swing.table.DefaultTableCellRenderer, resp.) using a statement like
rendererLabel.setTooltipText(myToolTip);
Unfortunately no tooltip appeared after hovering the mouse cursor over the icon or text of the tree label.
I also tried to set
ToolTipManager.sharedInstance().registerComponent(tree);
before instantiating the renderer - also with no effect to the tooltip behaviour.
Currently I work with Java 1.5.0_16.
What may be the reason, that no tooltip appears?
How can a tooltip be realizied for labels in tree and tablre renderers?
Thomas Wiedmann

The renderer code has this structure:
public class MyRenderer extends DefaultTreeCellRenderer {
     public Component getTreeCellRendererComponent(JTree tree, Object value, boolean isSelected, boolean isExpanded, boolean isLeaf, int index, boolean hasFocus) {
          JTextPanel pane = new JTextPanel();
          pane.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 0));
          if (data instanceof MyDataObject) {
               MyDataObject myObj = (MyDataObject)data;
               JLabel label = new JLabel();
               label.setIcon(myObj.getIcon());
               label.setText(myObj.getInfo());
               label.setToolTipText("MyTooltip");
               pane.add(label);
          return pane;
Thomas Wiedmann

Similar Messages

  • Tooltip for AttributedString?

    Hi all,
    I format text in a JTextPane with Styles and Attributes. This works fine and looks like I expected. Is it possible to add a Tooltip to an AttributedString?
    I tried to add an AttributeComponent (in this case a JLabel) instead of the attributed string, because I could set a Tooltip for the JLabel. But the JLabel is not shown in my JTextPane. Maybe someone can give me a hint how to add a Tooltip to an AttributedString or how to display the JLabel as ComponentAttribute.
    Thank you.
    Axel

    Here's some code for a MouseMotionListener I put on my JTextPane and use to implement a hyperlink cursor over styled text representing a url reference:
    class TextPaneMouseMotion extends MouseMotionAdapter
      public void mouseMoved(MouseEvent e)
        JTextComponent jt = (JTextComponent)e.getComponent();
        int pos = jt.viewToModel(e.getPoint());
        if (pos >= 0)
          Element el = d.getCharacterElement(pos);
          AttributeSet as = el.getAttributes();
          if (as.getAttribute(urlRef__) != null)
            jt.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
          else
            jt.setCursor(Cursor.getDefaultCursor());
    }You can put anything you like into thje style - not just text attributes. Define your own keys (urlRef__ in my case) and if they are present when the mouse is over that part of the text then take the appropriate action.
    So in your case may be put the tool tip text into the style against your own well-known key and if its there in the mouse listener set the tool tip on the JTextPane.

  • Multiline tooltip for JComboBox items.

    Hi, As the title suggests I'd like to create a multiline tooltip for items in a combobox list.
    I have implemented a multiline tooltip renderer which works perfectly on any component except JComboBox items.
    I have also implemented a ListCellRenderer for a combobox that enables tooltips for the combobox items. Also works perfectly, except that they are single line tooltips.
    The tooltip text is read from an xml file, therefore I have no control on how long the line of text is. Most of the time the text also contains newlines.
    This is the method (overridden from JComponent) added to a subclass of a component so that that component uses the MultiLineToolTip:
        public JToolTip createToolTip() {
            MultiLineToolTip tip = new MultiLineToolTip(this);
            tip.setComponent(this);
            return tip;
        }And this is the ListCellRenderer used on the combobox, so that items have (single-line) tooltips enabled:
        private class ToolTipEnabledComboBoxRenderer extends JLabel implements ListCellRenderer{
             public ToolTipEnabledComboBoxRenderer(){
                  setOpaque(true);
             public Component getListCellRendererComponent(JList list,Object value,
                                                              int index,boolean isSelected,
                                                              boolean cellHasFocus) {
                  String entry = (String)value;
                  if (isSelected || cellHasFocus) {
                       this.setBackground(list.getSelectionBackground());
                       setForeground(list.getSelectionForeground());
                  } else {
                       this.setBackground(list.getBackground());
                       setForeground(list.getForeground());
                  this.setText(entry);
                  if(isSelected || cellHasFocus){
                       if(constraint!=null &&combobox!=null &&
                                   constraint.getType() == Constrained.CONTROLLED_VOCABULARY){
                            String tooltip = ((ControlledVocabulary)constraint).getEntryDescription(entry);
                            if(tooltip==null || tooltip.equals("")){
                                 tooltip="";
                            list.setToolTipText(tooltip);
                  return this;
        }It seems to me that what I have to do is subclass the list used by the combobox and override the createToolTip() method. But how can I set the list used by the combobox? As far as I know the only time I can access the list is in the getListCellRendererComponent() method of the ListCellRenderer, in which the list is a parameter.
    Any ideas?
    Don

    Hello,
    <p>Have you seen this one?</p>
    Francois

  • Tooltip for a JOptionPane.showConfirmDialog??

    I can't get this to work, any ideas on how to reference the OK & Cancel buttons of the "JOptionPane.showConfirmDialog" and create a custom tooltip for each??
    // --------- test to see if the current file was modified and give an option to save first.
    if (changed)
    // ----- display pop-up alert --------------------------------------------------------------
    int confirm = JOptionPane.showConfirmDialog(null,
    "Click OK to discard current changes, \n or Cancel to save before proceeding.", // msg
    "Unsaved Modifications!", // title
    JOptionPane.OK_CANCEL_OPTION, // buttons displayed
                        // JOptionPane.ERROR_MESSAGE
                        // JOptionPane.INFORMATION_MESSAGE
                        // JOptionPane.PLAIN_MESSAGE
                        // JOptionPane.QUESTION_MESSAGE
    JOptionPane.WARNING_MESSAGE,
    null);
    // -- set the tool tip for the buttons here -- ??????
    // public Point getToolTipLocation( MouseEvent event);
    // public JToolTip createToolTip( );
    // toolTipText
    // Point getToolTipLocation( MouseEvent MOUSE_CLICKED);
    JOptionPane.getToolTipLocation(OK_OPTION, Click to discard current changes."")
    // OKButton.setToolTipText("Click to discard current changes.");
    // CancelButton.setToolTipText("Click to save the current file.");
    if (confirm != JOptionPane.YES_OPTION)
    { //user wants to save changes
    try {
    // save the file
    catch(Exception e) {}
    } // close "if (changed)"
    // ----- display pop-up alert --------------------------------------------------------------

    The renderer code has this structure:
    public class MyRenderer extends DefaultTreeCellRenderer {
         public Component getTreeCellRendererComponent(JTree tree, Object value, boolean isSelected, boolean isExpanded, boolean isLeaf, int index, boolean hasFocus) {
              JTextPanel pane = new JTextPanel();
              pane.setLayout(new FlowLayout(FlowLayout.LEFT, 2, 0));
              if (data instanceof MyDataObject) {
                   MyDataObject myObj = (MyDataObject)data;
                   JLabel label = new JLabel();
                   label.setIcon(myObj.getIcon());
                   label.setText(myObj.getInfo());
                   label.setToolTipText("MyTooltip");
                   pane.add(label);
              return pane;
    Thomas Wiedmann

  • Setting tooltip for columns in a JTable

    Hi!
    I have a JTable inside a JScrollPane. How do I set tooltip for each columnheader of the JTable?
    I have noted that if I don�t have the JTable within the JScrollPane, the columnheaders are not shown.
    Regards
    Johan

    1) You need to set the tooptip text on the renderer for the column (yourTable.getColumnModel().getColumn(...).getHeaderRenderer()).
    2) The header is a separate component to the table. When you add a table to a scroll pane it automatically adds the header to the scroll pane too. You can get the component (yourTable.getTableHeader()) and add it to your own container if you wish.

  • Tooltip for mousedragged

    I did a program in applet..I want to set tooltip for the drawing..i.e.,when the oval is dragged its new co-ordinates should be displayed by using the tooltip..How can i do this..
    .import java.awt.event.MouseListener;
    import java.awt.event.MouseMotionListener;
    import java.awt.geom.Ellipse2D;
    import java.awt.geom.Line2D;
    import java.awt.geom.Point2D;
    import java.text.DateFormat;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.Calendar;
    import java.util.Date;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.BorderLayout;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import javax.swing.BorderFactory;
    import javax.swing.border.Border;
    public class mouseevent extends JApplet
          private static final int BALL_DIAMETER = 40; // Diameter of ball
        //--- instance variables
        /** Ball coords.  Changed by mouse listeners.  Used by paintComponent. */
        private int _ballX     = 450;   // x coord - set from drag
        private int _ballY     = 50;   // y coord - set from drag
        /** Position in ball of mouse press to make dragging look better. */
        private int _dragFromX = 0;    // pressed this far inside ball's
        private int _dragFromY = 0;    // bounding box.
        /** true means mouse was pressed in ball and still in panel.*/
        private boolean _canDrag  = false;
        JLabel label;
        String s= "aswedfrtyhgqwsadrftlopqasnhfgrchildnode1";   
        int width = s.length();   
        int border = 2;    int margin = 10;   
        int rectx = margin+border,recty =margin+border+63;   
        int rectwidth = 8, rectheight = 6;   
        int imgborder = 10;   
        int imgline1 = 300;  
        int labellocx = rectx+imgborder+13;  
        int labellocy = recty+imgborder-1;   
        int circlex = rectx+rectwidth;
        int circley = recty+rectheight;  
        int x =rectx+rectwidth+10;  
        int y = recty+rectheight+10;
        int x1 = x+17; 
        int y1 = y+20;  
        int titlebarx= 300;
        int titlebary = 40;  
        boolean title = true;
        String date[] = {"0","4","8","12","16","20","24"}; 
        String day[] = {"Mon","Tue","Wed","Thu","Fri","Sat"};
        int width1 = 180;
    //    int f2= x+168;
        int n =180;
    //    int dayx = 385;
        long From ;
        long To ;
        ArrayList dateList;
         int rect1x= 300;
        int rect1y = 100;
        int rect1width= 50;
        int rect1heigth = 50;
        boolean candrag = false;
        public void init()     
            Container cont = getContentPane();   
            cont.setLayout(new BorderLayout());
            // to see the scrollpane, the scrollpane has to be smaller        
            // then the component held within its viewport             
            setPreferredSize(new Dimension(300, 300));             
            JScrollPane scroll = new JScrollPane();              
            getContentPane().add(scroll, BorderLayout.CENTER);        
            scroll.getViewport().add(new Imagepanel());       
    private class Imagepanel extends JPanel implements MouseListener,MouseMotionListener
            JScrollPane scroll = new JScrollPane();      
            Rectangle rect = new Rectangle(rectx,recty,rectwidth,rectheight);
            Rectangle rect1  = new Rectangle(rect1x,rect1y,rect1width,rect1heigth);
            Ellipse2D.Double circle = new Ellipse2D.Double(_ballX,_ballY,BALL_DIAMETER,BALL_DIAMETER);   
            Ellipse2D.Double circle1 = new Ellipse2D.Double(x+10,y+10,4,4);    
            boolean selected = false;  
            boolean selected1 = false;     
            int w ;     
        Imagepanel()       
            // setting the component to be largenr than the scrollpane           
            // just so we'll see scrollbars.
            setPreferredSize(new Dimension(32710,32710));      
            scroll = new JScrollPane();     
            add(scroll);                 
            addMouseListener(this);       
            addMouseMotionListener(this);
            setBorder(BorderFactory.createLineBorder(Color.BLACK, border));          
        protected void paintComponent(Graphics g)         
            int n = 168;
            int x = 300;
            int x1=300;
            int x2=x;
            int daydx=(width1/2);
            int dayx =(daydx+x);
            int f2= x+n;
            From = new java.util.GregorianCalendar(2007,01,01).getTime().getTime();
            To = new java.util.GregorianCalendar(2007,06,30).getTime().getTime();
            double Difference = To-From;
            long days = Math.round((Difference/(1000*60*60*24)));
            int noday = (int)days;
            Date fromDate = new java.util.GregorianCalendar(2007,01,01).getTime();
            Date toDate = new java.util.GregorianCalendar(2007,06,30).getTime();
            super.paintComponent(g);            
            Graphics2D g2 = (Graphics2D) g;             
            g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,RenderingHints.VALUE_ANTIALIAS_ON);       
            Font font = new Font("Ariel",Font.PLAIN,11); 
            Font font1 = new Font("Ariel",Font.PLAIN,9);
            g2.fillOval(_ballX, _ballY, BALL_DIAMETER-20, BALL_DIAMETER-20);
            g2.setBackground(Color.GRAY);
            //drawing the tilte bar     
            g2.setBackground(Color.WHITE);  
            g2.drawLine(imgline1,0,imgline1,getHeight()); 
            g2.setPaint(new Color(0,128,192));
            g2.fillRect(imgborder,imgborder,290,45);
            //g2.drawLine(margin,margin,titlebarx,titlebary);              
            //drawing the root node and labeling      
            g2.draw(rect);
            g2.setPaint(Color.WHITE);
            g2.drawLine(margin,margin,titlebarx,titlebary); 
            g2.drawString("RESOURCE",40,40);       
            g2.drawString("TIME",200,25);
            g2.setPaint(Color.green);
            g2.drawString("sadasd",344,22);
            g2.draw(circle);
            rect.setLocation(rectx,recty);      
            rect.setSize(rectwidth,rectheight);
            g2.setPaint(Color.BLACK);
            g2.drawString(" aswedfrtyhgqwsadrftlopqasnhfgrchildnode1",rectx+rectwidth+05,recty+rectheight);               
            for (int i = 0;i<noday;i++)
            Calendar  c = Calendar.getInstance(); // current date
                c.add(Calendar.DATE, i); // add one day
                SimpleDateFormat sdf = new  SimpleDateFormat("MM/dd/yy"); // use the pattern: day_of_month
                String str = sdf.format(c.getTime()); // fromat the date to string
                System.out.println(str); // print it at the console
                for (int j=0;j<6;j++)
                    g2.setFont(font1);
                    g2.drawLine(x1,40,x1,35);
                    g2.drawString(date[j],x1,35);
    //              g2.drawString(day[j],dayx,20);
                    g2.drawString("24",f2,35);
                    f2+=width1;
                    x1+=30;
    //              dayx=+170;
                g2.drawRect(x,10,width1,30);
                x+=width1;
                g2.drawString(str,dayx,20);
                dayx+=180;
            for(int k=0;k<n;k++)
                for(int l=0;l<6;l++)
                Calendar c = Calendar.getInstance(); // current datem
                c.add(Calendar.DAY_OF_WEEK, k); // add one day
                SimpleDateFormat sdf = new SimpleDateFormat("EEE"); // use the pattern: day_of_month
                String str = sdf.format(c.getTime()); // fromat the date to string
                System.out.println(str); // print it at the console
                g2.drawString(str,dayx,5);
    //          g2.drawString(day[l],dayx,20);
                dayx+=180;
            //dividing the drawing panel      
            //drawing for the click event       
            if(selected)       
                Color color = Color.orange; 
                g2.fill(circle);
                g2.draw(circle);          
                //              g2.drawRoundRect(x+30,y+15,200,12,5,5);        
                g2.drawString("aswedfrtyhgqwsadrftlopqasnhfgrchildnode1",x+15,y+5);     
                g2.drawRect(300,y,100,15);      
            if(selected1)      
                g2.setFont(new Font("Arial",Font.PLAIN,12)); 
                g2.fill(circle1);
                g2.draw(circle1);           
                g2.drawString(" aswedfrtyhgqwsadrftlopqmasnhfgrchildnode1",x1+15,y1+5);  
        public void update(Graphics g)    
            paint(g);   
        public void mouseClicked(MouseEvent e)          
            //imagePaneMouseClicked(e);              
        private void imagePaneMouseClicked(MouseEvent e)        
            Point p = e.getPoint();         
            if (rect.contains(p))                  
                if (!selected)              
                    selected = true;        
                    repaint();               
            if(circle.contains(p))     
                if(!selected1)           
                    selected1 = true;    
                    repaint();           
            if(rect.contains(p)) 
                if(e.getClickCount() == 2)    
                    selected = false;  
                    repaint();      
        public void mousePressed(MouseEvent e)        
             int x = e.getX();   // Save the x coord of the click
            int y = e.getY();   // Save the y coord of the click
            if (x >= _ballX && x <= (_ballX + BALL_DIAMETER)
                    && y >= _ballY && y <= (_ballY + BALL_DIAMETER)) {
                _canDrag = true;
                _dragFromX = x - _ballX;  // how far from left
                _dragFromY = y - _ballY;  // how far from top
            } else {
                _canDrag = false;
        public void mouseReleased(MouseEvent e) {        }               
        public void mouseEntered(MouseEvent e) {        }          
        public void mouseExited(MouseEvent e) { 
            candrag = false;
            public void mouseDragged(MouseEvent e) {
              if (_canDrag)
              {   // True only if button was pressed inside ball.
                //--- Ball pos from mouse and original click displacement
                _ballX = e.getX() - _dragFromX;
                _ballY = e.getY() - _dragFromY;
                //--- Don't move the ball off the screen sides
                _ballX = Math.max(_ballX, 0);
                _ballX = Math.min(_ballX, getWidth() - BALL_DIAMETER);
                //--- Don't move the ball off top or bottom
                _ballY = Math.max(_ballY, 0);
                _ballY = Math.min(_ballY, getHeight() - BALL_DIAMETER);
                this.repaint(); // Repaint because position changed.
                this.add(label);
                label.setText(""+_ballX+_ballY);
                label.setLocation(_ballX,_ballY);
            public void mouseMoved(MouseEvent e) {
    }

    The label is not getting displayed...the program throws some exception...
    Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
    at java.awt.Container.addImpl(Container.java:1015)
    at java.awt.Container.add(Container.java:351)
    at javaapplication5.mouseevent$Imagepanel.mouseDragged(mouseevent.java:346)
    at java.awt.Component.processMouseMotionEvent(Component.java:5536)
    at javax.swing.JComponent.processMouseMotionEvent(JComponent.java:3144)
    at java.awt.Component.processEvent(Component.java:5257)
    at java.awt.Container.processEvent(Container.java:1966)
    at java.awt.Component.dispatchEventImpl(Component.java:3955)
    at java.awt.Container.dispatchEventImpl(Container.java:2024)
    at java.awt.Component.dispatchEvent(Component.java:3803)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3909)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
    at java.awt.Container.dispatchEventImpl(Container.java:2010)
    at java.awt.Component.dispatchEvent(Component.java:3803)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
    at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)

  • Tooltip for datagrid's cells

    I know how to create a tooltip for datagrid and/or its
    columns. Is it possible to create a tooltip (or something similar)
    for each cell? So whenever the mouse is over a certain cell, a tip
    would be shown for that cell that depends on the value of the cell.
    Similar functionality can often be seen in web-based database apps:
    an Ajax query gets related data from a database on mouseOver.
    My need and idea is to
    - show a simple text list as a tooltip
    - the text would be fetched from a database via a web service
    - the fetch would be based on datagrid's (hidden) rowid and
    each column's (hidden) column id (which are real database columns)
    - the database structure is an n:m relation i.e. one
    rowid+colid can refer to several items that are then used in the
    tooltip
    Use case: A number is displayed in the datagrid. The need is
    to display 0-n references related to that specific figure (e.g.
    book names, notes etc) in the tooltip. Next cell's tooltip would be
    showing different references.
    Anybody any ideas or suggestions? Thanks!

    Hi,
    Did you try creating a custom itemRenderer and handling the
    mouse events for that item renderer component. There is also a
    property called dataTipFunction, please check that too.
    Hope this helps.

  • JTree- seperate tooltip for each node

    hi,
    i would like to have different tooltips for different nodes. in all tutorials they have given the method of assinging tooltip in a general class i.e. setting a tooltip for all leaf nodes etc.. But i would like to have seperate tooltip for each node.
    thanx

    hi,
    Doing both of the above tasks will lead to have a tooltip same for all nodes. But i need all the toltips to be different for different leafs.
    However i solved that problem using mouseListeners and getPath() method..
    Now i have another problem. when i move my mouse over any leaf node(not necessarily selecting just on moving over the text) i would like to change the color of the text of that particular node to another color. If i use renderer to do this then it may change the color of all the nodes.
    how it could be done for only a particular node and not for all. Aren't there any renderers for nodes.
    thanx

  • Setting icons in a JLabel table cell renderer

    I am using a JLabel as a renderer for one of the columns in a JTable
    Within the renderer class I use the following code to set the icon on the label. The icon is decided on the information for that particular cell which is held in the table model.
    <CODE>
    URL url = c.getResource("/images/icon.gif");
    this.setIcon(new ImageIcon(Toolkit.getDefaultToolkit().getImage(url)));
    <CODE>
    When the icon gets set for one renderer it gets set for all other renderers as well. This does not happen when I set the text on one of the JLabel renderers.
    How can I make it so that the icon only gets changes for one of the renderers.

    You need to put this code into the getTableCellRendererComponent method. You should probably store all the possible icons at the class level otherwise you might end up loading an image each time a cell is rendered:
    public class MyTableCellRenderer extends DefaultTableCellRenderer
      protected Icon icon1;
      protected Icon icon2;
      protected Icon icon3;
      public MyTableCellRenderer()
        icon1 = new ImageIcon(c.getResource("/images/icon1.gif"));
        icon2 = new ImageIcon(c.getResource("/images/icon2.gif"));
        icon3 = new ImageIcon(c.getResource("/images/icon3.gif"));
      public Component getTableCellRendererComponent(...)
        if(...)
          setIcon(icon1);
        else if(...)
          setIcon(icon2);
        else if(...)
          setIcon(icon3);
        else
          setIcon(null);
        return super.getTableCellRendererComponent(...);
    }Hope this helps.

  • Tooltip for components located in TableCellRenderer component

    how can I add ToolTips for each components located in TableCellRenderer component?
    In bellow example I took panel as TableCellRenderer component. I put two labels in it. I need diffrent tooltips for two labels.
    import java.util.*;
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.awt.event.*;
    * @author kesava
    public class TooltipForTableCell extends JFrame {
    JTable table;
    DefaultTableModel tableModel;
    * Creates a new instance of TooltipForTableCell
    public TooltipForTableCell() {
    init();
    setDefaultCloseOperation(EXIT_ON_CLOSE);
    pack();
    setVisible(true);
    public void init() {
    Vector<String> columns = new Vector<String>();
    columns.add("col-1");
    columns.add("col-2");
    Vector<Vector<String>> data = new Vector<Vector<String>>();
    Vector<String> row = new Vector<String>();
    row.add("aaa-1");
    row.add("bbb-1");
    data.add(row);
    row = new Vector<String>();
    row.add("aaa-2");
    row.add("bbb-2");
    data.add(row);
    tableModel = new DefaultTableModel(data, columns);
    table = new JTable(tableModel) {
    public int getRowHeight() {
    return 25;
    table.getColumn("col-1").setCellRenderer(new CustomTableCellRenderer());
    table.getColumn("col-2").setCellRenderer(new CustomTableCellRenderer());
    getContentPane().add(new JScrollPane(table));
    public class CustomTableCellRenderer extends JPanel implements TableCellRenderer {
    String pos;
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
    pos = "(" + row + "," + column + ")";
    JLabel label1 = new JLabel(value.toString());
    JLabel label2 = new JLabel(pos);
    removeAll();
    add(label1);
    add(label2);
    return this;
    public static void main(String[] args){
    new TooltipForTableCell();
    }

    lanp16108103, please don't post in threads that are long dead and don't hijack another poster's thread. When you have a question, start your own topic. Feel free to provide a link to an old post that may be relevant to your problem.
    I'm locking this thread now.
    db

  • How to make tooltip for DataGridColumn

    Hi, I'm trying to get a tooltip for whenever the user mouses
    over a column header in a DataGrid. I've seen some talk about
    creating my own ItemRenderer to do this but looking at the Flex
    docs, I see that the existing DataGridItemRenderer for a
    DataGridColumn has a tooltip attribute but I have been unsuccessful
    in getting it to work. Should I in fact make my own ItemRenderer or
    is there any way to expose it in the existing DataGridItemRenderer?
    Can anyone advise what the best way to do this is? Thanks!

    We can do like this:
    l_DataGridColumn.headerRenderer=new ClassFactory(YourHeaderItemRenderer);// use custom renderer instead of the default DataGridItemRenderer
    And in you class YourHeaderItemRenderer extends DataGridItemRenderer, you can override some method:
    override public function set toolTip(value:String):void {
         //set toolTip value here:    
         toolTip= "column description";
    this one is not dynamic, so if we want to,  we can extend the DataGridColumn to add the toolTip field, and use it:
    l_DataGridColumn.headerRenderer=new ClassFactory(YourHeaderItemRenderer);// use custom renderer instead of the default DataGridItemRenderer
    l_DataGridColumn.toolTip="compute it here";
    override public function set toolTip(value:String):void {
         //set toolTip value here:    
         toolTip= (data as YourDataGridColumn).toolTip;
    Of course in this case, the dataGrid columns must use the YourDataGridColumn instead of DataGridColumn.
    All that to have a toolTip for the column, it's sad :-)

  • How to assign a tooltip for a field in ALV editable grid?

    I have to display some instructions ( 50 chars long) for an editable field in alv.
    How to do this?
    BCALV_DEMO_TOOLTIP tells about assiging tooltip to an icon or symbol.
    Thanks,
    Ven..

    Neither of these two example programs help much in regards to tooltips against any field of any row. Both of these examples use tooltips for Icons. I have also been looking for a single example of tooltips usage outside of these two programs, and have found nothing in SAP, or on the internet, so far.
    Having said that, I have tried to implement the same method used by the later example, but have not got this to work. What I think we need is an example of this functionality where these Icons are not used!. I believe.
    Gary King

  • Jquery tooltip for sharepoint 2013 list (newform.aspx)

    I am looking for a simple solution/jquery tooltip for SharePoint list form fields.
    Something like below , but this one displays static text for each column and want tooltip text for each of my list column
    <script type="text/javascript" language="javascript" src="/wz_tooltip.js"></script><o:p></o:p>
    <a href="#" onmouseover="Tip('(This is test tooltip )');" onmouseout="UnTip();">
    Thanks in advance!
    <o:p></o:p>
    Amrita Talreja

    When you assign "Description" for every field in sharepoint list.SharePoint by default show this desc in a span just below the field control , like this.
    <span class="ms-metadata">This is simple desc</span>
    What you can try in jquery/javascript is to -
    - Search for this span [class="ms-metadata"] in your form table (table[class="ms-formtable"])
    - save its text() in a variable - var txtDesc = $("span selector").text();
    - Hide this span -$("span selector").hide()
    - Now you have dynamic desc message , you can add this as an "Title" attribute to your field control (textbox and other control)
    - $("your field control selector").attr("Title", txtDesc );
    Or can add a hyperlink for this -
    <a href="#" onmouseover="Tip('"+ txtDesc +"');" onmouseout="UnTip();">
    Thanks
    Ganesh Jat [My Blog |
    LinkedIn | Twitter ]
    Please click 'Mark As Answer' if a post solves your problem or 'Vote As Helpful' if it was useful.

  • Is there a way to have tooltips for every column in a TableView?

    Hi there!
    I found in documentation that any node and control can show a tooltip ( http://docs.oracle.com/javafx/2/api/javafx/scene/control/Tooltip.html ) but I can't get tooltips to work for TableColumn (a column from TableView).
    Do you have any idea how could I have tooltips for each column of the table view?

    TableColumn's are neither controls nor nodes, so you can neither set nor install tooltips on them.
    You can use cellfactories to set tooltips on cells generated from the factories.
    You can use css style lookups (node.lookup function) to get access to table nodes (such as the headers) after the tableview has been displayed on a stage and then manipulate the displayed nodes to add tooltips. It's not a great approach, but it is the only approach I know at the moment that would work.

  • How to implement tooltip for the list items for the particular column in sharepoint 2013

    Hi,
    I had created a list, How to implement tooltip for the list items for the particular column in SharePoint 2013.
    Any help will be appreciated

    We can use JavaScript or JQuery to show the tooltips. Refer to the following similar thread.
    http://social.technet.microsoft.com/forums/en/sharepointdevelopmentprevious/thread/1dac3ae0-c9ce-419d-b6dd-08dd48284324
    http://stackoverflow.com/questions/3366515/small-description-window-on-mouse-hover-on-hyperlink
    http://spjsblog.com/2012/02/12/list-view-preview-item-on-hover-sharepoint-2010/

Maybe you are looking for

  • SSIS query returns no results - same query in SQL management studio works

    Hello, I'm running a very simple join to get a result set: SELECT dbo.sap_contracts.svc_id, dbo.sap_contracts.svc_code, dbo.sap_contracts.quantity, dbo.sap_contracts.start_date, dbo.sap_contracts.end_date FROM dbo.sap_contracts INNER JOIN dbo.contrac

  • How to mention encoding in servlet.

    Hi How to mention encoding in servlet. Regards Arghya Banerjee

  • Data source and Extract Structure

    Hi all, I have a doubt on Data source and Extract Str, when i used one info cube with some char and kf's after i did extraction shall we change the extract strcuture prequently other wise better to use all the predefined extract strcuture hide in dat

  • JTable - Disable some columns

    How should I disable some columns in a JTable so that they cannot be edited at all? The methods provided do this but double clicking the column enables it.

  • What is the 3rd party Vender (SMS)

    Verizon finally replied me and explained $9.99 is for Premium SMS by third party vendor. But I don't sign on any third party vendor.  What is the Premium SMS by third party vendor.? Anyone has same situation like me?