JMenuBar a little off

My MenuBar does not display exactly like i want it to. It seems to be 1 or 2 px off, both in x and y position - compared to the JMenuBar example and to apps like firefox.

What can i do to fix this?

my app is basically 4 files.

1. Main - setting up L&F to system and starting my mainFrame

2. MainFrame - creates a JFrame and sets a menubar and contentpane from 2 other files

3. MenuFrame - the JMenuBar of MainFrame

4. Desktop - the ContentPane of MainFrame

MAINFRAME:

public MainFrame(){

//create a mainFrame

JFrame mainFrame =new JFrame();

MenuFrame menuBar =new MenuFrame();

Desktop desktop =new Desktop();

mainFrame.setJMenuBar(menuBar.createMenuBar());

mainFrame.setContentPane(desktop.createContentPane());

//set attributes for menuBar

mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

mainFrame.setTitle("Sequencer");

mainFrame.setVisible(true);

//maximize window (must be placed after setVisible)

mainFrame.setExtendedState(JFrame.MAXIMIZED_BOTH);

}

CREATEMENUBAR (method inside MenuFrame)

public JMenuBar createMenuBar(){

//Create menubar

menuBar =new JMenuBar();

menuBar.add(createFileMenu());

menuBar.add(createEditMenu());

System.out.println(menuBar.getMargin());

return menuBar;

}

Hope this makes sense

Carsten

[1956 byte] By [Carsten78a] at [2007-11-27 1:39:50]
# 1

It's most likely because swing's L&F's don't actually use the native windowing capabilities, but try their best to emulate them. There may be slight variances between actual native apps and the mimicked swing version. Also, apps like firefox may have changed their L&F slightly from the default platform's so you can have even more differences there.

hunter9000a at 2007-7-12 0:53:20 > top of Java-index,Java Essentials,Java Programming...
# 2
Not sure what you mean.
abillconsla at 2007-7-12 0:53:20 > top of Java-index,Java Essentials,Java Programming...
# 3
> Not sure what you mean.Me or the OP?
hunter9000a at 2007-7-12 0:53:21 > top of Java-index,Java Essentials,Java Programming...
# 4

Sorry a little late reply.

http://img329.imageshack.us/my.php?image=firefoxandmyapplu7.jpg

notice that the actual menu is not placed very nicely in my app?

I think hunter9000 is right when he says its because its actually just an emulation. But cant i do anything about it? perhaps manipulate the placement of the menu?

Carsten

Carsten78a at 2007-7-12 0:53:21 > top of Java-index,Java Essentials,Java Programming...
# 5

It's not you ... mine are like that too ... I actually think it looks nice. I notice that the Windows L&F seems more prone to it - if you use the Motif Look & Feel it might even be worse. The Java L & F appears to clear it up best. I was comparing several Windows apps just now - including FileDialog and they do it too. If you check out the ... \demo\jfc\SwingSet2\SwingSet2.jar, you can go back and forth and observe the differences.

~Bill

abillconsla at 2007-7-12 0:53:21 > top of Java-index,Java Essentials,Java Programming...
# 6
> > Not sure what you mean.> > Me or the OP?The OP ... should have made that clearer.
abillconsla at 2007-7-12 0:53:21 > top of Java-index,Java Essentials,Java Programming...