JavaFX PopUp Drag and Drop - java

first i use JavaSE 1.7 -> The product i develop for is setting this standard. So i can not use the Functions of JavaFX8!
I developed a Custom Menu Item like this:
http://de.share-your-photo.com/7f2f7d74d8
There you can see some triangels! If the triangle shows to the right side i want to get a PopUp on the right hand side next to the Menu Item.
My Problem is that the popup should be dragable and it should not be possible that the PopUp leaves the Main Stage.
Could you please help me with this Problem? What kind of class should i use to develop the PopUp?
Maybe is it possible to make a PopUp Object Draggabel?

I solve the problem, by myself.
I added a container (VBox) to the popup and makes this one draggable!
With every new Koordinate, i set the x&y coordinates to the new position!
container.setOnMouseDragged(new EventHandler<MouseEvent>() {
#Override
public void handle(MouseEvent event) {
// TODO Auto-generated method stub
if(dragAct==true){
//DRAG HANDLING
}
}
});

Related

First addCommand() item in a Form fails when used with native theme

I have encountered a problem when using the the addCommand() method of the Form class along with the Native theme - other themes work fine. See the following example:
Form hi = new Form("Hi World");
hi.addComponent(new Label("Hi World"));
// with native theme - can't click on the first command in the list
hi.addCommand(new Command("Dummy1") {
public void actionPerformed(ActionEvent ev) {
Dialog.show("Dummy1 Clicked!", "You clicked the Dummy1", "OK", null);
}
});
hi.addCommand(new Command("Dummy2") {
public void actionPerformed(ActionEvent ev) {
Dialog.show("Dummy2 Clicked!", "You clicked the Dummy2", "OK", null);
}
});
hi.show();
When I create an application using the code above, a click on the second command ("Dummy2") produces the expected Dialog, but a click on the first command ("Dummy1") does nothing.
This only happens when using the Native theme. If I switch to Flat Blue, then clicking on either command produces the expected Dialog.
This behavior happens both on the Simulator and on a real Android device (don't know about iOS).
Fyi, my toolchain is NetBeans IDE v8.2, Java 1.8.0_25, with the CodenameOne plugin v3.6.0.
Has anyone else seen this? Am I missing something? If so, is there a workaround?
If the element is very narrow and very close to the top the click might be misinterpreted as a click out of bounds or on the status bar area. You need to set the styling of the SideCommand to have a sensible default as this element is very application specific. Otherwise touches might be lost.
I tried styling the SideCommand but it didn't seem to help. What worked for me was to define a style for TitleArea and simply uncheck Derived for the Padding settings (I left them all set to 0px).
I have no idea why this works - I would have thought that the derived values would have been zero in any case.

Get slidingpanellayout events

I'm using sliding panels with my android app, but i need to get an event when the panel is up, is there a way listen to when it happens?
im using a sothree Sliding panel library
Looks like you are talking about umano/AndroidSlidingUpPanel. After briefly looking at the documentation/code you should be able to set a PanelSlideListener to your SlidingUpPanelLayout. They also provide a SimplePanelSlideListener which inserts no-ops for any functions you choose not to implement, which is probably what you will want to use.
For example inside of your Activity's onCreate you could do something like:
SlidingUpPanelLayout slidingPanel = (SlidingUpPanelLayout)findViewById(R.id.your_sliding_layout);
slidingPanel.setPanelSlideListener(new SimplePanelSlideListener() {
#Override
public void onPanelExpanded(View panel) {
// Insert your code here
}
});

How to force a Value change on a Vaadin RichTextArea component

I have developed a custom component consist of a layout and two labels within it. This layout is draggable. The code is similar to this :
DragAndDropWrapper boxWrap= new DragAndDropWrapper(layout);
mainLayout.addComponent(boxWrap);
After that I have a RichTextArea that allows the layout to be dropped in it. With this code.
RichTextArea richText= new RichTextArea;
DragAndDropWrapper dndWrapper = new DragAndDropWrapper(richText);
dndWrapper.setDropHandler(new DropHandler() {
public void drop(DragAndDropEvent event) {
//Do whatever you want when something is dropped
}
//Criterio de aceptacion
public AcceptCriterion getAcceptCriterion() {
return AcceptAll.get();
}
});
The code works fine. But when I drop the layout within the RichTextArea y want to get the Text written in this area and add some text but the method richText.getValue() is not updated unless I change the focus to another component or tab out. I guess there is not being communication with the server side so the value is not updated. Is there any way to force a a focus change when mousedown on the layout? I tried with JavaScript but i dont know how to add a onmousedown="function()" attribute to the layout component. I also tried extending RichTextArea and implementing the MouseListener or something or a TextChangeListener, but nothing works.
Any clue? Thank you.
PS: The component cannot be different from a RichTextArea.
Have you set richText.setImmediate(true); ?

How can I detect that a menu is open in JavaFX?

I'm writing a JavaFX app and have a menubar with partial transparency. When the user mouses over the menubar, it becomes fully opaque. I'd also like it to be opaque when the user has opened one of the menus. Is this possible somehow? I'm using JavaFX 2 if it matters.
Thanks.
try this..!!
menu.setOnShowing(new EventHandler<Event>() {
#Override
public void handle(Event t)
menubar.setStyle("-fx-background-color:transparent"); //
// or you can use set opacity property
menubar.setOpacity(0.25);
}
});
this event occurs when you show you menu...there also menu hidden propety..you can also use it.

Making java tooltips disappear with application switch

I use JComponent.setToolTipText to get tooltips in my java application, but unlike, e.g., eclipse, if I switch to another application when a tip is showing, it remains hovering over what I'm doing until I switch back to the java app and move the mouse around to get it off the element before returning to the alternate application. Is there a way to make the tooltips in my app better citizens? to make them disappear when the app loses focus?
I'm on a mac if relevant.
I've found a solution! (with some input from a colleague)
<myJFrame>.addWindowFocusListener(new WindowFocusListener() {
#Override #SuppressWarnings("unused")
public void windowLostFocus(WindowEvent e) {
ToolTipManager.sharedInstance().setEnabled(false);
}
#Override #SuppressWarnings("unused")
public void windowGainedFocus(WindowEvent e) {
ToolTipManager.sharedInstance().setEnabled(true);
}
});
A WindowAdapter listening to windowActivated/Deactivated also works.
A plain FocusListener does not.

Categories