im making a game server the login server is done, now im working on the character server.

My problem is on the client, I recieve all the values and then I want to create a character based on those values. Here is my jPanel code.

public class createChar extends JPanel {
   private final int ID;
   private String user;
   private int level;
   private int exp;
   private float r;
   private float gr;
   private float b;

public createChar(String username,int ID,int level,int exp,float r,float g,float b){
    this.ID = ID;
    this.user = username;
    this.level = level;
    this.exp = exp;
    this.r =(int) r;
    this.gr =(int) g;
    this.b =(int) b;
    setVisible(true);
}


@Override
public void paintComponent(Graphics g){
    super.paintComponent(g);
    Color clr = new Color(r,gr,b);
    g.setColor(clr);
    g.fillRect(50, 50, 100, 100);   
 super.repaint();

}

Here I add the jPanel:

                           while((fChara = cin.readLine()) != null){
                           System.out.println("[CHARAS]" + fChara);
                          if (fChara.contains("-")){

                       Scanner cs = new Scanner(fChara);
                        cs.useDelimiter(":");

                          String schar = cs.next();



                       System.out.println( "schar:" +schar);

                      //   cs.delimiter();
                    int id = cs.nextInt();
                    String cname = cs.next();
                       System.out.println("ID:" + id);
                    int level = cs.nextInt();
                    int exp = cs.nextInt();
                    int r = cs.nextInt();
                    int g = cs.nextInt();
                    int b = cs.nextInt();

                    System.out.println( id +":" + cname+":" + level+":" + exp+":" + r+":" +g+":" +b);
                          createChar chara = new createChar(cname,id,level,exp,r,g,b);  
                       jPanel1.add(chara);

                       }

Thanks!

没有正确的解决方案

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top