📄 titleinfowindow.java
字号:
//
// Unified Library Application
// Case study in Unified Modeling Language Toolkit
//
// TitleInfoWindow.java
//
//
// Copyright (c) 1998 John Wiley & Sons, Inc. All rights reserved.
// Reproduction or translations of this work beyond that permitted
// in Section 117 of the 1976 United States Copyright Act without
// the express written permission of the copyright owner is unlawful.
// Requests for further information should be addressed to Permissions
// Department, John Wiley & Sons, Inc. The purchaser may make back-up
// copies for his/her own use only and not for distribution or resale.
// The Publisher assumes no responsibility for errors, omissions, or
// damages, caused by the use of these programs of from the use of the
// information contained herein.
package ui;
import bo.*;
import util.*;
import java.awt.*;
public class TitleInfoWindow extends Frame implements ResultOfFindTitle {
void findButton_Clicked(Event event) {
FindTitleDialog dlg = new FindTitleDialog(this,true);
dlg.show();
}
void okButton_Clicked(Event event) {
dispose();
}
public void resultTitle(ObjId id)
{
Title current = Title.getTitle(id);
titleField.setText(current.getTitle());
authorField.setText(current.getAuthor());
isbnField.setText(current.getISBN());
typeField.setText(current.getTypeAsString());
reservationsList.clear();
Reservation reservation;
int index = 0;
while ((reservation = current.getReservation(index)) != null)
{
reservationsList.addItem(reservation.getBorrower().getLastName());
index++;
}
itemList.clear();
Item item;
index = 0;
while ((item = current.getItem(index)) != null)
{
String toadd;
toadd = " (Item:" + item.getId() + " )";
if (item.isBorrowed())
toadd = toadd + ": Borrowed";
else
toadd = toadd + ": Free";
itemList.addItem(toadd);
index++;
}
}
public TitleInfoWindow() {
//{{INIT_CONTROLS
setLayout(null);
addNotify();
resize(insets().left + insets().right + 448,insets().top + insets().bottom + 304);
setFont(new Font("Dialog", Font.PLAIN, 12));
titleLabel = new java.awt.Label("Title Name");
titleLabel.reshape(insets().left + 12,insets().top + 24,84,24);
add(titleLabel);
titleField = new java.awt.TextField();
titleField.setEditable(false);
titleField.reshape(insets().left + 132,insets().top + 24,183,24);
titleField.setBackground(new Color(12632256));
add(titleField);
isbnField = new java.awt.TextField();
isbnField.setEditable(false);
isbnField.reshape(insets().left + 132,insets().top + 96,120,24);
isbnField.setBackground(new Color(12632256));
add(isbnField);
authorField = new java.awt.TextField();
authorField.setEditable(false);
authorField.reshape(insets().left + 132,insets().top + 60,183,24);
authorField.setBackground(new Color(12632256));
add(authorField);
label1 = new java.awt.Label("ISBN / Nr");
label1.reshape(insets().left + 12,insets().top + 96,84,24);
add(label1);
label2 = new java.awt.Label("Author");
label2.reshape(insets().left + 12,insets().top + 60,84,24);
add(label2);
findButton = new java.awt.Button("Find");
findButton.reshape(insets().left + 348,insets().top + 24,74,25);
add(findButton);
okButton = new java.awt.Button("OK");
okButton.reshape(insets().left + 348,insets().top + 60,74,25);
add(okButton);
itemList = new java.awt.List(0,false);
add(itemList);
itemList.reshape(insets().left + 24,insets().top + 216,168,70);
label8 = new java.awt.Label("Items Available");
label8.reshape(insets().left + 24,insets().top + 180,132,24);
add(label8);
reservationsList = new java.awt.List(0,false);
add(reservationsList);
reservationsList.reshape(insets().left + 216,insets().top + 216,216,70);
label3 = new java.awt.Label("Reservations");
label3.reshape(insets().left + 216,insets().top + 180,132,24);
add(label3);
label4 = new java.awt.Label("Type");
label4.reshape(insets().left + 12,insets().top + 132,84,24);
add(label4);
typeField = new java.awt.TextField();
typeField.setEditable(false);
typeField.reshape(insets().left + 132,insets().top + 132,120,24);
typeField.setBackground(new Color(12632256));
add(typeField);
setTitle("Title Information");
//}}
//{{INIT_MENUS
//}}
}
public TitleInfoWindow(String title) {
this();
setTitle(title);
}
public synchronized void show() {
move(50, 50);
super.show();
}
public boolean handleEvent(Event event) {
if (event.id == Event.WINDOW_DESTROY) {
dispose();
return true;
}
if (event.target == findButton && event.id == Event.ACTION_EVENT) {
findButton_Clicked(event);
return true;
}
if (event.target == okButton && event.id == Event.ACTION_EVENT) {
okButton_Clicked(event);
return true;
}
return super.handleEvent(event);
}
//{{DECLARE_CONTROLS
java.awt.Label titleLabel;
java.awt.TextField titleField;
java.awt.TextField isbnField;
java.awt.TextField authorField;
java.awt.Label label1;
java.awt.Label label2;
java.awt.Button findButton;
java.awt.Button okButton;
java.awt.List itemList;
java.awt.Label label8;
java.awt.List reservationsList;
java.awt.Label label3;
java.awt.Label label4;
java.awt.TextField typeField;
//}}
//{{DECLARE_MENUS
//}}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -