Pessoal preciso de saber como faço um JMenuItem abrir uma JPanel, ou seja ao clicar no JMenuItem abrir o JPanel correspondente, isto em Eclipse, através do windowBuilder. Agradecido http://postimg.org/image/qy1yzgoc9/
public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
Agenda1 window = new Agenda1();
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Create the application.
*/
public Agenda1() {
initialize();
}
/**
* Initialize the contents of the frame.
*/
private void initialize() {
frame = new JFrame();
frame.setBounds(100, 100, 450, 300);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(new CardLayout(0, 0));
-----
JPanel panelEditar = new JPanel();
frame.getContentPane().add(panelEditar, "name_5905325036674");
panelEditar.setLayout(new CardLayout(0, 0));
------
JMenuItem mntmEditar = new JMenuItem("Editar");
mntmEditar.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
CardLayout card=(CardLayout)frame.getContentPane().getLayout();
card.show(frame.getContentPane(), "panelEditar");
}
});