How to trigger Hamburger in JavaFX - java

What I just want is when I clicked the Hamburger then it shows menus list. Now I want when I clicked any menu then my drawerstack and drawser should be hide.
I know how to triggers button likedoClick() but I wanna do know for go through API but didn't successful to find any suitable answer. Could you please share your exprience how I can trigger a Hamburger in javafx.
HamburgerSlideCloseTransition transition = new HamburgerSlideCloseTransition(hamburger);
transition.setRate(-1);
hamburger.addEventHandler(MouseEvent.MOUSE_CLICKED, (e) -> {
transition.setRate(transition.getRate() * -1);
transition.play();
borderpane.setRight(drawersStack);
drawersStack.toggle(rightDrawer);
});
thank you!

As I suggested in the comments, you could make all the buttons from the drawers from a custom class and feature the event handling there, e.g.
class drawerButton extends Button{
public drawerButton(){
addEventHandler(MouseEvent.MOUSE_CLICKED, (e) -> {
//open desired pane (pdf, favorites, etc)
//close the drawer
}
}
}

Related

Codename One - event listener for Dialog dismiss/cancel/tap outside

I am porting my Android app by means of Codename One.
Now I am porting the Dialogs in my app.
I am able to create similar dialogs in the Codename project, adding ActionListeners to the buttons and so on, but I am not able to find the event listener for cancel/dismiss/tap outside event.
The dispose() method has not a corresponding listener, that would be useful.
This is the simplest Dialog, but I have more complex ones too:
public static void openAlertDialog( String s1, String s2)
{
Dialog alertDialog=new Dialog(s1);
Button okButton=new Button("ok");
alertDialog.setLayout(BoxLayout.y());
Container c1=new Container(); //not so useful here but when there are more buttons
c1.setLayout(BoxLayout.x());
alertDialog.add(new SpanLabel(s2, "DialogBody"));
c1.add(okButton);
alertDialog.add(c1);
alertDialog.show();
}
How to have the chance of executing some code when the dialog is dismissed but no buttons were pressed?
You don't even need event listeners for Codename One dialogs. E.g. this code can be written like that:
Dialog alertDialog=new Dialog(s1);
Command ok = new Command("ok");
Button okButton=new Button(ok);
alertDialog.setLayout(BoxLayout.y());
Container c1=new Container(); //not so useful here but when there are more buttons
c1.setLayout(BoxLayout.x());
alertDialog.add(new SpanLabel(s2, "DialogBody"));
c1.add(okButton);
alertDialog.add(c1);
alertDialog.setDisposeWhenPointerOutOfBounds(true);
if(alertDialog.showDialog() == ok) {
// user pressed OK. You can test against other commands than ok as well
} else {
// canceled or clicked outside
}

TabWidget flickers when keyboard hides android

How to hide a tab bar at bottom.
I used android:windowSoftInputMode="adjustPan|adjustResize". I do not get the desired result. I also added the event bus and when the focus on the edit text disappears tab bar:
public void showTabBar()
{
mTabHost.getTabWidget().setVisibility(View.VISIBLE);
}
public void hideTabBar()
{
mTabHost.getTabWidget().setVisibility(View.GONE);
}
But, it flickers, too, is not suitable. What else can I do?
(source: cs629227.vk.me)

ComboBox SAME item selected action listener

A combo box will fire an event if a DIFFERENT value is selected. I want to be also be able to listen to the SAME item being selected (that is, valueProperty has no change). There seems to be no way to do this.
I tried extending the ComboBox and finding a way to listen for the little popup menu being closed, but I don't even have access to that! What can I do?
Here is what I was trying:
class ResponsiveComboBox<E> extends ComboBox<E> {
public ResponsiveComboBox() {
super();
assert getContextMenu() != null; //Asssertion failed!
this.getContextMenu().setOnHiding((WindowEvent event) -> {
fireEvent(new ActionEvent());
});
}
}
comboBox.showingProperty().addListener((obs, wasShowing, isShowing) -> {
if (! isShowing) {
System.out.println("Combo box popup hidden");
}
});
This event handler might be triggered before the value is changed.

GWT - CSS animation after adding element to the page

If the button is clicked, I want to add a Label to page and fade it in via an CSS animation. I thougt, I could just create and add the label with the CSS class "hidden" attached, which has the opacity = 0 and after that remove the class and CSS will do the rest.
But i was wrong. GWT seems to execute the code in the onClick() in some kind of bulk mode -> The label gets added already without the "hidden" class. How can i prevent or do it that better? If I add/remove the "hidden" class manually in the browser, the animation works finde.
The java code looks like this:
Button submitButton = new Button("send");
submitButton.addClickHandler(new ClickHandler() {
#Override
public void onClick(ClickEvent event) {
Label l = new Label("test");
l.addStyleName("hidden");
RootPanel.get().add(l);
l.removeStyleName("hidden");
}
});
RootPanel.get().add(submitButton);
Das CSS sieht folgendermaßen aus:
.gwt-Label{
transition-property: opacity;
transition-duration: 1s;
}
.hidden{
opacity:0;
}
Probably you have to add some delay function before remove hidden class.
Here you have example (in JS but it's only to show):
http://jsfiddle.net/matku/PXnPZ/
$(".myElement").delay(50).queue( function(){
$(this).removeClass("hidden");
});
And another way I found on google:
http://map-notes.blogspot.com/2012/11/fade-animation.html

Action into Submenu Context Menu Java JFace SWT Eclipse

I'm having a slight problem with an Eclipse Plug-In in development.
There is a view which is comparabe to a roster. There is a list of users in there. My problem is, that I'd like to add an context menu.
The idea is to perform a right-click on a user and the menu should pop up. So far so good... but the problem is that I don't want a single menu. I'd like to have an entry "set status" to that context menu and when one hovers over this entry the menu should be extended to show stuff like "away" "busy" "invisible" and so on...
Could anyone help me out to achieve this?
I have already implemented the corresponding action and made the addition to the MenuManager.
public SessionViewContextMenu(ViewPart sessionView, TableViewer viewer,
final Action action) {
MenuManager manager = new MenuManager("#PopupMenu");
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
manager.add(action);
}
});
The correspodning action looks like this:
public Action(...) {
super(provider, "Bla Bla");
// some fancy picture
setImageDescriptor(...);
// setId(ACTION_ID);
setToolTipText("Bla Bla");
update();
}
Everything is working fine (at least the context menu shows the entry). Now I'd like to extend the menu when one hovers over / selects the corresponding action. So the menu should extend and show some more possibilites here...
Any help on how to create a recursive context menu is highly appreciated!
Hope, you understand the problem and don't hesitate to ask dor clarification!
Just create a sub-menu and add the actions to this sub-menu.
Here is a quick snippet which should clarify the usage:
// submenu for a specific user
MenuManager subMenu = new MenuManager("Change Status", null);
// Actions for the sub menu
subMenu.add(someAction);
// add the action to the submenu
manager.add(subMenu);
Hope that helps!
Put together:
public SessionViewContextMenu(ViewPart sessionView, TableViewer viewer,
final Action action) {
MenuManager manager = new MenuManager("#PopupMenu");
manager.setRemoveAllWhenShown(true);
manager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager manager) {
manager.add(action);
// submenu for a specific user
MenuManager subMenu = new MenuManager("Change Status", null);
// Actions for the sub menu
subMenu.add(someAction);
// add the action to the submenu
manager.add(subMenu);
}
});

Categories

Resources