尝试下订单屏幕上没有显示任何内容,但我想显示一个textarea说:
这是Sandwhich提供的打顶
你能帮助我吗?
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.GridLayout;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import java.awt.event.*;
import java.util.ArrayList;
import java.util.List;
public void setCheese(String s) {
cheese = s;
}
public String getCheese() {
return cheese;
}}
答案 0 :(得分:0)
你应该得到一个NullPointerException makeASandwih,因为三明治是null,然后你尝试调用一个实例方法
protected void makeASandwich() {
Sandwich sandwich = null;
sandwich.setCheese(jcbcheese.getItemAt(jcbcheese.getSelectedIndex()));
尝试创建三明治的新实例
protected void makeASandwich() {
Sandwich sandwich = new Sandwich();
sandwich.setCheese(jcbcheese.getItemAt(jcbcheese.getSelectedIndex()));