Olá pessoa estou tentando inserir no meu JFrame um JMenuBar mais da sempre erro… alguém poderia mim dizer como colocar segue o código:
package gui;
/*
* AbsoluteLayoutDemo.java requires no other files.
*/
import java.awt.Container;
import java.awt.Insets;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.*;
public class FramePrincipal {
public static void addComponentsToPane(Container pane) {
pane.setLayout(null);
/*
*Gostaria de adiconar o JMenuBar aqui
*/
}
public static void createAndShowGUI() {
//Create and set up the window.
JFrame frame = new JFrame("AbsoluteLayoutDemo");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//Set up the content pane.
addComponentsToPane(frame.getContentPane());
//Size and display the window.
Insets insets = frame.getInsets();
frame.setSize(700 + insets.left + insets.right,
525 + insets.top + insets.bottom);
Toolkit tk = Toolkit.getDefaultToolkit();
// Obtendo a dimensão da tela
Dimension screenSize = tk.getScreenSize();
// Centralizando
frame.setLocation((screenSize.width - frame.getSize().width) / 2,
(screenSize.height - frame.getSize().height) / 2);
frame.setVisible(true);
}
}