Studyon Minte9.com
Java SE




Designer



1) JFrame Form

Netbeans: New Project > Java Package: New > JFrame Form
2) Add menu
Frame: Menu Bar (add) Menu: Menu Item (add)
3) Panels
Frame: Tabbed Pane (add) Tabbed Pane: Panel (add 3, first empty, add background colors to panels)
4) Attach menu to Tabbed Pane
package testswing; import java.awt.BorderLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JFrame; import javax.swing.JPanel; public class Test extends JFrame { public Test() { initComponents(); changePanel(jPanel1); jMenuItem1.addActionListener(new MenuAction(jPanel2)); // --- Look Here --- // } private class MenuAction implements ActionListener { private JPanel panel; private MenuAction(JPanel panel) { this.panel = panel; } @Override public void actionPerformed(ActionEvent e) { changePanel(panel); } } public void changePanel(JPanel panel) { getContentPane().removeAll(); getContentPane().add(panel, BorderLayout.CENTER); getContentPane().doLayout(); validate(); repaint(); } // Generated Code (Netbeans Designer) .... // Variables declaration - do not modify private javax.swing.JMenu jMenu1; private javax.swing.JMenu jMenu2; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenuItem jMenuItem1; // --- Look Here --- // private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JTabbedPane jTabbedPane1; // End of variables declaration }
 


http://netbeans.org/kb/docs/java/quickstart-gui.html