예제 #1
0
 public void addDiceRoll(Player player, DiceType type, List<DiceFace> result) {
   try {
     StyleConstants.setForeground(userNameStyle, player.getColor().getColor());
     String line = player.getName() + " rolled " + result.size() + " " + type.getName() + " :\n";
     text.insertString(text.getEndPosition().getOffset(), line, userNameStyle);
     for (DiceFace face : result) {
       ImageIcon icon = new ImageIcon(face.getImage().getAbsolutePath());
       StyleConstants.setIcon(iconStyle, icon);
       text.insertString(text.getEndPosition().getOffset(), " ", iconStyle);
       text.insertString(text.getEndPosition().getOffset(), " ", textStyle);
     }
     text.insertString(text.getEndPosition().getOffset(), "\n", userNameStyle);
     // The pane auto-scrolls with each new response added
     textPane.setCaretPosition(text.getEndPosition().getOffset() - 1);
   } catch (BadLocationException e) {
     e.printStackTrace();
   }
 }
예제 #2
0
 public void addPlayerAction(Player player, String line) {
   try {
     StyleConstants.setForeground(actionStyle, player.getColor().getColor());
     text.insertString(text.getEndPosition().getOffset(), "* " + line + " *\n", actionStyle);
     // The pane auto-scrolls with each new response added
     textPane.setCaretPosition(text.getEndPosition().getOffset() - 1);
   } catch (BadLocationException e) {
     e.printStackTrace();
   }
 }
예제 #3
0
 public void addMessage(Player player, String line) {
   addMessage(player.getDisplayName(), player.getColor().getColor(), line);
 }