0

I'm training with Java and Swing, in Windows the GUI is shown correctly, instead on MAC there are several problems. The JMenuBar is shown in the window, while should be shown in the MAC bar [finder].

Mac View

Code of JMenuBar:

        JMenuBar menuBar = new JMenuBar();

        preferenceItem.addMouseListener(this);
        printItem.addMouseListener(this);

        menuBar.add(fileMenu);
        fileMenu.add(openItem);
        fileMenu.add(printItem);
        fileMenu.add(exportItem);

        menuBar.add(optionMenu);
        optionMenu.add(preferenceItem);

        setJMenuBar(menuBar);

Than another problem is how two panels are shown. As you can see in the previous image backup button, which is in the second panel is shown above the first panel.

public OptionDialog(){
        super();

        setTitle(NOME_APPLICAZIONE);

        Dimension dimensioni = Toolkit.getDefaultToolkit().getScreenSize();
        setLocation((int)(dimensioni.getWidth()/2-getWidth()/2), (int)(dimensioni.getHeight()/2-getHeight()/2));
        this.setVisible(true);
        this.add(pnlDialog, BorderLayout.NORTH);
        this.add(pnlDialogBackup, BorderLayout.SOUTH);


        pnlDialog.setBorder(general);

        GridLayout grid = new GridLayout(7,2,20,5);
        pnlDialog.setLayout(grid);

        pnlDialog.add(lblLingua);
        pnlDialog.add(Language);
        pnlDialog.add(lblCarattere);
        pnlDialog.add(Char);
        pnlDialog.add(lblOrdinamento);
        pnlDialog.add(Order);
        pnlDialog.add(lblScadenza);
        pnlDialog.add(Scadenza);
        pnlDialog.add(lblNotifica);
        pnlDialog.add(Notifica);
        pnlDialog.add(lblTempo);
        pnlDialog.add(Time);
        pnlDialog.add(Applica,BorderLayout.PAGE_END);


        pnlDialogBackup.setBorder(backup);
        pnlDialogBackup.add(Backup);


        Notifica.addItemListener(this);

        lblTempo.setVisible(false);
        Time.setVisible(false);
        setSize(new Dimension(300, 300));
        setResizable(false);
}
Mitro
  • 1,230
  • 8
  • 32
  • 61
  • 2
    1) May be [that](http://stackoverflow.com/questions/307024/native-swing-menu-bar-support-for-macos-x-in-java) helps you with menu. 2) Instead of `setSize(new Dimension(300, 300));` try to use `pack()` method. – alex2410 Mar 31 '14 at 08:35
  • 1
    More [here](http://stackoverflow.com/q/8955638/230513). – trashgod Mar 31 '14 at 08:52
  • I've solved the view issue, but now when I click on "preferenceItem", it doesn't show the new JDialog. (No event is performed) – Mitro Mar 31 '14 at 10:44

0 Answers0