import org.jdesktop.application.SingleFrameApplication;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import org.jdesktop.application.FrameView;
public class Welcome extends FrameView
{
SearchPanelClass panel1 = new SearchPanelClass();
AddMaterialPanel panel2 = new AddMaterialPanel();
Container container= AutomobileApplication.getApplication().getMainFrame();
public Welcome(SingleFrameApplication app)
{
super(app);
initMenu();
}
private class MenuAction implements ActionListener {
private SearchPanelClass panel;
private MenuAction(SearchPanelClass pnl)
{
this.panel = pnl;
}
private AddMaterialPanel AddMaterialPan;
private MenuAction(AddMaterialPanel pnl)
{
this.AddMaterialPan = pnl;
}
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if(command == "Panel1")
{
changePanel(panel1);
}
if(command =="Panel2")
{
changePanel(panel2);
}
}
}
private void initMenu() {
JMenuBar menubar = new JMenuBar();
JMenu menu = new JMenu("Menu");
JMenuItem menuItem1 = new JMenuItem("Panel1");
JMenuItem menuItem2 = new JMenuItem("Panel2");
menubar.add(menu);
menu.add(menuItem1);
menu.add(menuItem2);
this.setMenuBar(menubar);
menuItem1.addActionListener(new MenuAction(panel1));
menuItem2.addActionListener(new MenuAction(panel2));
}
private void changePanel(JPanel panel) {
container.removeAll();
setComponent(panel);
panel.setVisible(true);
container.doLayout();
}
}
这里 SearchPanelClass 和 AddMaterialPanel 是我想根据菜单项单击添加的两个自定义面板。但是面板仅在调整窗口大小时才可见。谁能告诉我在调整窗口大小时后端调用了哪些程序?
请给我掌舵...
提前致谢..