* Added scroll ability for system messages panel.

This commit is contained in:
LevelX2 2015-12-05 00:48:36 +01:00
parent dd50521887
commit f7b8ab626d
3 changed files with 110 additions and 35 deletions

View file

@ -17,18 +17,21 @@ import javax.swing.text.html.HTMLEditorKit;
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 method solves the known issue with Nimbus LAF background transparency and background color.
* This method solves the known issue with Nimbus LAF background
* transparency and background color.
*
* @param color
*/
public void setExtBackgroundColor(Color color) {
setBackground(new Color(0,0,0,0));
setBackground(new Color(0, 0, 0, 0));
JPanel jPanel = new JPanel();
jPanel.setBackground(color);
setLayout(new BorderLayout());
@ -73,4 +76,4 @@ public class ColorPane extends JEditorPane {
super.paintChildren(g);
}
}
}

View file

@ -1,6 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<Form version="1.8" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents>
<Component class="javax.swing.JSpinner" name="jSpinner1">
</Component>
</NonVisualComponents>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
@ -85,6 +89,9 @@
</SubComponents>
</Container>
<Container class="javax.swing.JTabbedPane" name="jTabbedPaneText">
<Properties>
<Property name="tabPlacement" type="int" value="3"/>
</Properties>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JSplitPaneSupportLayout$JSplitPaneConstraintsDescription">
<JSplitPaneConstraints position="right"/>
@ -92,6 +99,62 @@
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout"/>
<SubComponents>
<Component class="mage.client.chat.ChatPanelSeparated" name="jScrollPaneTalk">
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="Talk">
<Property name="tabTitle" type="java.lang.String" value="Talk"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
</Component>
<Container class="javax.swing.JScrollPane" name="jScrollPaneSystem">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="horizontalScrollBarPolicy" type="int" value="31"/>
<Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor">
<Color id="Standardcursor"/>
</Property>
<Property name="focusable" type="boolean" value="false"/>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
<AuxValues>
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
</AuxValues>
<Constraints>
<Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout" value="org.netbeans.modules.form.compat2.layouts.support.JTabbedPaneSupportLayout$JTabbedPaneConstraintsDescription">
<JTabbedPaneConstraints tabName="System">
<Property name="tabTitle" type="java.lang.String" value="System"/>
</JTabbedPaneConstraints>
</Constraint>
</Constraints>
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="mage.client.components.ColorPane" name="colorPaneSystem">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" red="0" type="rgb"/>
</Property>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="null"/>
</Property>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Arial" size="14" style="0"/>
</Property>
<Property name="margin" type="java.awt.Insets" editor="org.netbeans.beaninfo.editors.InsetsEditor">
<Insets value="[0, 0, 0, 0]"/>
</Property>
<Property name="opaque" type="boolean" value="false"/>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents>
</Container>
</SubComponents>
</Container>

View file

@ -38,13 +38,12 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.swing.Icon;
import javax.swing.border.EmptyBorder;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableColumnModel;
import mage.client.chat.ChatPanelBasic;
import static mage.client.chat.ChatPanelBasic.CHAT_ALPHA;
import mage.client.chat.ChatPanelSeparated;
import mage.client.components.ColorPane;
import static mage.client.dialog.PreferencesDialog.KEY_USERS_COLUMNS_ORDER;
import static mage.client.dialog.PreferencesDialog.KEY_USERS_COLUMNS_WIDTH;
import mage.client.util.MageTableRowSorter;
@ -62,8 +61,6 @@ public class PlayersChatPanel extends javax.swing.JPanel {
private final List<String> players = new ArrayList<>();
private final UserTableModel userTableModel;
private final ChatPanelSeparated userChatPanel;
private final ColorPane systemMessagesPane;
private static final int[] defaultColumnsWidth = {20, 100, 100, 80, 80};
@ -84,43 +81,26 @@ public class PlayersChatPanel extends javax.swing.JPanel {
TableUtil.setColumnWidthAndOrder(jTablePlayers, defaultColumnsWidth, KEY_USERS_COLUMNS_WIDTH, KEY_USERS_COLUMNS_ORDER);
jTablePlayers.setDefaultRenderer(Icon.class, new CountryCellRenderer());
systemMessagesPane = new ColorPane();
jScrollPaneTalk.setSystemMessagesPane(colorPaneSystem);
jScrollPaneTalk.setOpaque(false);
userChatPanel = new ChatPanelSeparated();
userChatPanel.setSystemMessagesPane(systemMessagesPane);
if (jTabbedPaneText != null) {
jTabbedPaneText.setBackground(new Color(0, 0, 0, CHAT_ALPHA));
if (userChatPanel != null) {
userChatPanel.setBackground(new Color(0, 0, 0, CHAT_ALPHA));
jTabbedPaneText.addTab("Talk", userChatPanel);
}
if (systemMessagesPane != null) {
systemMessagesPane.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1));
systemMessagesPane.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
systemMessagesPane.setFocusCycleRoot(false);
systemMessagesPane.setMargin(new java.awt.Insets(2, 2, 2, 2));
systemMessagesPane.setOpaque(false);
systemMessagesPane.setExtBackgroundColor(new Color(0, 0, 0, CHAT_ALPHA)); // Alpha = 255 not transparent
systemMessagesPane.setSelectionColor(Color.LIGHT_GRAY);
jTabbedPaneText.addTab("System", systemMessagesPane);
}
}
jScrollPaneSystem.getViewport().setOpaque(false);
colorPaneSystem.setExtBackgroundColor(new Color(0, 0, 0, CHAT_ALPHA)); // Alpha = 255 not transparent
colorPaneSystem.setBorder(new EmptyBorder(5, 5, 5, 5));
if (jScrollPanePlayers != null) {
jScrollPanePlayers.setBackground(new Color(0, 0, 0, CHAT_ALPHA));
jScrollPanePlayers.getViewport().setBackground(new Color(0, 0, 0, CHAT_ALPHA));
}
}
public ChatPanelBasic getUserChatPanel() {
return userChatPanel;
return jScrollPaneTalk;
}
public void cleanUp() {
TableUtil.saveColumnWidthAndOrderToPrefs(jTablePlayers, KEY_USERS_COLUMNS_WIDTH, KEY_USERS_COLUMNS_ORDER);
userChatPanel.cleanUp();
jScrollPaneTalk.cleanUp();
}
public void setSplitDividerLocation(int location) {
@ -219,11 +199,16 @@ public class PlayersChatPanel extends javax.swing.JPanel {
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
jSpinner1 = new javax.swing.JSpinner();
jSplitPane1 = new javax.swing.JSplitPane();
jScrollPanePlayers = new javax.swing.JScrollPane();
jTablePlayers = new javax.swing.JTable();
jTabbedPaneText = new javax.swing.JTabbedPane();
jScrollPaneTalk = new mage.client.chat.ChatPanelSeparated();
jScrollPaneSystem = new javax.swing.JScrollPane();
colorPaneSystem = new mage.client.components.ColorPane();
jSplitPane1.setBorder(null);
jSplitPane1.setDividerSize(10);
@ -246,6 +231,26 @@ public class PlayersChatPanel extends javax.swing.JPanel {
jScrollPanePlayers.setViewportView(jTablePlayers);
jSplitPane1.setTopComponent(jScrollPanePlayers);
jTabbedPaneText.setTabPlacement(javax.swing.JTabbedPane.BOTTOM);
jTabbedPaneText.addTab("Talk", jScrollPaneTalk);
jScrollPaneSystem.setBorder(null);
jScrollPaneSystem.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
jScrollPaneSystem.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
jScrollPaneSystem.setFocusable(false);
jScrollPaneSystem.setOpaque(false);
colorPaneSystem.setEditable(false);
colorPaneSystem.setBackground(new java.awt.Color(0, 0, 0));
colorPaneSystem.setBorder(null);
colorPaneSystem.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
colorPaneSystem.setMargin(new java.awt.Insets(0, 0, 0, 0));
colorPaneSystem.setOpaque(false);
jScrollPaneSystem.setViewportView(colorPaneSystem);
jTabbedPaneText.addTab("System", jScrollPaneSystem);
jSplitPane1.setRightComponent(jTabbedPaneText);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
@ -270,7 +275,11 @@ public class PlayersChatPanel extends javax.swing.JPanel {
}
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private mage.client.components.ColorPane colorPaneSystem;
private javax.swing.JScrollPane jScrollPanePlayers;
private javax.swing.JScrollPane jScrollPaneSystem;
private mage.client.chat.ChatPanelSeparated jScrollPaneTalk;
private javax.swing.JSpinner jSpinner1;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JTabbedPane jTabbedPaneText;
private javax.swing.JTable jTablePlayers;