Re: JMenuBar使用的問題?
※ 引述《chen.bbs@bbs.cs.pu.edu.tw (小永)》之銘言:
: 請問一下,我想用JMenuBar有個選單來改變ContertPane的內容
: 程式可以正常執行。
: 但是為什麼我的寫法不能成功?
: 是我的寫法哪邊有問題嗎,還是說有可以有其它的方法?
: 以下是完整的程式碼
: =====================================
.
.
. //以上恕刪
: public void actionPerformed(ActionEvent evt)
: { if ( evt.getSource() == change2Apanel ) {
c.removeAll();
: c.add(aPanel); /*注解的地方想在這邊執行*/
aPanel.updateUI();
: System.out.println("切換到Apanel!!"); }
: if ( evt.getSource() == change2Bpanel ) {
c.removeAll();
: c.add(bPanel);
bPanel.updateUI();
: System.out.println("切換到Bpanel!!"); }
: }
: public static void main(String[] args)
: {
: test app = new test();
: app.addWindowListener(new WindowAdapter()
: { public void windowClosing(WindowEvent evt)
: { System.exit(0); }
: });
: app.setVisible(true);
: }
: }
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.218.242
討論串 (同標題文章)
完整討論串 (本文為第 2 之 2 篇):