import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import java.text.*;
/**
* Gourmet Coffee System.
*
* @author
* @version 1.1.0
* @see Product
* @see Coffee
* @see CoffeeBrewer
* @see Catalog
* @see OrderItem
* @see Order
* @see Sales
* @see CatalogLoader
* @see FileCatalogLoader
* @see DataFormatException
* @see SalesFormatter
* @see PlainTextSalesFormatter
* @see HTMLSalesFormatter
* @see XMLSalesFormatter
*/
public class GourmetCoffeeGUI extends JPanel {
/* Standar error stream */
static private PrintWriter stdErr = new PrintWriter(System.err, true);
/* Window width in pixels */
static private int WIDTH = 600;
/* Window height in pixels */
static private int HEIGHT = 530;
/* Size of the catalog list cell in pixels */
static private int CATALOG_CELL_SIZE = 50;
/* Visible rows in catalog list */
static private int CATALOG_LIST_ROWS = 14;
/* Size of the order list cell in pixels */
static private int ORDER_CELL_SIZE = 100;
/* Visible rows in order list */
static private int ORDER_LIST_ROWS = 6;
/* Size quantity text field */
static private int QUANTITY__TEXTFIELD_SIZE = 5;
/* Size total text field */
static private int TOTAL__TEXTFIELD_SIZE = 8;
/* Rows in status text area rows */
static private int STATUS_ROWS = 10;
/* Rows in status text area cols */
static private int STATUS_COLS = 40;
private JList catalogList;
private JList orderList;
private JButton addModifyButton;
private JButton removeButton;
private JButton registerSaleButton;
private JButton displaySalesButton;
private JButton saveSalesButton;
private JPanel productPanel;
private JLabel quantityLabel;
private JLabel totalLabel;
private JTextField quantityTextField;
private JTextField totalTextField;
private JTextArea statusTextArea;
private JRadioButton plainRadioButton;
private JRadioButton HTMLRadioButton;
private JRadioButton XMLRadioButton;
private JFileChooser fileChooser;
private Catalog catalog;
private Order currentOrder;
private Sales sales;
private SalesFormatter salesFormatter;
private NumberFormat dollarFormatter;
/**
* Loads a product catalog and starts the application.
*
* @param args
* String arguments. Not used.
* @throws IOException
* if there are errors in the loading the catalog.
*/
public static void main(String[] args) throws IOException {
String line = "catalog.dat";
args = new String[1];
args[0] = line;
String filename = "";
if (args.length != 1) {
filename = "catalog.dat";
} else {
filename = args[0];
}
try {
Catalog catalog = (new FileCatalogLoader()).loadCatalog(filename);
JFrame frame = new JFrame("Gourmet Coffee");
frame.setContentPane(new GourmetCoffeeGUI(catalog));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(WIDTH, HEIGHT);
frame.setResizable(true);
frame.setVisible(true);
} catch (FileNotFoundException fnfe) {
stdErr.println("The file does not exist");
System.exit(1);
} catch (DataFormatException dfe) {
stdErr.println("The file contains malformed data: "
+ dfe.getMessage());
System.exit(1);
}
}
/**
* Instantiates the components and arranges them in a window.
*
* @param initialCatalog
* a product catalog.
*/
public GourmetCoffeeGUI(Catalog initialCatalog) {
// create the components
catalogList = new JList();
orderList = new JList();
catalogList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
catalogList.setVisibleRowCount(CATALOG_LIST_ROWS);
catalogList.setFixedCellWidth(CATALOG_CELL_SIZE);
orderList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
orderList.setVisibleRowCount(ORDER_LIST_ROWS);
orderList.setFixedCellWidth(ORDER_CELL_SIZE);
addModifyButton = new JButton("Add|Modify Order Item");
removeButton = new JButton("Remove Order Item");
registerSaleButton = new JButton("Register Sale of Current Order");
displaySalesButton = new JButton("Display Sales");
saveSalesButton = new JButton("Save Sales");
quantityLabel = new JLabel("Quantity:");
totalLabel = new JLabel("Total:");
quantityTextField = new JTextField("", QUANTITY__TEXTFIELD_SIZE);
totalTextField = new JTextField("$0.00", TOTAL__TEXTFIELD_SIZE);
totalTextField.setEditable(false);
statusTextArea = new JTextArea(STATUS_ROWS, STATUS_COLS);
statusTextArea.setEditable(false);
plainRadioButton = new JRadioButton("Plain", true);
HTMLRadioButton = new JRadioButton("HTML");
XMLRadioButton = new JRadioButton("XML");
ButtonGroup group = new ButtonGroup();
group.add(plainRadioButton);
group.add(HTMLRadioButton);
group.add(XMLRadioButton);
// Product Information panel
productPanel = new JPanel();
productPanel.setBorder(BorderFactory
.createTitledBorder("Product Information"));
// Catalog panel
JPanel catalogPanel = new JPanel();
catalogPanel.setBorder(BorderFactory.createTitledBorder("Catalog"));
catalogPanel.add(new JScrollPane(catalogList,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER));
// "Add|Modify Product" panel
JPanel centralPanel = new JPanel(new BorderLayout());
JPanel addModifyPanel = new JPanel(new GridLayout(2, 1));
JPanel quantityPanel = new JPanel();
quantityPanel.add(quantityLabel);
quantityPanel.add(quantityTextField);
addModifyPanel.add(quantityPanel);
addModifyPanel.add(addModifyButton);
centralPanel.add(productPanel, BorderLayout.CENTER);
centralPanel.add(addModifyPanel, BorderLayout.SOUTH);
// Order panel
JPanel orderPanel = new JPanel(new BorderLayout());
orderPanel.setBorder(BorderFactory.createTitledBorder("Order"));
JPanel totalPanel = new JPanel();
totalPanel.add(totalLabel);
totalPanel.add(totalTextField);
JPanel buttonsPanel = new JPanel(new GridLayout(2, 1));
buttonsPanel.add(removeButton);
buttonsPanel.add(registerSaleButton);
orderPanel.add(totalPanel, BorderLayout.NORTH);
orderPanel.add(new JScrollPane(orderList,
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER), BorderLayout.CENTER);
orderPanel.add(buttonsPanel, BorderLayout.SOUTH);
// Status panel
JPanel bottomPanel = new JPanel(new BorderLayout());
bottomPanel.setBorder(BorderFactory.createTitledBorder("Status"));
JPanel salesButtonsPanel = new JPanel(new GridLayout(1, 5));
salesButtonsPanel.add(plainRadioButton);
salesButtonsPanel.add(HTMLRadioButton);
salesButtonsPanel.add(XMLRadioButton);
salesButtonsPanel.add(displaySalesButton);
salesButtonsPanel.add(saveSalesButton);
bottomPanel.add(new JScrollPane(statusTextArea,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED),
BorderLayout.CENTER);
bottomPanel.add(salesButtonsPanel, BorderLayout.SOUTH);
// arrange panels in window
setLayout(new BorderLayout());
add(catalogPanel, BorderLayout.WEST);
add(centralPanel, BorderLayout.CENTER);
add(orderPanel, BorderLayout.EAST);
add(bottomPanel, BorderLayout.SOUTH);
// start listening for list and buttons events
catalogList.addListSelectionListener(new DisplayProductListener());
addModifyButton.addActionListener(new AddModifyListener());
removeButton.addActionListener(new RemoveListener());
registerSaleButton.addActionListener(new RegisterSaleListener());
displaySalesButton.addActionListener(new DisplaySalesListener());
saveSalesButton.addActionListener(new SaveSalesListener());
plainRadioButton.addActionListener(new PlainListener());
HTMLRadioButton.addActionListener(new HTMLListener());
XMLRadioButton.addActionListener(new XMLListener());
// populate
没有合适的资源?快使用搜索试试~ 我知道了~
c++编程思想第二卷
共520个文件
cpp:395个
h:63个
mak:16个
需积分: 9 8 下载量 39 浏览量
2008-10-22
18:23:21
上传
评论
收藏 1.4MB RAR 举报
温馨提示
c++编程思想第二卷,英文版的,挺不错的!讲述了stl模板库还有异常处理等
资源推荐
资源详情
资源评论
收起资源包目录
c++编程思想第二卷 (520个子文件)
thinking in c++ 第二卷CHM 帮助.chm 660KB
c++编程思想第二卷CHM 帮助.chm 428KB
CarBuilder.cpp 7KB
Date.cpp 5KB
ObservedFlower.cpp 5KB
Cppcheck.cpp 5KB
ExtractCode.cpp 4KB
ToastOMaticMarkII.cpp 4KB
BitSet.cpp 4KB
BankTeller.cpp 3KB
OrnamentalGarden.cpp 3KB
ToastOMatic.cpp 3KB
Bicycle.cpp 3KB
Showerr.cpp 3KB
ShapeFactory2.cpp 3KB
WildLifeMonitor.cpp 3KB
SafeAssign.cpp 3KB
SearchReplace.cpp 3KB
FunctionObjects.cpp 3KB
MulticastCommand.cpp 3KB
Manipulations.cpp 3KB
BasicSequenceOperations.cpp 3KB
MyVector2.cpp 3KB
PaperScissorsRock.cpp 3KB
VirtualConstructor.cpp 3KB
Thesaurus.cpp 3KB
BeeAndFlowers.cpp 3KB
CheckedCast.cpp 3KB
SortedSearchTest.cpp 3KB
MemCheck.cpp 2KB
WaxOMatic.cpp 2KB
BuggedSearch.cpp 2KB
MyVector.cpp 2KB
Ring.cpp 2KB
BuildBicycles.cpp 2KB
TokenIteratorTest.cpp 2KB
Suite.cpp 2KB
StringDeque.cpp 2KB
AbstractFactory.cpp 2KB
Recycle.cpp 2KB
Format.cpp 2KB
ShapeFactory1.cpp 2KB
ThreadLocalVariables.cpp 2KB
Comparison.cpp 2KB
FibonacciAdapter.cpp 2KB
HTMLStripper.cpp 2KB
PriorityQueue6.cpp 2KB
Recycle2.cpp 2KB
MultiSet1.cpp 2KB
Removing.cpp 2KB
Seeking.cpp 2KB
Manips.cpp 2KB
Valarray2.cpp 2KB
MapVsHashMap.cpp 2KB
AssociativeBasics.cpp 2KB
Interrupting3.cpp 2KB
ChainOfReponsibility.cpp 2KB
PriorityQueue7.cpp 2KB
InnerClassIdiom.cpp 2KB
VirtualBase3.cpp 2KB
HTMLStripper2.cpp 2KB
Inserters.cpp 2KB
Sortable.cpp 2KB
ListSpecialFunctions.cpp 2KB
PartialOrder2.cpp 2KB
VirtInit.cpp 2KB
MatrixMultiply.cpp 2KB
NumericTest.cpp 2KB
Wrapped.cpp 2KB
TempTemp.cpp 2KB
SimplePriorities.cpp 1KB
Effector.cpp 1KB
ComposeFinal.cpp 1KB
DataLogger.cpp 1KB
VectorOfBool.cpp 1KB
SimpleDateTest2.cpp 1KB
IndexingVsAt.cpp 1KB
PriorityQueue3.cpp 1KB
VirtualBase2.cpp 1KB
Paste.cpp 1KB
MessengerDemo.cpp 1KB
HiLo.cpp 1KB
Interfaces.cpp 1KB
VirtualBase.cpp 1KB
Stack2.cpp 1KB
StringSuite.cpp 1KB
ListVsSet.cpp 1KB
Strfile.cpp 1KB
BearCorner2.cpp 1KB
TempTemp4.cpp 1KB
BadException.cpp 1KB
SleepingTask.cpp 1KB
Stlshape.cpp 1KB
Datagen.cpp 1KB
SpecialList.cpp 1KB
SetOperations.cpp 1KB
Stlshape2.cpp 1KB
FindBlanks.cpp 1KB
ListStability.cpp 1KB
WordList.cpp 1KB
共 520 条
- 1
- 2
- 3
- 4
- 5
- 6
资源评论
右边的石頭
- 粉丝: 0
- 资源: 8
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功