-2

Hi all first an apology if this question comes as a bit vague. But i am in the process of brain storming. What i would like to achieve: In IDEs like intelliJ or Eclipse, its possible to hover on certain text and the javadocs is displayed in the tooltips. I am trying to achieve that in my JSwing application.

For instance i have a bunch of POJOs with properties like

public class Person {
     /**
       * Some description about the field
      */
     public int age;
}

Now my "age" field will be exposed in my JSwing application. And I would like to provided contextual tooltip based on the javadoc comment when a user hovers over.

I have an idea, which is to generate javadocs and parse the html as resources. However, I would like to hear some thoughts about this approach.

e.g.

http://www.eclipseonetips.com/wp-content/uploads/2010/08/unwanted-hover-tooltip-in-eclipse.jpg

delita
  • 1,571
  • 1
  • 19
  • 25
  • You can't use comments for this (most likely, unless you're writing your own editor that parses java). Perhaps look at writing your own annotations. – byxor Mar 21 '17 at 17:40
  • any idea how eclipse IDE is able to achieve this? Somehow the javadocs must be parsed into the IDE? – delita Mar 21 '17 at 18:05
  • Eclipse has its **own** compiler that constantly parses your java source code. – GhostCat Mar 21 '17 at 19:41

1 Answers1

3

Serious answer: don't do this.

You are mixing up different kinds of information here.

Your classes and their fields are a representation of your object model in terms of ,well, code/implementation.

And there should not be such a direct connection to your UI layer that will be displaying information to the user.

Whereas: your UI deals with all kinds of UI elements. And the elements in their have "names", and "meanings", and so on (which for example, in a real world application require Internationalization!).

And you intend to mix that "code" information with your "UI elements" information; as said: don't do that.

Of course, you can think about putting reasonable tooltips on UI fields; but the information for that ... belongs to the corresponding UI element; and not to some field on some java class that happens (at some point) to be a "direct" source for that UI element.

GhostCat
  • 137,827
  • 25
  • 176
  • 248