hi,i use the following code to set the tooltiptext for a graph(JGraph)!But it does not work the right way!When my cursor is above the cell,it does not display the tooltiptext,however when it leaves the cell,the tooltiptext appears!What i want is that when my cursor is above a cell,it displays the tooltiptext immediately .

\n

sorry for my english :)\nthanks!

\n

here is the code:

\n

GraphModel model = new DefaultGraphModel();

\n
   GraphLayoutCache view = new GraphLayoutCache(model,new DefaultCellViewFactory());\n\n   final JGraph graph = new JGraph(model,view);\n\n   DefaultGraphCell dgc=new DefaultGraphCell("Hello");\n   GraphConstants.setBounds(dgc.getAttributes(),new Rectangle2D.Double(20,20,40,20));\n\n   GraphConstants.setGradientColor(dgc.getAttributes(), Color.orange);\n   GraphConstants.setOpaque(dgc.getAttributes(),true);\n   graph.getGraphLayoutCache().insert(dgc);\n   ToolTipManager.sharedInstance().registerComponent(graph);\n   graph.addMouseMotionListener(new MouseMotionAdapter(){\n        public void mouseMoved(MouseEvent e){\n            Object o=graph.getFirstCellForLocation(e.getX(), e.getY());\n            if(o!=null){\n                if(o instanceof  DefaultGraphCell)\n                {\n                    //ToolTipManager.sharedInstance().setInitialDelay(0);\n                    graph.setToolTipText("AA");\n                }\n            }\n            }});\n   JFrame frame = new JFrame();\n   frame.setBounds(100, 20, 400,400);\n   JScrollPane js=new JScrollPane(graph);\n   frame.getContentPane().add(js);\n   frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);\n   frame.pack();\n   frame.setVisible(true);\n

asked 04 Feb, 19:50

%3F%3F%3F's gravatar image

???
11
accept rate: 0%

closed 05 Feb, 01:32

Gaudenz's gravatar image

Gaudenz ♦♦
7.4k15

The question has been closed for the following reason "Question is off-topic or not relevant. This forum is for mxGraph." by Gaudenz 05 Feb, 01:32


Use mxGraphComponent.setToolTips(true) and override mxGraph.getToolTipForCell.

link

answered 04 Feb, 23:20

Gaudenz's gravatar image

Gaudenz ♦♦
7.4k15
accept rate: 31%

You mean i have to change to the jgraphx instead of jgraph package?Appreciate more help from you :)

(05 Feb, 01:29) ???

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×13

Asked: 04 Feb, 19:50

Seen: 142 times

Last updated: 05 Feb, 01:35

powered by BitNami OSQA