我只知道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);
}
}