瀏覽代碼

Providing separate panels to visualize Armor, Shield, and general Items.
Shrinking by 20 to support scrollbar

Sam Jaffe 9 年之前
父節點
當前提交
3770856181

+ 46 - 8
src/org/leumasjaffe/charsheet/view/EquipmentTab.java

@@ -1,6 +1,5 @@
 package org.leumasjaffe.charsheet.view;
 
-import javax.swing.JLabel;
 import javax.swing.JPanel;
 
 import lombok.AccessLevel;
@@ -13,12 +12,25 @@ import java.awt.Insets;
 import org.jdesktop.swingx.VerticalLayout;
 import org.leumasjaffe.charsheet.entity.DDCharacter;
 import org.leumasjaffe.charsheet.view.inventory.ArmorPanel;
+import org.leumasjaffe.charsheet.view.inventory.ItemPanel;
+import org.leumasjaffe.charsheet.view.inventory.ShieldPanel;
 
 import java.awt.Color;
+import javax.swing.JLabel;
+import javax.swing.SwingConstants;
+import java.awt.Font;
+import javax.swing.border.MatteBorder;
+import java.awt.Dimension;
 
 @FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
 public class EquipmentTab extends JPanel {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+
 	public EquipmentTab() {
+		setPreferredSize(new Dimension(600, 300));
 		setOpaque(false);
 		GridBagLayout gridBagLayout = new GridBagLayout();
 		gridBagLayout.columnWidths = new int[]{0, 0, 0};
@@ -53,15 +65,41 @@ public class EquipmentTab extends JPanel {
 		inventory.setBackground(Color.WHITE);
 		scrollPane_1.setViewportView(inventory);
 		inventory.setLayout(new VerticalLayout(5));
+		
+		JLabel lblEquipment = new JLabel("Equipment");
+		lblEquipment.setBorder(new MatteBorder(0, 0, 1, 0, (Color) Color.WHITE));
+		lblEquipment.setFont(new Font("Tahoma", Font.BOLD, 20));
+		lblEquipment.setHorizontalAlignment(SwingConstants.CENTER);
+		lblEquipment.setBackground(Color.BLACK);
+		lblEquipment.setOpaque(true);
+		lblEquipment.setForeground(Color.WHITE);
+		scrollPane.setColumnHeaderView(lblEquipment);
+		
+		JLabel lblInventory = new JLabel("Inventory");
+		lblInventory.setBorder(new MatteBorder(0, 0, 1, 0, (Color) Color.WHITE));
+		lblInventory.setHorizontalAlignment(SwingConstants.CENTER);
+		lblInventory.setBackground(Color.BLACK);
+		lblInventory.setOpaque(true);
+		lblInventory.setForeground(Color.WHITE);
+		lblInventory.setFont(new Font("Tahoma", Font.BOLD, 20));
+		scrollPane_1.setColumnHeaderView(lblInventory);
+		
 		equipment.add(new ArmorPanel("Armor"));
-		equipment.add(new ArmorPanel("Shield"));
-		inventory.add(new ArmorPanel("<dummy>"));
-	}
+		equipment.add(new ShieldPanel("Shield"));
+		equipment.add(new ItemPanel("<dummy>"));
+		equipment.add(new ItemPanel("<dummy>"));
+		equipment.add(new ItemPanel("<dummy>"));
+		equipment.add(new ItemPanel("<dummy>"));
 
-	/**
-	 * 
-	 */
-	private static final long serialVersionUID = 1L;
+		inventory.add(new ItemPanel("<dummy>"));
+		inventory.add(new ItemPanel("<dummy>"));
+		inventory.add(new ItemPanel("<dummy>"));
+		inventory.add(new ItemPanel("<dummy>"));
+		inventory.add(new ItemPanel("<dummy>"));
+		inventory.add(new ItemPanel("<dummy>"));
+		inventory.add(new ItemPanel("<dummy>"));
+		inventory.add(new ItemPanel("<dummy>"));
+	}
 
 	public void setModel(DDCharacter model) {
 		// TODO Auto-generated method stub

+ 6 - 2
src/org/leumasjaffe/charsheet/view/inventory/ArmorPanel.java

@@ -14,6 +14,10 @@ import java.awt.Component;
 import javax.swing.Box;
 
 public class ArmorPanel extends JPanel {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
 	private JTextField armorNameField;
 	private JTextField armorTypeField;
 	private JTextField armorBonusField;
@@ -25,7 +29,7 @@ public class ArmorPanel extends JPanel {
 	private JTextField propField;
 
 	public ArmorPanel(String string) {
-		setPreferredSize(new Dimension(300, 75));
+		setPreferredSize(new Dimension(280, 70));
 		GridBagLayout gridBagLayout = new GridBagLayout();
 		gridBagLayout.columnWidths = new int[]{0, 0};
 		gridBagLayout.rowHeights = new int[]{0, 0, 0};
@@ -35,7 +39,7 @@ public class ArmorPanel extends JPanel {
 		
 		JPanel panel = new JPanel();
 		GridBagConstraints gbc_panel = new GridBagConstraints();
-		gbc_panel.insets = new Insets(0, 0, 5, 0);
+		gbc_panel.insets = new Insets(0, 0, 0, 0);
 		gbc_panel.fill = GridBagConstraints.BOTH;
 		gbc_panel.gridx = 0;
 		gbc_panel.gridy = 0;

+ 148 - 0
src/org/leumasjaffe/charsheet/view/inventory/ItemPanel.java

@@ -0,0 +1,148 @@
+package org.leumasjaffe.charsheet.view.inventory;
+
+import javax.swing.JPanel;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Color;
+import javax.swing.SwingConstants;
+import java.awt.Component;
+import javax.swing.Box;
+
+public class ItemPanel extends JPanel {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	private JTextField nameField;
+	private JTextField weightField;
+	private JTextField countField;
+	private JTextField valueField;
+
+	public ItemPanel(String string) {
+		setPreferredSize(new Dimension(280, 40));
+		GridBagLayout gridBagLayout = new GridBagLayout();
+		gridBagLayout.columnWidths = new int[]{0, 0};
+		gridBagLayout.rowHeights = new int[]{0, 0};
+		gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
+		gridBagLayout.rowWeights = new double[]{0.0, Double.MIN_VALUE};
+		setLayout(gridBagLayout);
+		
+		JPanel panel = new JPanel();
+		GridBagConstraints gbc_panel = new GridBagConstraints();
+		gbc_panel.fill = GridBagConstraints.BOTH;
+		gbc_panel.gridx = 0;
+		gbc_panel.gridy = 0;
+		add(panel, gbc_panel);
+		GridBagLayout gbl_panel = new GridBagLayout();
+		gbl_panel.columnWidths = new int[]{0, 0, 0, 0, 0};
+		gbl_panel.rowHeights = new int[]{0, 0, 0, 0};
+		gbl_panel.columnWeights = new double[]{1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE};
+		gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
+		panel.setLayout(gbl_panel);
+		
+		JLabel lblName = new JLabel("ITEM NAME");
+		lblName.setHorizontalAlignment(SwingConstants.CENTER);
+		lblName.setForeground(Color.WHITE);
+		lblName.setOpaque(true);
+		lblName.setBackground(Color.BLACK);
+		lblName.setFont(new Font("Tahoma", Font.BOLD, 10));
+		GridBagConstraints gbc_lblName = new GridBagConstraints();
+		gbc_lblName.fill = GridBagConstraints.BOTH;
+		gbc_lblName.insets = new Insets(0, 0, 0, 1);
+		gbc_lblName.gridheight = 2;
+		gbc_lblName.gridx = 0;
+		gbc_lblName.gridy = 0;
+		panel.add(lblName, gbc_lblName);
+		
+		Component verticalStrut = Box.createVerticalStrut(20);
+		verticalStrut.setMinimumSize(new Dimension(0, 10));
+		verticalStrut.setMaximumSize(new Dimension(32767, 10));
+		verticalStrut.setPreferredSize(new Dimension(0, 10));
+		GridBagConstraints gbc_verticalStrut = new GridBagConstraints();
+		gbc_verticalStrut.insets = new Insets(0, 0, 0, 1);
+		gbc_verticalStrut.gridx = 2;
+		gbc_verticalStrut.gridy = 0;
+		panel.add(verticalStrut, gbc_verticalStrut);
+		
+		JLabel lblCount = new JLabel("COUNT");
+		lblCount.setOpaque(true);
+		lblCount.setHorizontalAlignment(SwingConstants.CENTER);
+		lblCount.setForeground(Color.WHITE);
+		lblCount.setFont(new Font("Tahoma", Font.BOLD, 8));
+		lblCount.setBackground(Color.BLACK);
+		GridBagConstraints gbc_lblCount = new GridBagConstraints();
+		gbc_lblCount.fill = GridBagConstraints.HORIZONTAL;
+		gbc_lblCount.insets = new Insets(0, 0, 0, 1);
+		gbc_lblCount.gridx = 1;
+		gbc_lblCount.gridy = 1;
+		panel.add(lblCount, gbc_lblCount);
+		
+		JLabel lblWeight = new JLabel("WEIGHT");
+		lblWeight.setHorizontalAlignment(SwingConstants.CENTER);
+		lblWeight.setForeground(Color.WHITE);
+		lblWeight.setOpaque(true);
+		lblWeight.setBackground(Color.BLACK);
+		lblWeight.setFont(new Font("Tahoma", Font.BOLD, 8));
+		GridBagConstraints gbc_lblWeight = new GridBagConstraints();
+		gbc_lblWeight.fill = GridBagConstraints.HORIZONTAL;
+		gbc_lblWeight.insets = new Insets(0, 0, 0, 1);
+		gbc_lblWeight.gridx = 2;
+		gbc_lblWeight.gridy = 1;
+		panel.add(lblWeight, gbc_lblWeight);
+		
+		JLabel lblValue = new JLabel("VALUE");
+		lblValue.setOpaque(true);
+		lblValue.setHorizontalAlignment(SwingConstants.CENTER);
+		lblValue.setForeground(Color.WHITE);
+		lblValue.setFont(new Font("Tahoma", Font.BOLD, 8));
+		lblValue.setBackground(Color.BLACK);
+		GridBagConstraints gbc_lblValue = new GridBagConstraints();
+		gbc_lblValue.fill = GridBagConstraints.HORIZONTAL;
+		gbc_lblValue.insets = new Insets(0, 0, 0, 1);
+		gbc_lblValue.gridx = 3;
+		gbc_lblValue.gridy = 1;
+		panel.add(lblValue, gbc_lblValue);
+		
+		nameField = new JTextField();
+		GridBagConstraints gbc_nameField = new GridBagConstraints();
+		gbc_nameField.insets = new Insets(0, 0, 0, 0);
+		gbc_nameField.fill = GridBagConstraints.HORIZONTAL;
+		gbc_nameField.gridx = 0;
+		gbc_nameField.gridy = 2;
+		panel.add(nameField, gbc_nameField);
+		nameField.setColumns(10);
+		
+		countField = new JTextField();
+		GridBagConstraints gbc_countField = new GridBagConstraints();
+		gbc_countField.insets = new Insets(0, 0, 0, 0);
+		gbc_countField.fill = GridBagConstraints.HORIZONTAL;
+		gbc_countField.gridx = 1;
+		gbc_countField.gridy = 2;
+		panel.add(countField, gbc_countField);
+		countField.setColumns(10);
+		
+		weightField = new JTextField();
+		GridBagConstraints gbc_weightField = new GridBagConstraints();
+		gbc_weightField.insets = new Insets(0, 0, 0, 0);
+		gbc_weightField.fill = GridBagConstraints.HORIZONTAL;
+		gbc_weightField.gridx = 2;
+		gbc_weightField.gridy = 2;
+		panel.add(weightField, gbc_weightField);
+		weightField.setColumns(10);
+		
+		valueField = new JTextField();
+		GridBagConstraints gbc_valueField = new GridBagConstraints();
+		gbc_valueField.fill = GridBagConstraints.HORIZONTAL;
+		gbc_valueField.gridx = 3;
+		gbc_valueField.gridy = 2;
+		panel.add(valueField, gbc_valueField);
+		valueField.setColumns(10);
+		// TODO Auto-generated constructor stub
+	}
+
+}

+ 207 - 0
src/org/leumasjaffe/charsheet/view/inventory/ShieldPanel.java

@@ -0,0 +1,207 @@
+package org.leumasjaffe.charsheet.view.inventory;
+
+import javax.swing.JPanel;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+import javax.swing.JLabel;
+import javax.swing.JTextField;
+import java.awt.Dimension;
+import java.awt.Font;
+import java.awt.Color;
+import javax.swing.SwingConstants;
+import java.awt.Component;
+import javax.swing.Box;
+
+public class ShieldPanel extends JPanel {
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	private JTextField nameField;
+	private JTextField armorBonusField;
+	private JTextField weightField;
+	private JTextField checkField;
+	private JTextField spellField;
+	private JTextField propField;
+
+	public ShieldPanel(String string) {
+		setPreferredSize(new Dimension(280, 70));
+		GridBagLayout gridBagLayout = new GridBagLayout();
+		gridBagLayout.columnWidths = new int[]{0, 0};
+		gridBagLayout.rowHeights = new int[]{0, 0, 0};
+		gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
+		gridBagLayout.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
+		setLayout(gridBagLayout);
+		
+		JPanel panel = new JPanel();
+		GridBagConstraints gbc_panel = new GridBagConstraints();
+		gbc_panel.insets = new Insets(0, 0, 0, 0);
+		gbc_panel.fill = GridBagConstraints.BOTH;
+		gbc_panel.gridx = 0;
+		gbc_panel.gridy = 0;
+		add(panel, gbc_panel);
+		GridBagLayout gbl_panel = new GridBagLayout();
+		gbl_panel.columnWidths = new int[]{0, 0, 0, 0, 0};
+		gbl_panel.rowHeights = new int[]{0, 0, 0, 0};
+		gbl_panel.columnWeights = new double[]{1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE};
+		gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
+		panel.setLayout(gbl_panel);
+		
+		JLabel lblArmorprotectiveItem = new JLabel("SHIELD/PROTECTIVE ITEM");
+		lblArmorprotectiveItem.setHorizontalAlignment(SwingConstants.CENTER);
+		lblArmorprotectiveItem.setForeground(Color.WHITE);
+		lblArmorprotectiveItem.setOpaque(true);
+		lblArmorprotectiveItem.setBackground(Color.BLACK);
+		lblArmorprotectiveItem.setFont(new Font("Tahoma", Font.BOLD, 10));
+		GridBagConstraints gbc_lblArmorprotectiveItem = new GridBagConstraints();
+		gbc_lblArmorprotectiveItem.fill = GridBagConstraints.BOTH;
+		gbc_lblArmorprotectiveItem.insets = new Insets(0, 0, 0, 1);
+		gbc_lblArmorprotectiveItem.gridheight = 2;
+		gbc_lblArmorprotectiveItem.gridx = 0;
+		gbc_lblArmorprotectiveItem.gridy = 0;
+		panel.add(lblArmorprotectiveItem, gbc_lblArmorprotectiveItem);
+		
+		Component verticalStrut = Box.createVerticalStrut(20);
+		verticalStrut.setMinimumSize(new Dimension(0, 10));
+		verticalStrut.setMaximumSize(new Dimension(32767, 10));
+		verticalStrut.setPreferredSize(new Dimension(0, 10));
+		GridBagConstraints gbc_verticalStrut = new GridBagConstraints();
+		gbc_verticalStrut.insets = new Insets(0, 0, 0, 0);
+		gbc_verticalStrut.gridx = 2;
+		gbc_verticalStrut.gridy = 0;
+		panel.add(verticalStrut, gbc_verticalStrut);
+		
+		JLabel lblAcBonus = new JLabel("AC BONUS");
+		lblAcBonus.setHorizontalAlignment(SwingConstants.CENTER);
+		lblAcBonus.setForeground(Color.WHITE);
+		lblAcBonus.setOpaque(true);
+		lblAcBonus.setBackground(Color.BLACK);
+		lblAcBonus.setFont(new Font("Tahoma", Font.BOLD, 8));
+		GridBagConstraints gbc_lblAcBonus = new GridBagConstraints();
+		gbc_lblAcBonus.fill = GridBagConstraints.HORIZONTAL;
+		gbc_lblAcBonus.insets = new Insets(0, 0, 0, 1);
+		gbc_lblAcBonus.gridx = 1;
+		gbc_lblAcBonus.gridy = 1;
+		panel.add(lblAcBonus, gbc_lblAcBonus);
+		
+		JLabel lblWeight = new JLabel("WEIGHT");
+		lblWeight.setHorizontalAlignment(SwingConstants.CENTER);
+		lblWeight.setForeground(Color.WHITE);
+		lblWeight.setOpaque(true);
+		lblWeight.setBackground(Color.BLACK);
+		lblWeight.setFont(new Font("Tahoma", Font.BOLD, 8));
+		GridBagConstraints gbc_lblWeight = new GridBagConstraints();
+		gbc_lblWeight.fill = GridBagConstraints.HORIZONTAL;
+		gbc_lblWeight.insets = new Insets(0, 0, 0, 1);
+		gbc_lblWeight.gridx = 2;
+		gbc_lblWeight.gridy = 1;
+		panel.add(lblWeight, gbc_lblWeight);
+		
+		JLabel lblCheckPenalty = new JLabel("CHECK PENALTY");
+		GridBagConstraints gbc_lblCheckPenalty = new GridBagConstraints();
+		gbc_lblCheckPenalty.fill = GridBagConstraints.HORIZONTAL;
+		gbc_lblCheckPenalty.insets = new Insets(0, 0, 0, 1);
+		gbc_lblCheckPenalty.gridx = 3;
+		gbc_lblCheckPenalty.gridy = 1;
+		panel.add(lblCheckPenalty, gbc_lblCheckPenalty);
+		lblCheckPenalty.setHorizontalAlignment(SwingConstants.CENTER);
+		lblCheckPenalty.setForeground(Color.WHITE);
+		lblCheckPenalty.setOpaque(true);
+		lblCheckPenalty.setBackground(Color.BLACK);
+		lblCheckPenalty.setFont(new Font("Tahoma", Font.BOLD, 8));
+		
+		nameField = new JTextField();
+		GridBagConstraints gbc_nameField = new GridBagConstraints();
+		gbc_nameField.insets = new Insets(0, 0, 0, 0);
+		gbc_nameField.fill = GridBagConstraints.HORIZONTAL;
+		gbc_nameField.gridx = 0;
+		gbc_nameField.gridy = 2;
+		panel.add(nameField, gbc_nameField);
+		nameField.setColumns(10);
+		
+		armorBonusField = new JTextField();
+		GridBagConstraints gbc_armorBonusField = new GridBagConstraints();
+		gbc_armorBonusField.insets = new Insets(0, 0, 0, 0);
+		gbc_armorBonusField.fill = GridBagConstraints.HORIZONTAL;
+		gbc_armorBonusField.gridx = 1;
+		gbc_armorBonusField.gridy = 2;
+		panel.add(armorBonusField, gbc_armorBonusField);
+		armorBonusField.setColumns(10);
+		
+		weightField = new JTextField();
+		GridBagConstraints gbc_weightField = new GridBagConstraints();
+		gbc_weightField.insets = new Insets(0, 0, 0, 0);
+		gbc_weightField.fill = GridBagConstraints.HORIZONTAL;
+		gbc_weightField.gridx = 2;
+		gbc_weightField.gridy = 2;
+		panel.add(weightField, gbc_weightField);
+		weightField.setColumns(10);
+		
+		checkField = new JTextField();
+		GridBagConstraints gbc_checkField = new GridBagConstraints();
+		gbc_checkField.fill = GridBagConstraints.HORIZONTAL;
+		gbc_checkField.gridx = 3;
+		gbc_checkField.gridy = 2;
+		panel.add(checkField, gbc_checkField);
+		checkField.setColumns(10);
+		
+		JPanel panel_1 = new JPanel();
+		GridBagConstraints gbc_panel_1 = new GridBagConstraints();
+		gbc_panel_1.fill = GridBagConstraints.BOTH;
+		gbc_panel_1.gridx = 0;
+		gbc_panel_1.gridy = 1;
+		add(panel_1, gbc_panel_1);
+		GridBagLayout gbl_panel_1 = new GridBagLayout();
+		gbl_panel_1.columnWidths = new int[]{0, 0, 0};
+		gbl_panel_1.rowHeights = new int[]{0, 0, 0};
+		gbl_panel_1.columnWeights = new double[]{0.0, 1.0, Double.MIN_VALUE};
+		gbl_panel_1.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
+		panel_1.setLayout(gbl_panel_1);
+		
+		JLabel lblSpellFailure = new JLabel("SPELL FAILURE");
+		lblSpellFailure.setHorizontalAlignment(SwingConstants.CENTER);
+		lblSpellFailure.setForeground(Color.WHITE);
+		lblSpellFailure.setOpaque(true);
+		lblSpellFailure.setBackground(Color.BLACK);
+		lblSpellFailure.setFont(new Font("Tahoma", Font.BOLD, 8));
+		GridBagConstraints gbc_lblSpellFailure = new GridBagConstraints();
+		gbc_lblSpellFailure.fill = GridBagConstraints.BOTH;
+		gbc_lblSpellFailure.insets = new Insets(0, 0, 0, 1);
+		gbc_lblSpellFailure.gridx = 0;
+		gbc_lblSpellFailure.gridy = 0;
+		panel_1.add(lblSpellFailure, gbc_lblSpellFailure);
+		
+		JLabel lblSpecialProperties = new JLabel("SPECIAL PROPERTIES");
+		lblSpecialProperties.setHorizontalAlignment(SwingConstants.CENTER);
+		lblSpecialProperties.setForeground(Color.WHITE);
+		lblSpecialProperties.setOpaque(true);
+		lblSpecialProperties.setBackground(Color.BLACK);
+		lblSpecialProperties.setFont(new Font("Tahoma", Font.BOLD, 8));
+		GridBagConstraints gbc_lblSpecialProperties = new GridBagConstraints();
+		gbc_lblSpecialProperties.fill = GridBagConstraints.BOTH;
+		gbc_lblSpecialProperties.insets = new Insets(0, 0, 0, 1);
+		gbc_lblSpecialProperties.gridx = 1;
+		gbc_lblSpecialProperties.gridy = 0;
+		panel_1.add(lblSpecialProperties, gbc_lblSpecialProperties);
+		
+		spellField = new JTextField();
+		GridBagConstraints gbc_spellField = new GridBagConstraints();
+		gbc_spellField.insets = new Insets(0, 0, 0, 0);
+		gbc_spellField.fill = GridBagConstraints.HORIZONTAL;
+		gbc_spellField.gridx = 0;
+		gbc_spellField.gridy = 1;
+		panel_1.add(spellField, gbc_spellField);
+		spellField.setColumns(10);
+		
+		propField = new JTextField();
+		GridBagConstraints gbc_propField = new GridBagConstraints();
+		gbc_propField.fill = GridBagConstraints.HORIZONTAL;
+		gbc_propField.gridx = 1;
+		gbc_propField.gridy = 1;
+		panel_1.add(propField, gbc_propField);
+		propField.setColumns(10);
+		// TODO Auto-generated constructor stub
+	}
+
+}