📄 quryapplet.java~3~
字号:
package javaservlets.tunnel;import java.awt.*;import java.awt.event.*;import java.applet.*;import com.borland.jbcl.layout.*;import javax.swing.*;/** * Title: * Description: * Copyright: Copyright (c) 2002 * Company: * @author * @version 1.0 */public class quryApplet extends Applet { IndyInterface indy; boolean isStandalone = false; BorderLayout borderLayout1 = new BorderLayout(); Panel panel1 = new Panel(); Button button1 = new Button(); ScrollPane scrollPane1 = new ScrollPane(); TextArea textArea1 = new TextArea(); JPanel jPanel1 = new JPanel(); JButton jButton1 = new JButton(); JScrollPane jScrollPane1 = new JScrollPane(); JTextArea jTextArea1 = new JTextArea(); /**Get a parameter value*/ public String getParameter(String key, String def) { return isStandalone ? System.getProperty(key, def) : (getParameter(key) != null ? getParameter(key) : def); } /**Construct the applet*/ public quryApplet() { } /**Initialize the applet*/ public void init() { try { jbInit(); } catch(Exception e) { e.printStackTrace(); } } /**Component initialization*/ private void jbInit() throws Exception { jButton1.setText("qurey"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { jButton1_actionPerformed(e); } }); this.setLayout(borderLayout1); button1.setLabel("qurey"); textArea1.setText("textArea1"); jPanel1.add(jButton1, null); jScrollPane1.getViewport().add(jTextArea1, null); try { indy = new RemoteIndyClient("http://localhost:7001/servlet/");//(getCodeBase() + "servlet/"); // Open the database connection boolean rc = indy.connect(); if (!rc) { System.out.println("Connection not initialized"); indy = null; } } catch (Exception ex) { ex.printStackTrace(); } } /**Start the applet*/ public void start() { } /**Stop the applet*/ public void stop() { } /**Destroy the applet*/ public void destroy() { } /**Get Applet information*/ public String getAppletInfo() { return "Applet Information"; } /**Get parameter info*/ public String[][] getParameterInfo() { return null; } /**Main method*/ public static void main(String[] args) { quryApplet applet = new quryApplet(); applet.isStandalone = true; Frame frame; frame = new Frame() { protected void processWindowEvent(WindowEvent e) { super.processWindowEvent(e); if (e.getID() == WindowEvent.WINDOW_CLOSING) { System.exit(0); } } public synchronized void setTitle(String title) { super.setTitle(title); enableEvents(AWTEvent.WINDOW_EVENT_MASK); } }; frame.setTitle("Applet Frame"); frame.add(applet, BorderLayout.CENTER); applet.init(); applet.start(); frame.setSize(400,320); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); frame.setLocation((d.width - frame.getSize().width) / 2, (d.height - frame.getSize().height) / 2); frame.setVisible(true); } void jButton1_actionPerformed(ActionEvent e) { if (indy == null) { System.out.println("Indy is null"); return; } // Get the indy record IndyRecord[] r = indy.query(); // Populate if (r != null) { // driver.setText(r.driver); // speed.setText("" + r.speed); for(int i=0;i<r.length;i++) { jTextArea1.setText(r[i].toString()); } } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -