JonathanGiles / jonathangiles.net-comments

0 stars 0 forks source link

posts/2009/javafx-menubar-released/index #83

Open JonathanGiles opened 4 years ago

JonathanGiles commented 4 years ago

JavaFX Menubar Released

https://jonathangiles.net/posts/2009/javafx-menubar-released/

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Thomas Comment posted on: August 12, 2009

Hi Jonathan,

cool feature, but menubar should become member of JFXStage! Absolute positioning is ugly and always troubles with more complex layouts (MigLayout). So my suggestion is to add menubar to org.jfxtras.stage.JFXStage.

JFXStage { menubar: myMenubar, content: [ ...] };

What do you think?

Best,

Thomas

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Jonathan Comment posted on: August 12, 2009

Thomas,

This is the plan - it just needs someone to do it :-) I might find some at some point to add this support in, but I couldn't say when.

-- Jonathan

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Thomas Comment posted on: August 12, 2009

Hi Jonathan,

it's me again. I've noticed that MenuBar seems to eat up MouseEvents.

I have added println for button action in your sample code, but button is dead (had same behavior in my app after adding MenuBar).

Button { translateX: 10, translateY: 10, text: "button" action: function() {println("button pressed");}}

Any hint?

Thomas

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Serega Comment posted on: August 13, 2009

Hi Jonathan, you've did nice work, thank you. I'm using your extension with pleasure. Please tell me, it there any possibility to specify skins for your MenuBar? I would like to change background color and font. Default font is not too good - it makes labels look like "jumping on the string".

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Jonathan Comment posted on: August 13, 2009

Thomas,

You're probably running an older release of the menubar. Try updating from SVN as this has since been fixed.

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Jonathan Comment posted on: August 13, 2009

Serega, Unfortunately it's not easily skinnable right now, although it would be pretty trivial to extract the code so that you can use CSS to configure the colours.

I will see if I can find time to do this. Cheers, Jonathan

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Thomas Comment posted on: August 14, 2009

Jonathan, thx for your feedback. After update from SVN (rev 298) it now works.

Bye, Thomas

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Serega Comment posted on: August 14, 2009

Hi, Jonathan. I'm trying to bind menu.width with scene.width. seems like I'm not good at JavaFX. I have a problem.

org.jfxtras.scene.menu.MenuTest.fx You declare: var scene: Scene;

And then, while describing menubar, you bind menubar.width with scene.width.

I would like to separate my scene and menu bar to different files. Scene will be in main.fx, menuBar will be in MainMenu.fx

And I don't understand how to bind menu.width and scene.width if they are in different script-files.

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Jonathan Comment posted on: August 14, 2009

Serega,

The simple answer is don't split the files :-)

Alternatively, create a class for the menubar where you pass the scene into it. That way the menubar can be bound to the scene's width as per usual.

-- Jonathan

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Serega Comment posted on: August 14, 2009

Jonathan, I've tried to wrap menuBar into function:

FILE MainMenu.fx: var mainMenu : MenuBar =null;

public function getMenuBar(scene: Scene) : MenuBar{ if(menuBar == null && scene =! null){ //println("init menuBar with scene.width={scene.width}"); menuBar = MenuBar{ width: bind scene.width //some code goes here } } }

FILE Main.fx: Stage{ scene: scene = Scene{ content:[ MainMenu.getMainMenu(scene)] } }

And nothing happens. println says that scene.width = 0 while initializing mainMenu : MenuBar and mainMenu looks like it really sized to 0. (background gray color is not displayed). What do I do wrong?

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Serega Comment posted on: August 14, 2009

Excuse me, I've forgot to explain. My menu will be context-dependent, So I want to put all menu functionality into one file (show/hide some menus and sub-menus). That is why I would like to separate menu module from application entry point.

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Serega Comment posted on: August 14, 2009

Excuse for spam, I've found a solution, but I don't think it's beautiful enough.

FILE MainMenu.fx: var mainMenu : MenuBar = null; public function getMainMenu(scene:Scene) : MenuBar{ println("getMainMenu invoke"); if(mainMenu == null && scene != null){ println("getMainMenu scene.width={scene.width}"); mainMenu = MenuBar{ width: bind scene.width; //code } }

FILE Main.fx var scene: Scene;

scene = Scene{ width: 800; content: [ //mainMenu ] }; insert MainMenu.getMainMenu(scene) into scene.content; //This code works... OMG. scene.width and mainMenu.width have been bound

//And it doesn't work: scene = Scene{ width: 800; content: [ MainMenu.getMainMenu(scene) ] }; //Seems like scene looses initialization race with mainMenu?

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Robert Comment posted on: September 26, 2009

How can i use your MenuBar Package? I need it since MenuBar no longer avaible in JavaFX 1.2.

Can you tell me, when JFXtras 0.6 will be release? Thx.

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Jonathan Comment posted on: September 26, 2009

Robert,

MenuBar has never been available as a JavaFX control in JavaFX. If you want to use the JFXtras MenuBar that I have built, I would recommend you check it out from the JFXtras SVN repository. I don't know when the JFXtras 0.6 release will be. Also, note that a future release of JavaFX will also have an official MenuBar control.

Cheers, Jonathan

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Robert Comment posted on: October 2, 2009

hi, i have a problem with your menuBar. it seems your menuBar only work in ResizeableScene.

unfortunately, i already create a project in Scene. When i change my Scene to ResizeableScene, all my nodes were scrambled.

i want to keep Scene, but on the other hand i need your menuBar.do you have any opinion? Thx

Regards, Robert

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Jonathan Comment posted on: October 2, 2009

Robert,

It should work fine in Scene, as that is what I developed it using. You don't need to set the menubar in ResizeableScene, you can just do it like it is done here: http://code.google.com/p/jfxtras/source/browse/jfxtras.core/trunk/test/org/jfxtras/scene/menu/MenuTest.fx?r=281

Btw, that menu I did is pretty basic, and a better one which I've been developing will probably be released in the Soma release of JavaFX.

Cheers, Jonathan

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Serega Comment posted on: October 2, 2009

Hello Jonathan! You've wrote: """Also, note that a future release of JavaFX will also have an official MenuBar control.""" Where did you get this information? I'm doing my ph.d using JavaFX and I'm very interested in getting JavaFX roadmap, but I didn't find any info. Please tell where do you get news about future releases?

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Robert Comment posted on: October 3, 2009

Ohh... My mistake that i put MenuBar as first node in Scene.

wow... are you working with JavaFX team? It's a great job. I'm really envy of you.

Btw, what if i want to make a RadioButtonMenuItem? (So bad, i can't wait till Soma release).

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Jonathan Comment posted on: October 3, 2009

Serega,

I'm in the JavaFX team, that's where I get the news :-) But there is the http://javafx-jira.kenai.com/ issue tracker that has a lot of information about what is happening in the JavaFX world.

Cheers, Jonathan

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Jonathan Comment posted on: October 3, 2009

Robert,

You'll need to create it yourself, although there will likely be one available in the Soma release (I've already built it).

Cheers, Jonathan

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Serega Comment posted on: October 3, 2009

I've post there several bugs :). I'm learning this awesome technology with my students. OK, I'll explore JavaFX jira to get more info. Thank you.

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Jonathan Comment posted on: October 3, 2009

Great to hear you're reporting issues to the issue tracker. If you're interested in tracking the menu/menubar control, it is http://javafx-jira.kenai.com/browse/RT-5513.

Cheers, Jonathan

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Serega Comment posted on: October 3, 2009

It's my pleasure to help to make JFX better. It's really in 9000 greater than Silverlight or Flash. Only canvas can be compatible to JFX, but it's too specialized solution. I have a question, is it planned to separate JFX css stuff from code? I think it'll be very comfortable to change presentation properties of scene objectes in independent way from code. Just code and css tet files. :)

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Jonathan Comment posted on: October 3, 2009

Serega,

A lot of work is being done to improve CSS support, but I'm not sure how public that information is right now. I would recommend you keep an eye out for information in Soma, you should be happy with it.

Cheers, Jonathan

JonathanGiles commented 4 years ago

Auto-imported comment, original author: George Comment posted on: October 31, 2009

Jonathan,

Is there an example source code available, the link posted above: http://code.google.com/p/jfxtras/source/browse/jfxtras.core/trunk/test/org/jfxtras/scene/menu/MenuTest.fx is no longer available.

Thanks, George

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Jonathan Comment posted on: October 31, 2009

@George: Check out <a href="http://code.google.com/p/jfxtras/source/browse/jfxtras.core/trunk/test/org/jfxtras/scene/menu/MenuTest.fx?r=281&quot; rel="nofollow">here</a>, although note that these Menus are pretty crappy compared to what is coming in the future from Sun.

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Gireesh Comment posted on: December 12, 2009

Hi Jonathan,

I have an unique requirement, Please help me. I have an application window with one button and when clicking on the button I need to show list of menus below the button, Its same as clicking on a Menu in MenuBar. Here the challenge is I wanted to show the "child menus" in a Transparent window and simulate as if its a sub menus for the "button".

Let me explain the use case. Why I want this is, My Applet will be shown in a small area only with 30px height and When clicking on the "Button" I wanted to show the menu which will be bigger and should show on top of the other items which are below the applet. I am using the Transparent window so that my menus wont hide inside the applet container.

Can you please help me on how to do this ? I tried adding the Menu and MenuItems in a VBox and added the VBox in a dialog. What's happening is , MenuItems are displayed correctly but Menu's are not rendered properly.

Help me on how to get this resolved.

gireeshkumar.g@gmail.com -Gireesh

JonathanGiles commented 4 years ago

Auto-imported comment, original author: Jonathan Comment posted on: December 21, 2009

JavaFX 1.3 will most probably have a MenuButton control that should do exactly what you need. I would recommend you wait for that.