📄 client.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: Client.java
import com.sun.image.codec.jpeg.JPEGCodec;
import com.sun.image.codec.jpeg.JPEGImageDecoder;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.BufferedImage;
import java.io.*;
import java.net.*;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.rmi.registry.LocateRegistry;
import java.rmi.registry.Registry;
import javax.swing.*;
class Client extends JFrame
implements ActionListener, KeyListener, MouseMotionListener, MouseWheelListener, MouseListener
{
BufferedImage image;
String IP;
JDialog d;
JTextField t;
RobotControllmpl robot;
public Client()
{
d = new JDialog(this, true);
d.setTitle("请输入服务器IP:");
t = new JTextField(20);
d.getContentPane().add(t);
t.addActionListener(this);
d.pack();
d.setVisible(true);
setSize(500, 500);
setDefaultCloseOperation(3);
try
{
System.out.println(IP);
Socket socket = new Socket(IP, 5678);
java.io.InputStream in = socket.getInputStream();
BufferedInputStream input = new BufferedInputStream(in);
socket.setTcpNoDelay(true);
socket.setReceiveBufferSize(0x100000);
String addr = socket.getInetAddress().getHostAddress();
Registry registry = LocateRegistry.getRegistry(addr, 1056);
robot = (RobotControllmpl)registry.lookup("robot");
initComponents();
for (; socket.isConnected(); repaint())
{
Thread.sleep(50L);
socket.sendUrgentData(255);
JPEGImageDecoder decoder = JPEGCodec.createJPEGDecoder(input);
image = decoder.decodeAsBufferedImage();
}
}
catch (UnknownHostException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
catch (NotBoundException e)
{
e.printStackTrace();
}
}
public static void main(String args[])
{
new Client();
}
public void paint(Graphics g)
{
g.drawImage(image, 0, 0, Toolkit.getDefaultToolkit().getScreenSize().width, Toolkit.getDefaultToolkit().getScreenSize().height, null);
}
public void initComponents()
{
addMouseListener(this);
addKeyListener(this);
addMouseMotionListener(this);
addMouseWheelListener(this);
}
public void actionPerformed(ActionEvent e)
{
if (e.getSource().equals(t))
{
IP = t.getText();
d.dispose();
setVisible(true);
}
}
public void keyPressed(KeyEvent e)
{
try
{
robot.keyPress(e.getKeyCode());
}
catch (RemoteException e1)
{
e1.printStackTrace();
}
}
public void keyReleased(KeyEvent e)
{
try
{
robot.keyRelease(e.getKeyCode());
}
catch (RemoteException e1)
{
e1.printStackTrace();
}
}
public void keyTyped(KeyEvent keyevent)
{
}
public void mouseDragged(MouseEvent mouseevent)
{
}
public void mouseMoved(MouseEvent e)
{
try
{
robot.mouseMove(e.getX(), e.getY());
}
catch (RemoteException e1)
{
e1.printStackTrace();
}
}
public void mouseWheelMoved(MouseWheelEvent e)
{
try
{
robot.mouseWheel(e.getWheelRotation());
}
catch (RemoteException e1)
{
e1.printStackTrace();
}
}
public void mouseClicked(MouseEvent mouseevent)
{
}
public void mouseEntered(MouseEvent mouseevent)
{
}
public void mouseExited(MouseEvent mouseevent)
{
}
public void mousePressed(MouseEvent e)
{
int n = e.getButton();
try
{
if (n == 1)
robot.mousePress(16);
else
if (n == 2)
robot.mousePress(8);
else
if (n == 3)
robot.mousePress(4);
}
catch (RemoteException e1)
{
e1.printStackTrace();
}
catch (Exception e2)
{
e2.printStackTrace();
}
}
public void mouseReleased(MouseEvent e)
{
int n = e.getButton();
try
{
if (n == 1)
robot.mouseRelease(16);
else
if (n == 2)
robot.mouseRelease(8);
else
if (n == 3)
robot.mouseRelease(4);
}
catch (RemoteException e1)
{
e1.printStackTrace();
}
catch (Exception e2)
{
e2.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -