?? helloclientframe.java
字號:
package rmisocket;
import java.rmi.*;
import java.rmi.server.*;
import java.rmi.registry.*;
import java.net.*;
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class helloClientFrame extends JFrame{
private JPanel contentPane;
private Button button1 = new Button();
private Label label1 = new Label();
public helloClientFrame(){
enableEvents(AWTEvent.WINDOW_EVENT_MASK);
try{
jbInit();
}catch(Exception e){
e.printStackTrace();
}
}
private void jbInit() throws Exception{
contentPane = (JPanel)this.getContentPane();
button1.setLabel("Connect host");
button1.setBounds(new Rectangle(114,181,112,33));
button1.addActionListener(new java.awt.event.ActionListener(){
public void actionPerformed(ActionEvent e){
button1_actionPerformed(e);
}
});
contentPane.setLayout(null);
this.setSize(new Dimension(338,272));
this.setTitle("RMI SOCKET CLIENT");
label1.setBounds(new Rectangle(103,102,190,32));
contentPane.add(button1, null);
contentPane.add(label1, null);
RMISocketFactory.setSocketFactory(new RMISocketFoc());
}
protected void processWindowEvent(WindowEvent e){
super.processWindowEvent(e);
if(e.getID() == WindowEvent.WINDOW_CLOSING){
System.exit(0);
}
}
void button1_actionPerform(ActionEvent e){
String serverName = "";
System.setSecurityManager(new RMISeurityManager());
try{
label1.setText("Connecting...");
serverName = InetAddress.getLocalHost().getHostName();
Hello myHello = (Hello)Naming.lookup("//" + serverName + "/HelloWorld");
String d = myHello.sayHello();
lable1.setText(d);
}catch(Exception e1){
System.out.println("Error:" + e1);
}
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -