swing - Java RMI with JFrame - Get text from client to GUI -
hey started java, rmi , jframe 2 weeks ago. i'm doing game, works fine console i'm adding gui , i'm getting confused how remote client messages text area
remote client interface
public interface iremoteclientobject extends remote { public void notifylogin(string player) throws remoteexception; public void notifylogout(string player) throws remoteexception; public void notifystatus(string player, playerstatus status) throws remoteexception; public boolean challenge(string player) throws remoteexception; }
remote client
public class remoteclientobject extends unicastremoteobject implements iremoteclientobject { /** * */ private static final long serialversionuid = -7209335248515276286l; /** * @throws remoteexception */ public remoteclientobject() throws remoteexception { } @override public void notifylogin(string player) throws remoteexception { system.out.println("\n" + player + " joined game"); } @override public void notifylogout(string player) throws remoteexception { system.out.println("\n" + player + " left game"); } @override public void notifystatus(string player, playerstatus status) throws remoteexception { if (status.equals(playerstatus.playing)) { system.out.println("\n" + player + " playing"); } else if (status.equals(playerstatus.ready)) { system.out.println("\n" + player + " available play"); } else { system.out.println("\n" + player + " unavailable play"); } } }
in program without gui, example when player login (it sends message players notification)
for (player player : serverobject.getplayers()) { player.getclient().notifylogin(username); }
but don't want text in system.out, want in text area
so can make me description how this?code not important, want understand how works remote client gui (jtextarea)?
i'm not sure have already. if gui in picture built , have jtextarea object created, replace line system.out.println(...)
mytextarea.settext(...)
or mytextarea.append(...)
depending if want keep previous content or replace it.
Comments
Post a Comment