⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 standaloneclient.java

📁 java web services how to program
💻 JAVA
字号:
// Fig. 11.6: StandaloneClient.java// StandaloneClient is a standalone JAXM application that// uses BookTitlesProxy to invoke the Book Titles Web service.package com.deitel.jws1.jaxm.client;// Java core packagesimport java.awt.*;import java.awt.event.*;// Java extension packagesimport javax.swing.*;// initialize GUI for StandaloneClientpublic class StandaloneClient extends JFrame {   private final static int FRAME_WIDTH = 450;   private final static int FRAME_HEIGHT = 300;   public StandaloneClient( String title )   {      super( title );      // JList to display results from Web-service invocation      final JList resultsList = new JList();      resultsList.setSelectionMode(          ListSelectionModel.SINGLE_SELECTION );      // JButton invokes remote Web service      JButton serviceButton = new JButton( "Invoke Service" );      serviceButton.addActionListener(         new ActionListener() {            // invoked when user presses JButton            public void actionPerformed( ActionEvent event )            {               // invoke Web service and store results in JList               try {                  // invoke Web service via BookTitlesProxy                  BookTitlesProxy service =                      new BookTitlesProxy();                  String response[] = service.getBookTitles();                  // store results in JList                  resultsList.setListData( response );               }               // handle exception in Web-service invocation               catch ( java.io.IOException exception ) {                  exception.printStackTrace();               }            }         }      );      // store JButton on JPanel      JPanel userPanel = new JPanel();      userPanel.add( serviceButton );      // add JList and JPanel to GUI      getContentPane().add( new JScrollPane( resultsList ) );      getContentPane().add( userPanel, BorderLayout.SOUTH );   } // end constructor   // return size of StandaloneClient frame   public Dimension getPreferredSize()   {      return new Dimension( FRAME_WIDTH, FRAME_HEIGHT );   }   // instantiate StandaloneClient GUI   public static void main( String args[] )   {      StandaloneClient client =          new StandaloneClient( "Book Title Service" );      client.setDefaultCloseOperation( EXIT_ON_CLOSE );      client.pack();      client.setVisible( true );   }} // end class StandaloneClient

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -