How can I create title bar menu in Java

2019-09-18 00:37发布

问题:

I wanna create a simple application with Java. I designed the main template in my head but I have a kind of design problem.

I am using JMenuBar and JMenu. It works fine but it's location is not exactly what I want.

In ubuntu, I use Eclipse and it has menu in titlebar:

As you can see , menus are at top.(File,Edit,Source,etc..)

However, My application is not the same.

Here is my application.

JMenu is working fine but in title bar there is no menu.

What can I do to create this menus ?

Are there any component for it ?

Thank you. Best Regards. Ömer.

回答1:

You may be interested by the Jayatana project



回答2:

You're using the right components, but have a Look and Feel (L&F) problem. Take a look here:

http://docs.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html

however, I can't guarantee that changing the look and feel will make it look exactly as you want.


The general problem is that Swing abstracts away from the OS's GUI components. Eclipse is also Java, but SWT instead of Swing, so it doesn't have the problem. There may be third party libraries that integrate better with the native L&F - Maurice seems to have found one. Alternatively, you could switch to SWT entirely, but that might be a bit much just to get the right L&F.



标签: java jmenubar