1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
|
import javax.swing.JApplet;
import javax.swing.JLabel;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import javax.swing.JTextField;
import javax.swing.JButton;
import javax.swing.JPanel;
public class Test extends JApplet {
private static final long serialVersionUID = 1L;
private JLabel label1 = new JLabel("LoginId");
private JLabel label4 = new JLabel("gameType");
private JTextField jtf_loginId = new JTextField("10");
private JTextField jtf_gameType = new JTextField("0");
public void init(){
this.setSize(300, 80);
JPanel top = new JPanel();
Font police = new Font("Arial", Font.BOLD, 14);
jtf_loginId.setFont(police);
jtf_loginId.setPreferredSize(new Dimension(150, 30));
jtf_loginId.setForeground(Color.GREEN);
jtf_gameType.setFont(police);
jtf_gameType.setPreferredSize(new Dimension(150, 30));
jtf_gameType.setForeground(Color.GREEN);
top.add(label1);
top.add(jtf_loginId);
top.add(label4);
top.add(jtf_gameType);
this.setContentPane(top);
this.setVisible(true);
String LoginId = "UserName=" + jtf_loginId.getText();
String GameType = "Time1=" + jtf_gameType.getText();
String url = "http://*********/Tangram.Metric/Metric/Create?" + LoginId + "&" + GameType;
String source ="";
URL oracle = null;
try {
oracle = new URL(url);
} catch (MalformedURLException e2) {
// TODO Auto-generated catch block
e2.printStackTrace();
}
URLConnection yc = null;
try {
yc = oracle.openConnection();
} catch (IOException e3) {
// TODO Auto-generated catch block
e3.printStackTrace();
}
BufferedReader in = null;
try {
in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
source +=inputLine;
in.close();
} catch (IOException e4) {
// TODO Auto-generated catch block
e4.printStackTrace();
}
}
} |
Partager