Different tooltips in JTreeTable

Hi all!
I have a JTreeTable (the rows are the nodes of a tree), very similar to the one at
http://java.sun.com/products/jfc/tsc/articles/treetable2/
I'd like to add different ToolTips in every node (in the example in the sun's site, for example see as a tooltip the file's name). How can I do that? Should I do that in the cell render method? Has anybody any example about that?
Feedbacks are really appreciated!
Thanks
Franky

Sure, sorry for the mistake about the tags...Follows the class I use to render the JTreeTable. My doubt is that I have to do something with the mouse listener to active the tooltip, could it be?
Thanks
public class TreeTableCellRenderer
          extends JTree
          implements TableCellRenderer {
          protected int visibleRow;
          protected Border highlightBorder;
          public TreeTableCellRenderer(TreeModel model) {
               super(model);
          public void updateUI() {
               super.updateUI();
               // Make the tree's cell renderer use the table's cell selection
               // colors.
               TreeCellRenderer tcr = getCellRenderer();
               if (tcr instanceof DefaultTreeCellRenderer) {
                    DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
                    // For 1.1 uncomment this, 1.2 has a bug that will cause an
                    // exception to be thrown if the border selection color is
                    // null.
                    // dtcr.setBorderSelectionColor(null);
                    dtcr.setTextSelectionColor(
                         UIManager.getColor("Table.selectionForeground"));
                    dtcr.setBackgroundSelectionColor(
                         UIManager.getColor("Table.selectionBackground"));
          public void setRowHeight(int rowHeight) {
               if (rowHeight > 0) {
                    super.setRowHeight(rowHeight);
                    if (JSortTreeTable.this != null
                         && JSortTreeTable.this.getRowHeight() != rowHeight) {
                         JSortTreeTable.this.setRowHeight(getRowHeight());
          public void setBounds(int x, int y, int w, int h) {
               super.setBounds(x, 0, w, JSortTreeTable.this.getHeight());
          public void paint(Graphics g) {
               g.translate(0, -visibleRow * getRowHeight());
               super.paint(g);
               // Draw the Table border if we have focus.
               if (highlightBorder != null) {
                    highlightBorder.paintBorder(
                         this,
                         g,
                         0,
                         visibleRow * getRowHeight(),
                         getWidth(),
                         getRowHeight());
           * TreeCellRenderer method. Overridden to update the visible row.
          public Component getTableCellRendererComponent(
               JTable table,
               Object value,
               boolean isSelected,
               boolean hasFocus,
               int row,
               int column) {
               Color background;
               Color foreground;
               this.setToolTipText("Tooltip");
               System.out.println("Tooltip "+this.getToolTipText());
               if (isSelected) {
                    background = table.getSelectionBackground();
                    foreground = table.getSelectionForeground();
               } else {
                    background = table.getBackground();
                    foreground = table.getForeground();
               highlightBorder = null;
               if (realEditingRow() == row && getEditingColumn() == column) {
                    background = UIManager.getColor("Table.focusCellBackground");
                    foreground = UIManager.getColor("Table.focusCellForeground");
               visibleRow = row;
               setBackground(background);
               TreeCellRenderer tcr = getCellRenderer();
               if (tcr instanceof DefaultTreeCellRenderer) {
                    DefaultTreeCellRenderer dtcr = ((DefaultTreeCellRenderer) tcr);
                    if (isSelected) {
                         dtcr.setTextSelectionColor(foreground);
                         dtcr.setTextNonSelectionColor(foreground);
                         dtcr.setBackgroundSelectionColor(background);
                    } else {
                         dtcr.setTextNonSelectionColor(foreground);
                         dtcr.setBackgroundNonSelectionColor(background);
                    Icon tutorialIcon;
                    ImageIcon icon3= new ImageIcon("C:\\eclipse\\workspace\\Java\\itemrevision.gif");
                    tutorialIcon=icon3;
                    dtcr.setOpenIcon((Icon) tutorialIcon);
                    dtcr.setClosedIcon((Icon) tutorialIcon);
                    dtcr.setLeafIcon((Icon) tutorialIcon);
               return this;
     }

Similar Messages

  • How do i display different tooltip for different parts of an image

    I have a .jpg image that i would like to display different tooltips for depending in where the mouse pointer is in the image.
    Any help is appreciated.

    I edited the button template in the app.xaml so all my buttons have transparent properties for all the trigger properties and the setter properties since in this instance i have no other use for the button.
    <Application x:Class="Application"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="MainWindow.xaml">
    <Application.Resources>
    <Style TargetType="{x:Type Button}">
    <Setter Property="FocusVisualStyle">
    <Setter.Value>
    <Style>
    <Setter Property="Control.Template">
    <Setter.Value>
    <ControlTemplate>
    <Rectangle Margin="2" SnapsToDevicePixels="True" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" StrokeThickness="1" StrokeDashArray="1 2"/>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>
    </Setter.Value>
    </Setter>
    <Setter Property="Background" Value="Transparent"/>
    <Setter Property="BorderBrush" Value="Transparent"/>
    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
    <Setter Property="BorderThickness" Value="1"/>
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="Padding" Value="1"/>
    <Setter Property="Template">
    <Setter.Value>
    <ControlTemplate TargetType="{x:Type Button}">
    <Border x:Name="border" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" SnapsToDevicePixels="True">
    <ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" ContentStringFormat="{TemplateBinding ContentStringFormat}" Focusable="False" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" RecognizesAccessKey="True" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
    </Border>
    <ControlTemplate.Triggers>
    <Trigger Property="IsDefaulted" Value="True">
    <Setter Property="BorderBrush" TargetName="border" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
    </Trigger>
    <Trigger Property="IsMouseOver" Value="True">
    <Setter Property="Background" TargetName="border" Value="Transparent"/>
    <Setter Property="BorderBrush" TargetName="border" Value="Transparent"/>
    </Trigger>
    <Trigger Property="IsPressed" Value="True">
    <Setter Property="Background" TargetName="border" Value="Transparent"/>
    <Setter Property="BorderBrush" TargetName="border" Value="Transparent"/>
    </Trigger>
    <Trigger Property="ToggleButton.IsChecked" Value="True">
    <Setter Property="Background" TargetName="border" Value="Transparent"/>
    <Setter Property="BorderBrush" TargetName="border" Value="Transparent"/>
    </Trigger>
    <Trigger Property="IsEnabled" Value="False">
    <Setter Property="Background" TargetName="border" Value="Transparent"/>
    <Setter Property="BorderBrush" TargetName="border" Value="Transparent"/>
    <Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="#FF838383"/>
    </Trigger>
    </ControlTemplate.Triggers>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>
    </Application.Resources>
    </Application>

  • Adding different tooltip for a column in table??

    Hi here,
    I have read the similar title "Adding ToolTip for individual cell in the table".
    The method that use "tableModel" and "override getToolTipText" for individual cell is useful for individual cell with tooltip that i have tried.
    How could i get the tooltip for each columns and show every row value on each tooltip.I wish when mouse moved above a column and the column could show all of that column's row value.
    Please help me.
    Thanks..

    your explanation sounds a bit confusing but if i got you right
    you could do something like this in your table
    public String getToolTipText(MouseEvent me)
          int row = this.rowAtPoint(me.getPoint());
          StringBuffer tooltip = new StringBuffer();
          for(int i=0; i<getColumnCount; i++)
             tooltip.append(getValueAt(row, i).toString());
          return tooltip.toString();
       }

  • Tooltip location problem

    Ok, i have a jfram with lots of components that uses different tooltips. The tooltips display some information and can get fairly big.
    The problem i have is that the tooltips for components are located so that they maybe go outside of the actual jframe that holds all the components.
    I want the tooltips to be relocated so that they are always fully inside the jframe's edges and not go outside.
    Anyone can give any hints on how to fix this?

    Isn't this a Swing question?

  • Adding ToolTip for individual cell in the table

    Hi everybody,
    Its urgent. I want to add ToolTip for individual cells. What I have implemented, it show same ToolTip for each cell. I want different ToolTip for individual cell.
    My cells are not editable, as i need this.
    Pleae help me.
    Thanks in Advance.
    Dawoodzai

    Hi,
    See this demo pasted below-
    import java.awt.*;
    import javax.swing.*;
    public class SimpleTableDemo extends JFrame {
         public SimpleTableDemo() {
              super("SimpleTableDemo");
              Object[][] data = {
                   {"Mary", "Campione", "Snowboarding", new Integer(5), new Boolean(false)},
                   {"Alison", "Huml", "Rowing", new Integer(3), new Boolean(true)},
                   {"Kathy", "Walrath", "Chasing toddlers", new Integer(2), new Boolean(false)},
                   {"Sharon", "Zakhour", "Speed reading", new Integer(20), new Boolean(true)},
                   {"Angela", "Lih", "Teaching high school", new Integer(4), new Boolean(false)}
              String[] columnNames = {"First Name", "Last Name", "Sport", "# of Years", "Vegetarian"};
              final JTable table = new MyTable(data, columnNames);
              table.setPreferredScrollableViewportSize(new Dimension(500, 70));
              JScrollPane scrollPane = new JScrollPane(table);
              getContentPane().add(scrollPane, BorderLayout.CENTER);
         public static void main(String[] args) {
              SimpleTableDemo frame = new SimpleTableDemo();
              frame.pack();
              frame.setVisible(true);
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    public class MyTable extends JTable {
         public MyTable(Object[][] rowData, Object[] columnNames) {
              super(rowData,columnNames);
         public String getToolTipText(MouseEvent e) {
              int r = rowAtPoint(e.getPoint());
              int c = columnAtPoint(e.getPoint());
              return getValueAt(r,c).toString();
    }

  • JPanel custom tooltips in JTree not showing

    Hi,
    I use a custom TreeCellRenderer in a JTree like
    MyTreeCellRenderer extends JPanel implements TreeCellRenderer
    The panel contains two JLabels, each with a different tooltip. Although I register the tree, the panel and the two labels with the tootipmanager, no tooltips are showing up. Any idea?
    Thanks,
    Ulrich

    I'll provide my own answer:
    As it currently stands Logic Apps require a "default" response to be defined in the swagger. This is not implemented by default by an API app out of the box, but can be done relatively easily by adding a Swagger OperationFilter.
    That is to say in the
    public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
    method of the filter you will need to ensure that the operation.responses dictionary contains an entry keyed with 'default'.
    Microsoft's provided connectors contain a reference to a "Microsoft.Azure.BizTalk.Adapters.SwaggerGenerator.dll" contains a OperationFilter that will do this for you if you don't want to write one yourself.
    Final note: Having spoken to MS about this issue it is currently under review and will hopefully be resolved in a future version of LogicApps so hopefully this will all disapear.
    Edit: Also see http://blogs.msdn.com/b/hosamshobak/archive/2015/03/31/logic-app-with-simple-api-app-with-inputs-and-outputs.aspx

  • 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

  • Different screensaver for each display?

    I'm pretty sure OS X out of the box doesn't do this, but has anyone found a way to designate a different screensaver for each display, or more specifically, only have the screensaver happen on one display, while the second display goes to sleep?
    Thanks!

    Hi Nari,
    I guess that's not possible. From Web Dynpro side, dropdown is only one UI element. So  different tooltip cannot be assigned.
    However, You can find the which dropdown item is selected and assign the tooltip at runtime accordingly.
    In wdDoModifyView method, you can assign the tooltip text.
    if(!firstTime){
             IWDDropDownByIndex drp = (IWDDropDownByIndex)view.getElement("DropDownByIndex");
             drp.setTooltip(wdContext.currentNODEelement().getATTRIBUTE());
    Regards,
    Anand G

  • Dynamic tooltips on alv column

    I am displaying one alv column as the traffic lights icon.
    Depending on whether it is red, yellow or green, i want to have a different tooltip for this column.
    is this possible? if yes then can someone please tell me how to do it?
    regards,
    Priyank

    Well Sascha,
    Thanks for the response but i have a slight change in requirement now. The tooltip content will have to be fetched from the backend (database level) now through the function module which is returning the data to be displayed in the ALV. Thus, the option that seems available now is to get the tooltip content in another column in the alv, keep this column hidden and use the content of this column as the tooltip for the traffic lights column.
    Any direct way of doing this?
    By the way i tried using the following code in the domodifyview method to see if it works....did not work for me....let me know what wrong i might have been doing.
      DATA: l_ref_cmp_usage TYPE REF TO if_wd_component_usage,
            l_ref_interfacecontroller TYPE REF TO iwci_salv_wd_table,
            l_value TYPE REF TO cl_salv_wd_config_table.
      l_ref_cmp_usage =   wd_this->wd_cpuse_alv( ).
      IF l_ref_cmp_usage->has_active_component( ) IS INITIAL.
        l_ref_cmp_usage->create_component( ).
      ENDIF.
      l_ref_interfacecontroller =   wd_this->wd_cpifc_alv( ).
      l_value = l_ref_interfacecontroller->get_model( ).
      DATA: lr_column_settings TYPE REF TO if_salv_wd_column_settings,
             lr_column TYPE REF TO cl_salv_wd_column.
      lr_column_settings ?= l_value.
      DATA:
        lt_columns TYPE salv_wd_t_column_ref.
      lt_columns = lr_column_settings->get_columns( ).
      DATA:
          ls_column TYPE salv_wd_s_column_ref.
      LOOP AT lt_columns INTO ls_column.
        DATA: lr_cv TYPE REF TO cl_salv_wd_cv_standard.
        CREATE OBJECT lr_cv.
        lr_cv->set_key( 'ICON_GREEN_LIGHT' ).
        DATA: lr_textview TYPE REF TO cl_salv_wd_uie_text_view.
        CREATE OBJECT lr_textview.
        lr_textview->set_text_fieldname( ls_column-id ).
    lr_textview->set_tooltip( 'TOOLTIP FOR GREENLIGHT' ).
        lr_cv->set_editor( lr_textview ).
        ls_column-r_column->add_cell_variant( r_cell_variant = lr_cv ).
        ls_column-r_column->set_sel_cell_variant_fieldname( 'EXPIRYSTATUS' ).
        CASE ls_column-id.
          WHEN 'EXPIRYSTATUS'.
        ENDCASE.
      ENDLOOP.

  • Dynamic ToolTips for DropDownByIndex

    Hi experts,
    how can I show different tooltips for every entry in a dropdown list when I go over with my mouse?
    e.g.
    Entries in drop down list:       ToolTip:
    entry 1                                    ToolTip 1
    entry 2                                    ToolTip 2
    entry 3                                    ToolTip 3
    Thanks in advance

    Hi
    >If the ToolTip is not too long maybe you can add the text into the Text property of the DropDownByIndex. I would do something like:
    >Entry 1 (ToolTip 1)
    >Entry 2 (ToolTip 2)
    +1
    If DropDown operates with 'key/display text' pairs. It seems the display texts in your DD is rather technical so you thought of the tooltips. Try to make the texts more user friendly and you will not need the tooltips at all.
    If you still wants to show the technical keys, I'd also suggest to use InputField with EVS. It behaves like DD, but shows technical key in a field and shows key/text pairs in a popup.
    BR, Siarhei

  • Tooltip for RadioButtonGroupByKey

    Hi,
    Can anyone tell me how to set different tooltip for a RadioButtonGroupByKey UI element. I create the Simple Values for the an attribute and bind this to the RadioButtonGroupByKey.
    As each UI element has one setTooltip() method, how can we set different tooltip for each radio button in the RadioButtonGroupByKey UI element.
    Thanks.

    Hi Armin,
    Thanx for the answer, actually I was looking for someone to confirm it
    Partially Saravanan is correct as I can modify the tooltip on each selection of the radiobutton but this will not solve the problem as for all the radiobuttons I will see the same tooltip.
    Thanks Again.

  • Linked line charts

    I have another question, I hope this makes sense.
    I am making two line charts - one line in each chart. I plan to have in one fex file (is this then called a dashboard?). These charts will be side by side and both share the same XML file.
    1. When the cursor is in the chart area, can the cursor be forced to follow the line on the chart and show the different tooltips as the cursor moves along the line/data points?
    2. Can the cursor - which is an arrow, be made into cross hairs in the chart area?
    3. If the cursor is forced on the line of one chart, can the curson position (as cross hairs) be shown on the second chart as both charts use the same XML file. And vice versa.
    Thanks.

    Hi,
    1. Cursor is moved by user - only by user in any direction, so you can't do anything with this. But you can create a vertical line and show any data in crossing. Like there http://extra.amcharts.com/editor/line/
    2. Yes, it's possible. http://extra.amcharts.com/editor/line/
    3. Yes, it's possible to bind such lines between several charts.
    Hope it's helpful.

  • ToolTipText for an image

    Hey all!
    I've created a panel that contains 10 images in two rows of five, and i want to add tooltiptext to the images. It appears that there is no method to do such a thing, so i decided that one way to do it would be to draw a panel underneath each image and add the tooltiptext to that. However, the images are drawn in different places due to their height and width, making things a little tricky... i have a few quick questions:
    Do you think that this approach is a good idea?
    How would you go about drawing these panels, which layout manager would you use etc...
    Thanks as always :)

    JComponent (which is what JPanel is) contains the following method:
    public String getToolTipText(MouseEvent event)
    Returns the string to be used as the tooltip for event. By default this
    returns any string set using setToolTipText. If a component provides
    more extensive API to support differing tooltips at different locations,
    this method should be overridden.(http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JComponent.html)
    Your panel can figure out where the mouse is, and set the text to appear
    in the tooltip accordingly.
    It would be neater if each image was in its own component (JLabel).
    That way each could have its own tooltip associated with it.
    If you get stuck, post some code to the Swing forum.

  • Image tooltiptext

    Hey all!
    I've created a panel that contains 10 images in two rows of five, and i want to add tooltiptext to the images. It appears that there is no method to do such a thing (or at least i can't find it), so i decided that one way to do it would be to draw a panel underneath each image and add the tooltiptext to that. However, the images are drawn in different places due to their height and width, making things a little tricky... i have a few quick questions:
    Do you think that this approach is a good idea?
    How would you go about drawing these panels, which layout manager would you use etc...
    Thanks as always :)

    Run the SwingSet demo that comes with the JDK. It shows how to provide different tooltips for different locations on the same image:
    a) demo located in: j2sdk1.4.2\demo\jfc\SwingSet2
    b) execute the jar: java -jar SwingSet2.jar

  • ToolTip for each node of the Tree in JTreeTable?

    Hello! I have the problem that a ToolTip i have set in the TreeCellRenderer would not been displayed! Only one ToolTip will pop up over the JTreeTable with the ToolTipText that was set in the first CellRenderer. Does everybody have an idea?

    OK! Its done! The solution does not help exact, but it gives my the way! With the coordinates of the MouseEvent I can get the Value of the current table row and set the ToolTip text new. Teh ToolTipManager automatically repaints the ToolTip whit the new text and position.

Maybe you are looking for

  • How do i convert mpg and mpeg files

    ok i got all my mpg and my mpeg files on i-tunes and i can watch the perfectly but when i try to put them on my ipod it doesnt work I know i have to convert them But what is the best program to use for converting mpg and mpeg files for my ipod

  • Unable to create Groups through API

    Hi, I have an approval workflow for creation of a new organization and it works fine.Once the last level of approval is completed, I should create a new org and three groups inside OIM. My adapter creates the new organization successfully. however, I

  • GTK styles and fonts missing in KDE

    when I go to system options, there used to be GTK styles and fonts under application appearance, but I don't see it there no more.. am I missing something? is it just because of gnome3? I also tried this, but it didn't help.. any hints? thank you

  • PO transfer ERROR with PORDCR1.PORDCR102 to SNC

    Hi~ PO is transfered from ECC to SNC. ECC Idoc  "PORDCR1.PORDCR102 " ->  SNC xml "RelenishmentOrderNotification" In SNC, there are application error because of delivery_date field. <Analysis> When we create PO in T/C ME21N, we enter delivery date in

  • Lightroom CC does not start on MAC

    I downloaded the version of Lightroom CC for Mac and start the program makes an attempt to get the initial welcome screen and the program closes. Made several attempts and does the same. I uninstalled and reinstalled and behaves the same. Lightroom 5