📄 fractionapplet.java
字号:
/////// FractionApplet.java ///////
package myrmi.fra;
import java.awt.Container;
import java.rmi.Naming;
import java.rmi.RemoteException;
import javax.swing.*;
public class FractionApplet extends JApplet
{ public void init()
{ try
{ obj = (FractionAdd)Naming.lookup("//" +
getCodeBase().getHost() + "/FractionServer");
a = new Fraction(1,3);
b = new Fraction(1,5);
ans = obj.add(a, b);
} catch (Exception e) {
System.out.println("FractionApplet exception: " +
e.getMessage());
e.printStackTrace();
}
Container cp = getContentPane();
cp.add(new JLabel("" +a+ " + " +b+ " = " + ans, JLabel.CENTER));
}
// "obj" is the identifier that we'll use to refer
// to the remote object that implements the "FractionAdd"
// interface
FractionAdd obj = null;
Fraction a, b, ans;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -