如何在另一个类的JList中设置值?

时间:2013-06-28 09:49:42

标签: java swing awt

我的程序中存在问题:

有几个班级

class Info{
private String number;
private Date date;
private String user;
private double sum;
private String nameCurrency;
private double courceOfCurrency;

public void setNumber(String s){
    this.number = s;
}
public void setDate(Date d){
    this.date = d;
}
public void setUser(String user){
    this.user = user;
}
public void setSum(double sum){
    this.sum = sum;
}
public void setNameCurrency(String nameCurrency){
    this.nameCurrency = nameCurrency;
}
public void setCourceOfCurrency(double courceOfCurrency){
    this.courceOfCurrency = courceOfCurrency;
}
public String getNumber(){
    return number;
}
public Date getDate(){
    return date;
}
public String getUser(){
    return user;
}
public double getSum(){
    return sum;
}
public String getNameCurrency(){
    return  nameCurrency;
}
public double getCourceOfCurrency(){
    return courceOfCurrency;
}
}

class Bill extends Info{

private String product;
private double qty;

public void setProduct(String s){
    this.product = s;
}
private void setQty(double qty){
    this.qty = qty;
}

public String getProduct(){
    return product;
}
public double getQty(){
    return qty;
}
}

主要

public class Main {
public static void main(String[] args) {
    JFrame frame = new MainFrame("TestWork");
    frame.setVisible(true);
}
}

在Class MainFrame上:

//something  
DefaultListModel listModel = new DefaultListModel();
    JList list = new JList(listModel);
//sometheing

和班级SecondFrame。 有一些JLabelJTextfield。 问题:如何从JTextField(SecondFrame)获取价值并将其加入JList(MainFrame class)

0 个答案:

没有答案