viewitemdetails.java
来自「一个小公司要求给写的很简单的任务管理系统。」· Java 代码 · 共 379 行 · 第 1/2 页
JAVA
379 行
/*
* ViewItemDetails.java
*
* Created on August 3, 2006, 9:37 PM
*/
package ebay.client;
/**
*
* @author Elancheran
*/
import ebay.apis.*;
public class ViewItemDetails extends javax.swing.JFrame {
private java.awt.image.BufferedImage image = null;
private String itemDetailString;
private String itemId;
private String[] details = new String[5];
private String[] values = new String[5];
private String desc;
/** Creates new form NewDetailsFrame */
public ViewItemDetails(String itemId, ItemType item) {
super();
String currency = null;
this.itemId = itemId;
setTitle("Item Id: "+itemId);
if( item.getTitle() != null) {
itemDetailString = item.getTitle();
//System.out.println("Found item: " + itemDetailString);
}
if (item.getPictureDetails() != null) {
//System.out.println("Picture url is " + item.getPictureDetails().getGalleryURL());
try {
java.net.URL url = new java.net.URL(item.getPictureDetails().getGalleryURL());
image = javax.imageio.ImageIO.read(url);
}catch(java.io.IOException ie) {
//ie.printStackTrace();
//System.out.println("Image not found!!!");
image = null;
}
}
if(item.getCurrency() != null) {
//System.out.println("Currency: " + item.getCurrency().value());
currency = item.getCurrency().value();
}
if (item.getDescription() != null) {
//System.out.println("Description: " + item.getDescription());
desc = item.getDescription();
}
int i=0;
if (item.getBestOfferDetails() != null) {
//System.out.println("Current bid: " + item.getBestOfferDetails());
details[i] = "Current Bid: ";
if( currency != null){
values[i] = currency + " " +
String.valueOf(item.getBestOfferDetails().getBestOffer()
.getValue());
} else {
values[i] = String.valueOf(item.getBestOfferDetails()
.getBestOffer().getValue());
}
i++;
}
if (item.getBuyItNowPrice() != null) {
details[i] = "Buy it Now: ";
//System.out.println("Buy it now: " + item.getBuyItNowPrice().getValue());
values[i] = String.valueOf(item.getBuyItNowPrice().getValue());
if( currency != null )
values[i] = values[i] + " " + currency;
i++;
}
if(item.getTimeLeft()!= null) {
//System.out.println("End Time: " + item.getTimeLeft().toString());
details[i] ="End Time: ";
String timeLeft = "";
if(item.getTimeLeft().getDays() != 0) {
timeLeft = item.getTimeLeft().getDays() + " Days ";
}
if(item.getTimeLeft().getHours() != 0)
timeLeft = timeLeft + item.getTimeLeft().getHours() + " Hrs ";
if(item.getTimeLeft().getMinutes() != 0)
timeLeft = timeLeft + item.getTimeLeft().getMinutes() + " Mins ";
if(item.getTimeLeft().getSeconds() != 0)
timeLeft = timeLeft + item.getTimeLeft().getSeconds() + " Secs ";
values[i] = timeLeft;
i++;
}
if(item.getQuantity() != null) {
//System.out.println("Quantity: " + item.getQuantity());
details[i] ="Quantity: ";
values[i] = String.valueOf(item.getQuantity());
i++;
}
if(item.getLocation() != null) {
//System.out.println("Location: " + item.getLocation());
details[i] ="Location: ";
values[i] = item.getLocation();
}
initComponents();
setVisible(true);
}
public void initComponents(){
mainPanel = new javax.swing.JPanel();
headerPanel = new javax.swing.JPanel();
itemDetailsLabel = new javax.swing.JLabel();
itemIdLabel = new javax.swing.JLabel();
detailsPanel = new javax.swing.JPanel();
priceLabel = new javax.swing.JLabel();
amoutLabel = new javax.swing.JLabel();
jSeparator1 = new javax.swing.JSeparator();
detailLabel1 = new javax.swing.JLabel();
valueLabel1 = new javax.swing.JLabel();
detailLabel2 = new javax.swing.JLabel();
valueLabel2 = new javax.swing.JLabel();
detailLabel3 = new javax.swing.JLabel();
valueLabel3 = new javax.swing.JLabel();
detailLabel4 = new javax.swing.JLabel();
valueLabel4 = new javax.swing.JLabel();
jSeparator2 = new javax.swing.JSeparator();
jScrollPane1 = new javax.swing.JScrollPane();
descriptionPane = new javax.swing.JTextPane();
descriptionPane.setEditable(false);
if(image != null) {
imagePanel = new javax.swing.JPanel(){
public void processComponentEvent(java.awt.event.ComponentEvent ce) {
super.processComponentEvent(ce);
if (ce.getID() == java.awt.event.ComponentEvent.COMPONENT_RESIZED) {
repaint();
}
}
public void paintComponent(java.awt.Graphics g) {
super.paintComponent(g);
g.drawImage(image,0,0, this.getWidth(), this.getHeight(), this);
}
};
} else {
imagePanel = new javax.swing.JPanel();
}
initComponentsData();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setResizable(false);
itemDetailsLabel.setFont(new java.awt.Font("Verdana", 1, 12));
itemIdLabel.setFont(new java.awt.Font("Verdana", 0, 12));
javax.swing.GroupLayout headerPanelLayout = new javax.swing.GroupLayout(headerPanel);
headerPanel.setLayout(headerPanelLayout);
headerPanelLayout.setHorizontalGroup(
headerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, headerPanelLayout.createSequentialGroup()
.addContainerGap()
.addComponent(itemDetailsLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 306, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(itemIdLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
headerPanelLayout.setVerticalGroup(
headerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, headerPanelLayout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(headerPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(itemIdLabel)
.addComponent(itemDetailsLabel))
.addContainerGap())
);
imagePanel.setBackground(new java.awt.Color(255, 255, 204));
javax.swing.GroupLayout imagePanelLayout = new javax.swing.GroupLayout(imagePanel);
imagePanel.setLayout(imagePanelLayout);
imagePanelLayout.setHorizontalGroup(
imagePanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGap(0, 150, Short.MAX_VALUE)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?