里面应该有个菜单栏的,实际上就一个JFrame框架
public class RootFrame extends JFrame {
private static final long serialVersionUID = 1L;
private JPanel centerPanel;
@SuppressWarnings("unchecked")
public RootFrame(String title) throws IOException{
super();
// setIconImages(new ICOFile(SourceLoader.AbsolutePath("files/images/menu/application.ico")).getImages());
setTitle(title);
setSize(400, 600);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLocationRelativeTo(null);
menuBar();
toolBar();
center();
statusBar();
setVisible(true);
}
public void menuBar() {
JMenuBar menuBar = new JMenuBar();
JMenu config = new JMenu();
config.setText("配置(Q)");
config.setMnemonic('Q');
JMenuItem switch_db = new JMenuItem();
switch_db.setText("切换数据库(S)");
switch_db.setMnemonic('S');
// Image image = Toolkit.getDefaultToolkit().getImage(
// getClass().getResource("/images/menu/搜狗浏览器截图.jpg"));
// ImageIcon icon = new ImageIcon(image);
// switch_db.setIcon(icon);
switch_db.addActionListener(new Action());
config.add(switch_db);
menuBar.add(config);
setJMenuBar(menuBar);
}
public void center() {
// this.centerPanel = new JPanel();
if(this.centerPanel == null) {
this.centerPanel = new JPanel();
// System.out.println("worec.form.RootFrame..center");
}
// System.out.println("worec.form.RootFrame..center");
this.centerPanel.setLayout(new BorderLayout());
JButton b = new JButton("1432");
this.centerPanel.add(b);
// this.centerPanel.setVisible(true);
getContentPane().add(this.centerPanel, BorderLayout.CENTER);
}
public void toolBar() {
}
public void statusBar() {
}
public Component add(Component comp) {
this.centerPanel.add(comp, BorderLayout.CENTER);
// System.out.println("worec.form.RootFrame..add");
// this.centerPanel.invalidate();