📄 mainguiapp.java
字号:
/*
* MainGUIApp.java
*
* Created on August 2, 2006, 8:02 PM
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
package ebay.client;
/**
*
* @author Elancheran
*/
import ebay.apis.*;
import javax.xml.ws.*;
import javax.swing.*;
import java.awt.event.*;
import java.util.Properties;
import java.io.*;
import java.util.List;
import java.util.Vector;
import ebay.client.handler.RequesterCredentials;
import javax.xml.ws.handler.Handler;
public class MainGUIApp extends javax.swing.JFrame{
private static final String baseURL = "https://api.ebay.com/wsapi?";
private static final String localURL = "http://localhost:7070/Ebay";
private static final String sandboxURL = "https://api.sandbox.ebay.com/wsapi?";
private static Properties props = new Properties();
private static CustomSecurityHeaderType header;
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;
private boolean multiTabView = false;
/** Creates a new instance of MainGUIApp */
public MainGUIApp() {
super("Web Services Ebay Client");
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
if(System.getProperty("http.proxyHost") != null &&
System.getProperty("http.proxyPort") != null)
{
this.proxyHostString = System.getProperty("http.proxyHost");
this.proxyPortString = System.getProperty("http.proxyPort");
}
}catch(Exception e) {
}
initComponents();
}
public static ItemType getItem(String endpointToUse, String itemId) {
boolean error = false;
String endpointURL = "";
EBayAPIInterfaceService svc = new EBayAPIInterfaceService();
EBayAPIInterface port = svc.getEBayAPI();
BindingProvider bp = (BindingProvider) port;
if (endpointToUse.equalsIgnoreCase("ebay")) {
endpointURL = baseURL + "callname=GetItem&siteid=0&appid=" +
(String)props.get("appID") + "&version=455&Routing=new";
List<Handler> handlerChain = new Vector();
handlerChain.add(new RequesterCredentials());
bp.getBinding().setHandlerChain(handlerChain);
}
else if(endpointToUse.equalsIgnoreCase("local")) {
endpointURL = localURL;
}
else {
System.exit(1);
}
bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY,
endpointURL);
GetItemRequestType itemRequest = new GetItemRequestType();
itemRequest.setVersion("455");
itemRequest.setItemID(itemId);
itemRequest.setErrorLanguage("en_US");
GetItemResponseType itemResponse = null;
try {
itemResponse = port.getItem(itemRequest);
}catch (Exception e) {
error = true;
}
if (error) {
return null;
}
else
return itemResponse.getItem();
}
public static void setProxyHost(String proxyHost){
proxyHostString = proxyHost;
}
public static void setProxyPort(String proxyPort){
proxyPortString = proxyPort;
}
public static String getProxyPort() {
return proxyPortString;
}
public static String getProxyHost() {
return proxyHostString;
}
private void initComponents() {
jPanel2 = new javax.swing.JPanel();
jPanel2.setBackground(new java.awt.Color(236,233,216));
jTextField1 = new javax.swing.JTextField();
jComboBox1 = new javax.swing.JComboBox();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jPanel3 = new javax.swing.JPanel();
jPanel3.setBackground(new java.awt.Color(236,233,216));
jButton1 = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
jMenu2 = new javax.swing.JMenu();
jMenuItem1 = new javax.swing.JMenuItem();
jMenu3 = new javax.swing.JMenu();
jMenuItem2 = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setResizable(false);
getContentPane().setBackground(new java.awt.Color(236, 233, 216));
jComboBox1.setFont(new java.awt.Font("Verdana", 0, 12));
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ebay Server", "Local Server" }));
jLabel1.setFont(new java.awt.Font("Verdana", 0, 12));
jLabel1.setText("Item Id");
jLabel2.setFont(new java.awt.Font("Verdana", 0, 12));
jLabel2.setText("Server");
javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
jPanel2.setLayout(jPanel2Layout);
jPanel2Layout.setHorizontalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
.addGap(50, 50, 50)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 77, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jComboBox1, 0, 113, Short.MAX_VALUE)
.addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 113, Short.MAX_VALUE))
.addContainerGap())
);
jPanel2Layout.setVerticalGroup(
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel2Layout.createSequentialGroup()
.addGap(23, 23, 23)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(15, 15, 15)
.addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(22, Short.MAX_VALUE))
);
jButton1.setFont(new java.awt.Font("Verdana", 0, 12));
jButton1.setText("Get Details");
jButton1.setMnemonic('G');
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addGap(164, 164, 164)
.addComponent(jButton1)
.addContainerGap(164, Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton1)
.addContainerGap(86, Short.MAX_VALUE))
);
jMenu1.setText("File");
jMenu1.setMnemonic('F');
jMenuItem1.setText("Exit");
jMenu1.add(jMenuItem1);
jMenuItem1.setMnemonic('x');
jMenuItem1.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae) {
exitApplication();
}
});
jMenuBar1.add(jMenu1);
jMenu3.setText("Edit");
jMenu3.setMnemonic('E');
jMenuItem2.setText("Preferences");
jMenuItem2.setMnemonic('P');
jMenuItem2.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent ae){
showPreferencesDialog();
}
});
jMenu3.add(jMenuItem2);
jMenuBar1.add(jMenu3);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(76, 76, 76)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(93, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(80, 80, 80)
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
pack();
}// </editor-fold>
public static void showMessageDialog(final java.awt.Container parent,
final String msg, final String title) {
SwingUtilities.invokeLater(new Runnable() {
public void run(){
javax.swing.JOptionPane.showMessageDialog(parent, msg, title,
javax.swing.JOptionPane.WARNING_MESSAGE);
}
});
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {
// TODO add your handling code here:
String currency = null;
java.lang.Object source = evt.getSource();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -