• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need Help in JEditorPane

 
AjayKumar Kanukuntla
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello everybody
I am into making a VisualBasic like editor, where user writes his code. I am using JEditorPane as editor for code writing.
Now the problem is, whenever user types a character, say "?", i need to show a popup window, immediate to the keyboard cursor, containing the functions, so that user can select one avoiding typing it.
I couldnot find a way to read the screen coordinates where i have to show the popup window. I tried with getLocation() on containers like JEditorPane, JSplitPane. But i couldnot place the listbox at the cursor position.
Please help me out in getting the screen coordinates in JEditorPane.
------------------
 
Manfred Leonhardt
Ranch Hand
Posts: 1492
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi AjayKumar,
Use the getCaret and its method getMagicCaretPosition. The code below shows how to use it. Keep in mind that the position returned is relative to the EditorPane itself. To get a dialog to appear you need to know where the EditorPane is and add the caret position to that.

Regards,
Manfred.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!