Topic: 在MVC应用中遇到的问题,请大家帮我解决一下。

  Print this page

1.在MVC应用中遇到的问题,请大家帮我解决一下。 Copy to clipboard
Posted by: stevendu
Posted on: 2004-05-09 11:23

在下面的代码中,要求执行期,station被修改后,在view中添加一些按钮,按钮标题是日期字符串。
遇到的问题是update方法执行后,按钮没有显示出来,请大侠们帮我看看。


package View;

import javax.swing.JPanel;
import java.awt.GridLayout;
import javax.swing.JButton;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.Color;
import java.awt.Graphics;
import java.util.Vector;
import java.util.Iterator;
import javax.swing.BorderFactory;
import Model.*;
import Controller.*;

public class PresaleDayView
extends JPanel
implements Observer {
public PresaleDayView(Subject subject) {
this.station = (Station) subject;
setBackground(new Color(123, 165, 255));
setBorder(BorderFactory.createLineBorder(Color.black));
setLayout(new GridLayout(Subject.MAX_PRESALE_DAYS, 1, 2, 0));
station.attch(this);
}

public String getType() {
return "PRESALEDAY";
}

public void update() {
Vector days = station.getDays();
if (days.size() == 0) return;
Iterator iter = days.iterator();
while (iter.hasNext()) {
PresaleDay day = (PresaleDay) iter.next();
add(new JButton(day.getDate()));
}
System.out.println("Presaledays updated. daysCount=" + days.size());
}

private Station station;
}

2.Re:在MVC应用中遇到的问题,请大家帮我解决一下。 [Re: stevendu] Copy to clipboard
Posted by: stevendu
Posted on: 2004-05-10 08:37

在update方法中加了updateUI()后,如果是Application就可以显示Button了,但是在Applet中还是不行,这是为什么呀?

3.Re:在MVC应用中遇到的问题,请大家帮我解决一下。 [Re: stevendu] Copy to clipboard
Posted by: tangming
Posted on: 2004-05-10 08:52

用invalidate()试试看

4.Re:在MVC应用中遇到的问题,请大家帮我解决一下。 [Re: stevendu] Copy to clipboard
Posted by: floater
Posted on: 2004-05-10 10:53

http://www.cjsdn.com/post/view?bid=46&id=90574&sty=3&keywords=validate

5.Re:在MVC应用中遇到的问题,请大家帮我解决一下。 [Re: stevendu] Copy to clipboard
Posted by: stevendu
Posted on: 2004-05-10 12:31

Thanks.


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923