私はJavaの基本的なことしか知りません。そして、このタイプのプログラム用の GUI を作成する必要があります。クレジットカード情報が表示されます。他のいくつかのクラスがあり、rmiregistry を利用します。これはコンソールでは問題なく動作しますが、GUI で表示する必要があります。ここで最初に表示されるのは、自分の名前 (java Shopper localhost my name ) を入力することです。次に、クレジットカード情報が表示されます。誰でも私を助けることができますか?よろしくお願いします
import java.rmi.*;
import javax.swing.*;
public class Shopper {
public static void main(String args[])
{
CreditManager cm = null;
CreditCard account = null;
if(args.length<2)
{
System.err.println("Usage:");
System.err.println("java Shopper <server> <accountname>");
System.exit(1);
}
try
{
String url = new String("//"+args[0]+"/cardManager");
System.out.println("Shopper: lookup cardManager, url="+url);
cm = (CreditManager) Naming.lookup(url);
}catch(Exception e)
{
System.out.println("Error in getting Card Manager "+e);
System.exit(1);
}
try
{
account = cm.findCreditAccount(args[1]);
System.out.println("Found account for "+args[1]);
}catch(Exception e)
{
System.out.println("Error in getting acocunt for "+args[1]);
System.exit(1);
}
try
{
System.out.println("Available credit is "+account.getCreditLine());
System.out.println("Changing pin number for account");
account.setSignature(1234);
System.out.println("Buying a new watch for $100");
account.makePurchase(100.0f, 1234);
System.out.println("Available credit is now "+account.getCreditLine());
System.out.println("Buying a new pair of shoes for $160");
account.makePurchase(160.0f, 1234);
System.out.println("Cardholder: Paying off $136 of balance");
account.payTowardsBalance(136.0f);
System.out.println("Available credit is now "+account.getCreditLine());
}catch(Exception e)
{
System.out.println("Transaction error for "+args[1]);
}
System.exit(0);
}
}