From 499b548a148a651c9b285450dc44bb107dad123d Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 12 Oct 2014 18:56:37 +0200 Subject: [PATCH] * Some changes to chat handling to fix unintended empty line. --- .../main/java/mage/client/chat/ChatPanel.java | 10 +++-- .../mage/client/components/ColorPane.java | 39 +++++++++---------- 2 files changed, 24 insertions(+), 25 deletions(-) diff --git a/Mage.Client/src/main/java/mage/client/chat/ChatPanel.java b/Mage.Client/src/main/java/mage/client/chat/ChatPanel.java index d67c3f1a063..aaf2a916297 100644 --- a/Mage.Client/src/main/java/mage/client/chat/ChatPanel.java +++ b/Mage.Client/src/main/java/mage/client/chat/ChatPanel.java @@ -230,9 +230,10 @@ public class ChatPanel extends javax.swing.JPanel { if (username != null && !username.isEmpty()) { text.append(getColoredText(userColor, username + userSeparator)); } - text.append(getColoredText(textColor, ManaSymbols.replaceSymbolsWithHTML(message, ManaSymbols.Type.PAY) + "
")); - + text.append(getColoredText(textColor, ManaSymbols.replaceSymbolsWithHTML(message, ManaSymbols.Type.PAY))); this.txtConversation.append(text.toString()); + this.txtConversation.requestFocusInWindow(); + this.txtMessage.requestFocusInWindow(); } private String getColoredText(String color, String text) { @@ -279,8 +280,9 @@ public class ChatPanel extends javax.swing.JPanel { public void useExtendedView(VIEW_MODE extendedViewMode) { this.extendedViewMode = extendedViewMode; this.txtConversation.setExtBackgroundColor(new Color(0, 0, 0, 100)); - this.txtConversation.setBackground(new Color(0, 0, 0, 0)); - this.txtConversation.setForeground(new Color(255, 255, 255)); + // this.txtConversation.setBackground(new Color(0, 0, 0, 0)); + // this.txtConversation.setForeground(new Color(255, 255, 255)); + this.txtConversation.setSelectionColor(Color.LIGHT_GRAY); this.jScrollPaneTxt.setOpaque(false); this.jScrollPaneTxt.getViewport().setOpaque(false); } diff --git a/Mage.Client/src/main/java/mage/client/components/ColorPane.java b/Mage.Client/src/main/java/mage/client/components/ColorPane.java index 0c0ff506aa4..bb77d498e90 100644 --- a/Mage.Client/src/main/java/mage/client/components/ColorPane.java +++ b/Mage.Client/src/main/java/mage/client/components/ColorPane.java @@ -1,7 +1,16 @@ package mage.client.components; -import javax.swing.*; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Graphics; +import static javafx.scene.paint.Color.color; +import javax.swing.JEditorPane; +import javax.swing.JPanel; +import javax.swing.JTextPane; +import javax.swing.text.AttributeSet; +import javax.swing.text.SimpleAttributeSet; +import javax.swing.text.StyleConstants; +import javax.swing.text.StyleContext; import javax.swing.text.html.HTMLDocument; import javax.swing.text.html.HTMLEditorKit; @@ -10,14 +19,14 @@ import javax.swing.text.html.HTMLEditorKit; * * @author nantuko */ -public class ColorPane extends JTextPane { +public class ColorPane extends JEditorPane { HTMLEditorKit kit = new HTMLEditorKit(); - HTMLDocument doc = new HTMLDocument(); + HTMLDocument doc = new HTMLDocument(); public ColorPane() { this.setEditorKit(kit); - this.setDocument(doc); + this.setDocument(doc); } /** * This method solves the known issue with Nimbus LAF background transparency and background color. @@ -36,26 +45,14 @@ public class ColorPane extends JTextPane { super.setText(string); //To change body of generated methods, choose Tools | Templates. } - public void append(String s) { + public void append(String text) { try { setEditable(true); - kit.insertHTML(doc, doc.getLength(), s, 0, 0, null); + kit.insertHTML(doc, doc.getLength(), text, 0, 0, null); + setEditable(false); int len = getDocument().getLength(); setCaretPosition(len); - setEditable(false); - -// -// -// StyleContext sc = StyleContext.getDefaultStyleContext(); -// AttributeSet aset = sc.addAttribute(SimpleAttributeSet.EMPTY, StyleConstants.Foreground, color); -// -// int len = getDocument().getLength(); -// -// setCaretPosition(len); -// setCharacterAttributes(aset, false); -// replaceSelection(s); -// -// + } catch (Exception e) { e.printStackTrace(); }