Inline menu appearing with mouseover - java

What I am looking for is an inline menu, that pops up by a mouseover event. Does anyone know how to do something like this? The way it currently works in my program is very complicated (using multiple servlets and JSON).
Answered

create a div element that will house the menu items that you require. hide it by default and give it absolute positioning. Add a mouseover event that will calculate the position based on which element you are hovering over and set this element's position to that and make it visible.

Related

How to click an element which is visible only on mouse hover - selenium java

Note:
The code is written using angular on UI.
UI is like a chart - and I want to mouse hover on top right corner and click on that blank space which will show me a dropdown.
If you directly use hover over on the invisble element, it won't work. you need to use hover over on parent element which is visible always.
eg: please see the 2 screenshot
Before :
After:
Here, I need to click the edit icon and delete icon
Both icons are not visible by default
but the (parent) whole first element box is visible.
I tried the mouse hover over on the serial number of first row.
So icons will be displayed
then, I clicked them
I hope this will be useful !
used movebyoffset as element was not visible directly due to angular.
Searched it on intenet no one answered this.
always use movebyoffset if code is in angular. And then use action class to build and perform click.
For getting exact x & y cords use this tool - chorme web app -> coordinates.
example:

JavaFX 2.2 Remove Pagination's selected page label

I want to remove the Selected page label (see image below) of the Pagination control.
After digging into caspian.css I wasn't able to find any clue about how to do that. By code I also didn't find any method to remove (or eventually hide) this label.
Is there a way to do that in JavaFX without re-implementing the whole control ?
Use -fx-page-information-visible
It's described within these links:
http://docs.oracle.com/javafx/2/ui_controls/pagination.htm
https://docs.oracle.com/javase/8/javafx/user-interface-tutorial/pagination.htm#JFXUI459
https://docs.oracle.com/javase/8/javafx/api/javafx/scene/doc-files/cssref.html#pagination
I couldn't find a way either to hide just the label, but would it help to hide the whole button?
.number-button:selected{
-fx-opacity: 0;
}
That would hide the current selected button.
It's not what you actually wanted but maybe it can help you.

Formatting JEditorPane's cursor, tooltips, links

Right now, I'm using Java Swing to create a JEditorPane primarily for its ability to have hyperlinks. I've successfully been able to display links and have them execute behavior upon a click, but I'm running into a few problems with formatting.
How can I set the cursor so that it normally is an arrow, but changes to a text cursor when hovering over text? (In essence, the behavior a cursor has within a web browser). I tried
EditorPane.setCursor(new Cursor(Cursor.TEXT_CURSOR))
but that made it a text cursor everywhere, even when not hovering over text. Right now, hovering over a link shows a pointer hand; I'd like to maintain that functionality as well.
What is the best way to show tooltips or mouseover text when hovering over a link? I tried modifying the title attribute of the link but nothing showed up.
I was trying to implement links to skip down to a subsection of the page, much like http://en.wikipedia.org/wiki/Xkcd#History would take you directly to the History subsection of Wikipedia's xkcd page. How can I do this?
An answer to any of these would be great (and multiple would be awesome xP). Thanks a lot for your help!
As you said one can simply give answers to a single point as well, let me try one by one, here is the answer for your last Point 3
Just provide an id to your tag like this
<h1><a id = "top"></a>First Line</h1>
Now somewhere in the bottom of your page write this :
<p>Return to TOP</p>
Clicking this link, you will reach the above area of the PAGE.
Points 1 & 2 may be addressed using the approach mentioned here. In particular, the view/model conversion methods will let you condition setCursor() and getToolTipText(), respectively.
You can get source from here http://java-sl.com/JEditorPaneStructureTool.html
It shows how to obtain text view bounds. First you get caret position for current mouse poiunter using viewToModel() method. Then go down the Views tree achieving leaf view and calcualte it's bounds. See this http://java-sl.com/tip_view_rectangle.html
If your mouse pointer in the view's rectangle then your mouse over text.
You can check whether the text in caret position is link and show your tooltip.
Use this http://java-sl.com/tip_links_in_editable.html to see how to detect whether mouse is over link.
Point 3.rd is answered by #nIcE cOw

jList in Scrollpane, seeking and displaying value of selectedIndex

I have a JList inside a Scrollpane. If you click on the list and move the arrow keys up and down it works like you expect, you can move your selection index and display around just fine.
Now, what I want to do is basically have a text box and i'm typing in the text box like "comic" and want it to seek to the index of that value. This WORKS just fine.
Where the problem is when the value of the list box is below, or above the viewable area. When it is, the selected index seeks, but does not change the position of the scrollable region. However, if I press the up or down arrows and requestFocus() to the list, and move up and down it seeks to the right viewable area.
What am I missing to make this happen WITHOUT changing focus. I want to be able to just type in the list all I want and have it show me what is selected. I feel i'm missing something obvious here.
If I understand the question then you should be able to use:
list.setSelectedIndex(...);
list.ensureIndexIsVisible(...);
If that doesn't help then post your SSCCE demonstrating the problem.

How can I create an AutoComplete popup in a JTextPane in Java?

I am creating a SQL editor. I am using JTextPane for the editor. I want to implement AutoCompletion for table name etc. like Eclipse.
I think the appropriate class for displaying info on top of another component is JPopupMenu, which already handles layering correctly to display itself. JPopupMenu has a show() method that takes its 'parent' component as an argument, and it will show itself in that component's coordinate space. Since you want to display a selection of terms for the user to choose from, a menu seems appropriate.
To check for text changes, you'd add a DocumentListener to the document that's wrapped by the JTextPane; you can access it using getDocument().
To find out where the cursor (actually, the caret) is, you can use getCaretPosition(). That returns the caret's position within the text stream as an int. You can use modelToView() to translate that position to actual (x,y) coordinates. That in turn will tell you where to show your menu.
You can use addKeyListener() to catch keyboard events on your JTextPane, like hitting Ctrl-Space.
The combination of all that should allow you to do what you're looking to do.
You can also use http://fifesoft.com/autocomplete/. You can install it on any JTextComponent.
For things like this you probably should consider layered panes so your auto-complete suggestions appear in the correct place and z-order.
Furthermore you will have to look for changes in the JTextPane to know when the user is typing and you will need a parser that understands what is typed so you can offer the feature only at appropriate points.
It's not quite clear what exactly your problem is and what you got so far.
I achieved this by adding a key listener to the JTextPane and checking for CTRL + Space keystrokes. When the appropriate key combo was detected the listener went off and looked up the list of possible matches based on the characters directly to the left of the cursor at the time of the key press and found the best matches and displayed them to the user in a JPopup. If there was an exact match then it simply replaced the partial text with the match. If no matches were found an option was given to the user to add the text that they had already typed, edit it and record it into the list of acceptable data.
We use jide. They have a lot of components that help you do this kind of thing really easily

Categories

Resources