Skip to content

Commit 7df096d

Browse files
author
yaoguangluo
committed
socket 请求服务器获取数据
1 parent 03d2b18 commit 7df096d

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

plugin/org/cache/devops/getCacheInfo/CacheInfoNodeInterface.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public CacheInfoNodeInterface() throws IOException{
1111
position = new String("BI");
1212
Image img = ((ImageIcon) thisicon).getImage();
1313
Image newimg = img.getScaledInstance(30,30,java.awt.Image.SCALE_SMOOTH );
14-
thisimage=img.getScaledInstance(50,50,java.awt.Image.SCALE_SMOOTH );
14+
thisimage = img.getScaledInstance(50,50,java.awt.Image.SCALE_SMOOTH );
1515
thisicon = new ImageIcon(newimg);
1616
}
1717
public void config() throws IOException{

plugin/org/cache/devops/getCacheInfo/CacheInfoNodePanel.java

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77

88
import java.awt.Panel;
99
import java.awt.ScrollPane;
10+
import java.awt.event.ActionEvent;
11+
import java.awt.event.ActionListener;
12+
import java.io.InputStream;
13+
import java.io.PrintWriter;
14+
import java.net.Socket;
1015
import java.awt.Color;
1116
public class CacheInfoNodePanel extends objectPanel{
1217
private static final long serialVersionUID = 1L;
@@ -23,25 +28,46 @@ public CacheInfoNodePanel(final CacheInfoNodeRun thisrun){
2328
label.setBounds(2, 2, 80, 30);
2429
JTextField ipport= new JTextField("xxx.xxx.xxx.xxx:xxxxx", 18);
2530
ipport.setBounds(2+85, 2, 200, 30);
26-
31+
2732
JLabel labelName= new JLabel("登录名称:");
2833
labelName.setBounds(2, 2+35, 80, 30);
2934
JTextField jTextFieldName= new JTextField("输入用户名称", 18);
3035
jTextFieldName.setBounds(2+85, 2+35, 200, 30);
31-
36+
3237
JLabel labelPswd= new JLabel("登录密码:");
3338
labelPswd.setBounds(2, 2+35+35, 80, 30);
3439
JTextField jTextFieldPswd= new JTextField("输入用户密码", 18);
3540
jTextFieldPswd.setBounds(2+85, 2+35+35, 200, 30);
3641
//
3742
JButton jbutton=new JButton("确定");
3843
jbutton.setBounds(2, 2+35+35+35, 80, 30);
44+
jbutton.addActionListener(new ActionListener(){
45+
public void actionPerformed(ActionEvent arg0) {
46+
try {
47+
String textOfLabelName = labelName.getText();
48+
String textOflabelPswd = labelPswd.getText();
49+
String textOfIpport = ipport.getText();
50+
Socket socket = new Socket(textOfIpport.split(":")[0],Integer.valueOf(textOfIpport.split(":")[1]));
51+
PrintWriter os = new PrintWriter(socket.getOutputStream());
52+
//os.println("/111");
53+
//添加输入值
54+
os.flush();
55+
InputStream is = socket.getInputStream();
56+
byte[] bytes=new byte[1024];
57+
while((is.read(bytes, 0, 1024)) != -1) {
58+
//System.out.println("1"+new String(bytes));
59+
//得到输出值
60+
}
61+
}catch(Exception e) {
62+
63+
}
64+
}});
3965
jp.add(labelName);
4066
jp.add(jTextFieldName);
4167
jp.add(labelPswd);
4268
jp.add(jTextFieldPswd);
43-
44-
69+
70+
4571
jp.add(label);
4672
jp.add(ipport);
4773
jp.add(jbutton);

0 commit comments

Comments
 (0)