我在开始开发的 Java 程序中遇到了一些问题。这将是哈利波特名声的 Honeydukes Candy Store 的在线订购系统,并且将是两个独立的程序。客户端程序将在 Swing 中,并接受订单和所有其他内容,并在下订单时将其发送到服务器程序。服务器程序将明显不那么漂亮,它的目标是将订单写入文本文件,然后再为一切顺利的客户端程序开绿灯。
对于客户端程序,我想要三个面板,主面板包含另外两个。左侧是 invntryPanel,包含一个包含商店库存的 JList。右侧将保存 infoPanel,它使用 CardLayout 在各种面板之间切换,使用 JList 中当前选择的项目来确定要显示哪个面板。信息面板也将是用户选择希望购买的数量的地方。
当用户完成订单时,可以点击一个我还没有完全确定位置的按钮,它会打开一个单独的窗口,询问一般信息(姓名等),并显示他们的总数。最后单击该窗口上的按钮会将订单发送到服务器程序,客户端应用程序将在收到来自服务器程序的请求已通过的确认后关闭。
我已经开始了,但是编译器今天似乎心情不好。我究竟做错了什么?
对于这是一个以自我为中心的问题,我深表歉意,但我只是不确定还能去哪里。我检查了多个其他资源,我的代码似乎是有序的,但显然不是。
先感谢您。
来源:
import javax.swing.*;
import java.util.*;
import java.awt.*;
public class ClientApp extends JFrame
{
public static void main(String[] args)
{
new ClientApp();
}
public ClientApp()
{
this.setSize(320,200);
this.setTitle("Honeydukes Candy Order");
this.setDefaultCloseOperation(
JFrame.EXIT_ON_CLOSE);
ButtonListener bl = new ButtonListener();
JPanel mainPanel = new JPanel();
JPanel infoPanel = new JPanel(new CardLayout());
JPanel invntryPanel = new JPanel();
String[] candy = {"Acid Pops", "Bat's Blood Soup",
"Bertie Bott's Every Flavour Beans",
"Blood-flavoured Lollipops",
"Cauldron Cakes", "Charm Choc",
"Chocoballs", "Chocolate Cauldrons",
"Chocolate Frogs", "Chocolate Skeletons",
"Chocolate Wands", "Choco-Loco", "Cockroach Clusters",
"Nougat", "Crystallised Pineapple",
"Drooble's Best Blowing Gum", "Exploding Bonbons",
"Toffees", "Fizzing Whizzbees",
"Fudge Flies", "Ice Mice",
"Jelly Slugs", "Liquourice Wands",
"Pepper Imps", "Peppermint Toads",
"Pink Coconut Ice", "Pixie Puffs",
"Pumpkin Fizz", "Salt Water Taffy",
"Shock-o-Choc", "Skeletal Sweets",
"Splindle's Lick'O'Rish Spiders",
"Sugar Quills", "Sugared Butterfly Wings",
"Toothflossing Stringmints", "Tooth-Splintering Strongmints",
"Treacle Fudge", "Chocolates", "Wizochoc"};
JList candyList = new JList(candy);
candyList.setVisibleRowCount(candy.length);
candyList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
JScrollPane scroll = new JScrollPane(candyList);
invntryPanel.add(scroll);
mainPanel.add(invntryPanel);
this.setVisible(true);
}
}
错误:
ClientApp.java:20: error: cannot find symbol
BasicButtonListener bl = new BasicButtonListener();
^
symbol: class BasicButtonListener
location: class ClientApp
ClientApp.java:20: error: cannot find symbol
BasicButtonListener bl = new BasicButtonListener();
^
symbol: class BasicButtonListener
location: class ClientApp
Note: ClientApp.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
2 errors