Просмотр исходного кода

Add current liquid wealth to Inventory.
Add purchase/sale dialog.

Sam Jaffe 8 лет назад
Родитель
Сommit
f94c7c25a5

+ 3 - 0
resources/Potato.json

@@ -152,6 +152,9 @@
       "OFF_HAND": "MWK Quarterstaff"
     },
     "favorites": {
+    },
+    "wealth": {
+      "pp": 0, "gp": 0, "sp": 0, "cp": 0
     }
   }
 }

+ 4 - 1
src/main/lombok/org/leumasjaffe/charsheet/model/inventory/DDInventory.java

@@ -22,12 +22,14 @@ public class DDInventory extends Observable {
 		@NonNull List<DDItem> items;
 		@NonNull Map<EquipmentSlot, String> equipment;
 		@NonNull Map<String, Map<EquipmentSlot, String>> favorites;
+		@NonNull Money wealth;
 	}
 	
 	// Serializable properties
 	@NonNull List<DDItem> items = new ArrayList<>();
 	@NonNull Map<EquipmentSlot, DDItem> equipment = new EnumMap<>(EquipmentSlot.class);
 	@NonNull Map<String, Map<EquipmentSlot, String>> favorites = new TreeMap<>();
+	@NonNull Money wealth = new Money(0, 0, 0, 0);
 	// Transient/Record-Keeping properties
 	@NonNull Map<String, DDItem> named = new HashMap<>();
 	@NonFinal Map<EquipmentSlot, String> previous = null;
@@ -40,11 +42,12 @@ public class DDInventory extends Observable {
 		named.putAll(items.stream().collect(Collectors.toMap(DDItem::getName, i -> i)));
 		fromSerializableEquipment(data.equipment);
 		favorites.putAll(data.favorites);
+		wealth.assign(data.wealth);
 	}
 
 	@JsonValue
 	private DDInventory.Serializable getSerial() {
-		return new DDInventory.Serializable(items, getSerializableEquipment(), favorites);
+		return new DDInventory.Serializable(items, getSerializableEquipment(), favorites, wealth);
 	}
 
 	public void load(final String name) {

+ 11 - 3
src/main/lombok/org/leumasjaffe/charsheet/model/inventory/Money.java

@@ -11,12 +11,20 @@ import lombok.experimental.FieldDefaults;
 public class Money implements Comparable<Money> {
 	int pp, gp, sp, cp;
 	
-	Money sum( final Money other ) {
+	public Money assign(final Money other) {
+		setPp(other.getPp());
+		setGp(other.getGp());
+		setSp(other.getSp());
+		setCp(other.getCp());
+		return this;
+	}
+	
+	public Money sum( final Money other ) {
 		return new Money(pp + other.pp, gp + other.gp, sp + other.sp, cp + other.cp);
 	}
 	
-	Money subtract( final Money other ) {
-		final Money tmp = new Money(pp + other.pp, gp + other.gp, sp + other.sp, cp + other.cp);
+	public Money difference( final Money other ) {
+		final Money tmp = new Money(pp - other.pp, gp - other.gp, sp - other.sp, cp - other.cp);
 		tmp.rebalance( );
 		return tmp;
 	}

+ 192 - 0
src/main/lombok/org/leumasjaffe/charsheet/view/dialog/BuySellItemDialog.java

@@ -0,0 +1,192 @@
+package org.leumasjaffe.charsheet.view.dialog;
+
+import javax.swing.JPanel;
+import javax.swing.JSpinner;
+import javax.swing.SpinnerNumberModel;
+
+import org.leumasjaffe.charsheet.model.inventory.DDItem;
+import org.leumasjaffe.charsheet.model.inventory.Money;
+import org.leumasjaffe.format.StringHelper;
+
+import lombok.AccessLevel;
+import lombok.experimental.FieldDefaults;
+import java.awt.GridBagLayout;
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+
+import javax.swing.Box;
+import javax.swing.JLabel;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.Font;
+import javax.swing.SwingConstants;
+import javax.swing.JTextField;
+
+@FieldDefaults(level=AccessLevel.PRIVATE, makeFinal=true)
+public class BuySellItemDialog extends JPanel {
+
+	/**
+	 * 
+	 */
+	private static final long serialVersionUID = 1L;
+	
+	JSpinner spinner;
+
+	public BuySellItemDialog(final DDItem item, int cap) {
+		final int rawValue = item.getValue().asCopper();
+		spinner = new JSpinner(new SpinnerNumberModel(1, 1, cap, 1));
+
+		GridBagLayout gridBagLayout = new GridBagLayout();
+		gridBagLayout.columnWidths = new int[]{120, 0, 0, 0, 0, 0};
+		gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0};
+		gridBagLayout.columnWeights = new double[]{1.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
+		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
+		setLayout(gridBagLayout);
+
+		JLabel lblName = new JLabel("ITEM NAME");
+		lblName.setOpaque(true);
+		lblName.setHorizontalAlignment(SwingConstants.CENTER);
+		lblName.setForeground(Color.WHITE);
+		lblName.setFont(new Font("Tahoma", Font.BOLD, 8));
+		lblName.setBackground(Color.BLACK);
+		GridBagConstraints gbc_lblName = new GridBagConstraints();
+		gbc_lblName.gridheight = 2;
+		gbc_lblName.fill = GridBagConstraints.BOTH;
+		gbc_lblName.insets = new Insets(0, 0, 0, 1);
+		gbc_lblName.gridx = 0;
+		gbc_lblName.gridy = 0;
+		add(lblName, gbc_lblName);
+
+		JTextField txtName = new JTextField(item.getName());
+		txtName.setEditable(false);
+		GridBagConstraints gbc_txtName = new GridBagConstraints();
+		gbc_txtName.insets = new Insets(0, 0, 0, 0);
+		gbc_txtName.fill = GridBagConstraints.HORIZONTAL;
+		gbc_txtName.gridx = 0;
+		gbc_txtName.gridy = 2;
+		add(txtName, gbc_txtName);
+
+		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.fill = GridBagConstraints.HORIZONTAL;
+		gbc_verticalStrut.gridx = 1;
+		gbc_verticalStrut.gridy = 0;
+		add(verticalStrut, gbc_verticalStrut);
+		
+		JLabel lblPp = new JLabel("pp");
+		lblPp.setOpaque(true);
+		lblPp.setHorizontalAlignment(SwingConstants.CENTER);
+		lblPp.setForeground(Color.WHITE);
+		lblPp.setFont(new Font("Tahoma", Font.BOLD, 8));
+		lblPp.setBackground(Color.BLACK);
+		GridBagConstraints gbc_lblPp = new GridBagConstraints();
+		gbc_lblPp.fill = GridBagConstraints.HORIZONTAL;
+		gbc_lblPp.insets = new Insets(0, 0, 0, 1);
+		gbc_lblPp.gridx = 1;
+		gbc_lblPp.gridy = 1;
+		add(lblPp, gbc_lblPp);
+		
+		JLabel lblGp = new JLabel("gp");
+		lblGp.setOpaque(true);
+		lblGp.setHorizontalAlignment(SwingConstants.CENTER);
+		lblGp.setForeground(Color.WHITE);
+		lblGp.setFont(new Font("Tahoma", Font.BOLD, 8));
+		lblGp.setBackground(Color.BLACK);
+		GridBagConstraints gbc_lblGp = new GridBagConstraints();
+		gbc_lblGp.fill = GridBagConstraints.HORIZONTAL;
+		gbc_lblGp.insets = new Insets(0, 0, 0, 1);
+		gbc_lblGp.gridx = 2;
+		gbc_lblGp.gridy = 1;
+		add(lblGp, gbc_lblGp);
+		
+		JLabel lblSp = new JLabel("sp");
+		lblSp.setOpaque(true);
+		lblSp.setHorizontalAlignment(SwingConstants.CENTER);
+		lblSp.setForeground(Color.WHITE);
+		lblSp.setFont(new Font("Tahoma", Font.BOLD, 8));
+		lblSp.setBackground(Color.BLACK);
+		GridBagConstraints gbc_lblSp = new GridBagConstraints();
+		gbc_lblSp.fill = GridBagConstraints.HORIZONTAL;
+		gbc_lblSp.insets = new Insets(0, 0, 0, 1);
+		gbc_lblSp.gridx = 3;
+		gbc_lblSp.gridy = 1;
+		add(lblSp, gbc_lblSp);
+		
+		JLabel lblCp = new JLabel("cp");
+		lblCp.setOpaque(true);
+		lblCp.setHorizontalAlignment(SwingConstants.CENTER);
+		lblCp.setForeground(Color.WHITE);
+		lblCp.setFont(new Font("Tahoma", Font.BOLD, 8));
+		lblCp.setBackground(Color.BLACK);
+		GridBagConstraints gbc_lblCp = new GridBagConstraints();
+		gbc_lblCp.fill = GridBagConstraints.HORIZONTAL;
+		gbc_lblCp.insets = new Insets(0, 0, 0, 1);
+		gbc_lblCp.gridx = 4;
+		gbc_lblCp.gridy = 1;
+		add(lblCp, gbc_lblCp);
+		
+		JTextField txtPp = new JTextField(StringHelper.toString(item.getValue().getPp()));
+		txtPp.setEditable(false);
+		txtPp.setColumns(6);
+		GridBagConstraints gbc_txtPp = new GridBagConstraints();
+		gbc_txtPp.insets = new Insets(0, 0, 0, 0);
+		gbc_txtPp.fill = GridBagConstraints.HORIZONTAL;
+		gbc_txtPp.gridx = 1;
+		gbc_txtPp.gridy = 2;
+		add(txtPp, gbc_txtPp);
+		
+		JTextField txtGp = new JTextField(StringHelper.toString(item.getValue().getGp()));
+		txtGp.setEditable(false);
+		txtGp.setColumns(3);
+		GridBagConstraints gbc_txtGp = new GridBagConstraints();
+		gbc_txtGp.insets = new Insets(0, 0, 0, 0);
+		gbc_txtGp.fill = GridBagConstraints.HORIZONTAL;
+		gbc_txtGp.gridx = 2;
+		gbc_txtGp.gridy = 2;
+		add(txtGp, gbc_txtGp);
+		
+		JTextField txtSp = new JTextField(StringHelper.toString(item.getValue().getSp()));
+		txtSp.setEditable(false);
+		txtSp.setColumns(3);
+		GridBagConstraints gbc_txtSp = new GridBagConstraints();
+		gbc_txtSp.insets = new Insets(0, 0, 0, 0);
+		gbc_txtSp.fill = GridBagConstraints.HORIZONTAL;
+		gbc_txtSp.gridx = 3;
+		gbc_txtSp.gridy = 2;
+		add(txtSp, gbc_txtSp);
+		
+		JTextField txtCp = new JTextField(StringHelper.toString(item.getValue().getCp()));
+		txtCp.setEditable(false);
+		txtCp.setColumns(3);
+		GridBagConstraints gbc_txtCp = new GridBagConstraints();
+		gbc_txtCp.insets = new Insets(0, 0, 0, 0);
+		gbc_txtCp.fill = GridBagConstraints.HORIZONTAL;
+		gbc_txtCp.gridx = 4;
+		gbc_txtCp.gridy = 2;
+		add(txtCp, gbc_txtCp);
+		
+		GridBagConstraints gbc_spinner = new GridBagConstraints();
+		gbc_spinner.fill = GridBagConstraints.HORIZONTAL;
+		gbc_spinner.insets = new Insets(0, 0, 0, 0);
+		gbc_spinner.gridwidth = 5;
+		gbc_spinner.gridx = 0;
+		gbc_spinner.gridy = 3;
+		add(spinner, gbc_spinner);
+		spinner.addChangeListener(e -> {
+			final Money value = Money.fromCopper(rawValue * getSelectedNumber());
+			txtPp.setText(StringHelper.toString(value.getPp()));
+			txtGp.setText(StringHelper.toString(value.getGp()));
+			txtSp.setText(StringHelper.toString(value.getSp()));
+			txtCp.setText(StringHelper.toString(value.getCp()));
+		});
+	}
+	
+	public int getSelectedNumber() {
+		return (Integer) spinner.getModel().getValue();
+	}
+}

+ 28 - 0
src/main/lombok/org/leumasjaffe/charsheet/view/inventory/ItemInfoMenu.java

@@ -6,9 +6,12 @@ import org.leumasjaffe.charsheet.controller.EquipItemController;
 import org.leumasjaffe.charsheet.model.inventory.DDInventory;
 import org.leumasjaffe.charsheet.model.inventory.DDItem;
 import org.leumasjaffe.charsheet.model.inventory.EquipmentSlot;
+import org.leumasjaffe.charsheet.model.inventory.Money;
+import org.leumasjaffe.charsheet.view.dialog.BuySellItemDialog;
 
 import javax.swing.JFrame;
 import javax.swing.JMenuItem;
+import javax.swing.JOptionPane;
 
 class ItemInfoMenu extends JPopupMenu {
 	/**
@@ -17,6 +20,7 @@ class ItemInfoMenu extends JPopupMenu {
 	private static final long serialVersionUID = 1L;
 
 	public ItemInfoMenu(final DDInventory inv, final DDItem item) {
+		final int rawWealth = inv.getWealth().asCopper();
 		
 		JMenuItem mntmInfo = new JMenuItem("Info");
 		mntmInfo.addActionListener(e -> {
@@ -28,9 +32,33 @@ class ItemInfoMenu extends JPopupMenu {
 		add(mntmInfo);
 
 		JMenuItem mntmBuy = new JMenuItem("Purchase");
+		mntmBuy.addActionListener(e -> {
+			final BuySellItemDialog dialog = new BuySellItemDialog(item, rawWealth / item.getValue().asCopper());
+			if (JOptionPane.showConfirmDialog(null, dialog, "Purchase How Many " + item.getName() + "?", 
+					JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
+				final int selected = dialog.getSelectedNumber();
+				item.getCount().value(item.getCount().value() + selected);
+				final Money wealth = inv.getWealth();
+				wealth.assign(wealth.difference(Money.fromCopper(selected * item.getValue().asCopper())));
+				// TODO: update model
+			}
+		});
+		mntmBuy.setEnabled(rawWealth >= item.getValue().asCopper());
 		add(mntmBuy);
 
 		JMenuItem mntmSell = new JMenuItem("Sell");	
+		mntmSell.addActionListener(e -> {
+			// TODO: Adjust display to show sale value of 1/2
+			final BuySellItemDialog dialog = new BuySellItemDialog(item, item.getCount().value());
+			if (JOptionPane.showConfirmDialog(null, dialog, "Sell How Many " + item.getName() + "?", 
+					JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
+				final int selected = dialog.getSelectedNumber();
+				item.getCount().value(item.getCount().value() - selected);
+				final Money wealth = inv.getWealth();
+				wealth.assign(wealth.sum(Money.fromCopper(selected * item.getValue().asCopper() / 2)));
+				// TODO: remove item if count is 0
+			}
+		});
 		mntmSell.setEnabled(item.getUnequippedCount() > 0);
 		add(mntmSell);
 

+ 92 - 94
src/main/lombok/org/leumasjaffe/charsheet/view/inventory/ItemInfoPanel.java

@@ -41,9 +41,9 @@ class ItemInfoPanel extends JPanel {
 		gbc_panel.gridy = 0;
 		add(panel, gbc_panel);
 		GridBagLayout gbl_panel = new GridBagLayout();
-		gbl_panel.columnWidths = new int[]{120, 0, 0, 0, 0, 0, 0, 0, 0};
+		gbl_panel.columnWidths = new int[]{120, 0, 0, 0};
 		gbl_panel.rowHeights = new int[]{0, 0, 0, 0};
-		gbl_panel.columnWeights = new double[]{1.0, 1.0, 1.0, 0.0, 1.0, 1.0, 1.0, 1.0, Double.MIN_VALUE};
+		gbl_panel.columnWeights = new double[]{1.0, 0.0, 0.0, Double.MIN_VALUE};
 		gbl_panel.rowWeights = new double[]{0.0, 0.0, 0.0, Double.MIN_VALUE};
 		panel.setLayout(gbl_panel);
 		
@@ -93,68 +93,16 @@ class ItemInfoPanel extends JPanel {
 		lblPage.setBackground(Color.BLACK);
 		GridBagConstraints gbc_lblPage = new GridBagConstraints();
 		gbc_lblPage.fill = GridBagConstraints.HORIZONTAL;
-		gbc_lblPage.insets = new Insets(0, 0, 0, 1);
+		gbc_lblPage.insets = new Insets(0, 0, 1, 0);
 		gbc_lblPage.gridx = 2;
 		gbc_lblPage.gridy = 1;
 		panel.add(lblPage, gbc_lblPage);
 		
-		JLabel lblPp = new JLabel("pp");
-		lblPp.setOpaque(true);
-		lblPp.setHorizontalAlignment(SwingConstants.CENTER);
-		lblPp.setForeground(Color.WHITE);
-		lblPp.setFont(new Font("Tahoma", Font.BOLD, 8));
-		lblPp.setBackground(Color.BLACK);
-		GridBagConstraints gbc_lblPp = new GridBagConstraints();
-		gbc_lblPp.fill = GridBagConstraints.HORIZONTAL;
-		gbc_lblPp.insets = new Insets(0, 0, 0, 1);
-		gbc_lblPp.gridx = 4;
-		gbc_lblPp.gridy = 1;
-		panel.add(lblPp, gbc_lblPp);
-		
-		JLabel lblGp = new JLabel("gp");
-		lblGp.setOpaque(true);
-		lblGp.setHorizontalAlignment(SwingConstants.CENTER);
-		lblGp.setForeground(Color.WHITE);
-		lblGp.setFont(new Font("Tahoma", Font.BOLD, 8));
-		lblGp.setBackground(Color.BLACK);
-		GridBagConstraints gbc_lblGp = new GridBagConstraints();
-		gbc_lblGp.fill = GridBagConstraints.HORIZONTAL;
-		gbc_lblGp.insets = new Insets(0, 0, 0, 1);
-		gbc_lblGp.gridx = 5;
-		gbc_lblGp.gridy = 1;
-		panel.add(lblGp, gbc_lblGp);
-		
-		JLabel lblSp = new JLabel("sp");
-		lblSp.setOpaque(true);
-		lblSp.setHorizontalAlignment(SwingConstants.CENTER);
-		lblSp.setForeground(Color.WHITE);
-		lblSp.setFont(new Font("Tahoma", Font.BOLD, 8));
-		lblSp.setBackground(Color.BLACK);
-		GridBagConstraints gbc_lblSp = new GridBagConstraints();
-		gbc_lblSp.fill = GridBagConstraints.HORIZONTAL;
-		gbc_lblSp.insets = new Insets(0, 0, 0, 1);
-		gbc_lblSp.gridx = 6;
-		gbc_lblSp.gridy = 1;
-		panel.add(lblSp, gbc_lblSp);
-		
-		JLabel lblCp = new JLabel("cp");
-		lblCp.setOpaque(true);
-		lblCp.setHorizontalAlignment(SwingConstants.CENTER);
-		lblCp.setForeground(Color.WHITE);
-		lblCp.setFont(new Font("Tahoma", Font.BOLD, 8));
-		lblCp.setBackground(Color.BLACK);
-		GridBagConstraints gbc_lblCp = new GridBagConstraints();
-		gbc_lblCp.insets = new Insets(0, 0, 0, 0);
-		gbc_lblCp.fill = GridBagConstraints.HORIZONTAL;
-		gbc_lblCp.gridx = 7;
-		gbc_lblCp.gridy = 1;
-		panel.add(lblCp, gbc_lblCp);
-		
 		JTextField txtName = new JTextField(item.getName());
 		txtName.setEditable(false);
 		txtName.setColumns(10);
 		GridBagConstraints gbc_txtName = new GridBagConstraints();
-		gbc_txtName.insets = new Insets(0, 0, 0, 1);
+		gbc_txtName.insets = new Insets(0, 0, 0, 0);
 		gbc_txtName.fill = GridBagConstraints.HORIZONTAL;
 		gbc_txtName.gridx = 0;
 		gbc_txtName.gridy = 2;
@@ -164,7 +112,7 @@ class ItemInfoPanel extends JPanel {
 		txtWeight.setEditable(false);
 		txtWeight.setColumns(10);
 		GridBagConstraints gbc_txtWeight = new GridBagConstraints();
-		gbc_txtWeight.insets = new Insets(0, 0, 0, 1);
+		gbc_txtWeight.insets = new Insets(0, 0, 0, 0);
 		gbc_txtWeight.fill = GridBagConstraints.HORIZONTAL;
 		gbc_txtWeight.gridx = 1;
 		gbc_txtWeight.gridy = 2;
@@ -174,63 +122,113 @@ class ItemInfoPanel extends JPanel {
 		txtPage.setEditable(false);
 		txtPage.setColumns(10);
 		GridBagConstraints gbc_txtPage = new GridBagConstraints();
-		gbc_txtPage.insets = new Insets(0, 0, 0, 1);
 		gbc_txtPage.fill = GridBagConstraints.HORIZONTAL;
 		gbc_txtPage.gridx = 2;
 		gbc_txtPage.gridy = 2;
 		panel.add(txtPage, gbc_txtPage);
 		
-		Component horizontalStrut = Box.createHorizontalStrut(20);
-		GridBagConstraints gbc_horizontalStrut = new GridBagConstraints();
-		gbc_horizontalStrut.insets = new Insets(0, 0, 0, 1);
-		gbc_horizontalStrut.gridx = 3;
-		gbc_horizontalStrut.gridy = 2;
-		panel.add(horizontalStrut, gbc_horizontalStrut);
+		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, 0, 0};
+		gbl_panel_1.rowHeights = new int[]{0, 0, 0};
+		gbl_panel_1.columnWeights = new double[]{1.0, 1.0, 1.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 lblPp = new JLabel("pp");
+		GridBagConstraints gbc_lblPp = new GridBagConstraints();
+		gbc_lblPp.fill = GridBagConstraints.HORIZONTAL;
+		gbc_lblPp.insets = new Insets(0, 0, 0, 1);
+		gbc_lblPp.gridx = 0;
+		gbc_lblPp.gridy = 0;
+		panel_1.add(lblPp, gbc_lblPp);
+		lblPp.setOpaque(true);
+		lblPp.setHorizontalAlignment(SwingConstants.CENTER);
+		lblPp.setForeground(Color.WHITE);
+		lblPp.setFont(new Font("Tahoma", Font.BOLD, 8));
+		lblPp.setBackground(Color.BLACK);
+		
+		JLabel lblGp = new JLabel("gp");
+		GridBagConstraints gbc_lblGp = new GridBagConstraints();
+		gbc_lblGp.fill = GridBagConstraints.HORIZONTAL;
+		gbc_lblGp.insets = new Insets(0, 0, 0, 1);
+		gbc_lblGp.gridx = 1;
+		gbc_lblGp.gridy = 0;
+		panel_1.add(lblGp, gbc_lblGp);
+		lblGp.setOpaque(true);
+		lblGp.setHorizontalAlignment(SwingConstants.CENTER);
+		lblGp.setForeground(Color.WHITE);
+		lblGp.setFont(new Font("Tahoma", Font.BOLD, 8));
+		lblGp.setBackground(Color.BLACK);
+		
+		JLabel lblSp = new JLabel("sp");
+		GridBagConstraints gbc_lblSp = new GridBagConstraints();
+		gbc_lblSp.fill = GridBagConstraints.HORIZONTAL;
+		gbc_lblSp.insets = new Insets(0, 0, 0, 1);
+		gbc_lblSp.gridx = 2;
+		gbc_lblSp.gridy = 0;
+		panel_1.add(lblSp, gbc_lblSp);
+		lblSp.setOpaque(true);
+		lblSp.setHorizontalAlignment(SwingConstants.CENTER);
+		lblSp.setForeground(Color.WHITE);
+		lblSp.setFont(new Font("Tahoma", Font.BOLD, 8));
+		lblSp.setBackground(Color.BLACK);
+		
+		JLabel lblCp = new JLabel("cp");
+		GridBagConstraints gbc_lblCp = new GridBagConstraints();
+		gbc_lblCp.insets = new Insets(0, 0, 0, 1);
+		gbc_lblCp.fill = GridBagConstraints.HORIZONTAL;
+		gbc_lblCp.gridx = 3;
+		gbc_lblCp.gridy = 0;
+		panel_1.add(lblCp, gbc_lblCp);
+		lblCp.setOpaque(true);
+		lblCp.setHorizontalAlignment(SwingConstants.CENTER);
+		lblCp.setForeground(Color.WHITE);
+		lblCp.setFont(new Font("Tahoma", Font.BOLD, 8));
+		lblCp.setBackground(Color.BLACK);
 		
 		JTextField txtPP = new JTextField(StringHelper.toString(item.getValue().getPp()));
-		txtPP.setEditable(false);
-		txtPP.setColumns(10);
 		GridBagConstraints gbc_txtPP = new GridBagConstraints();
-		gbc_txtPP.insets = new Insets(0, 0, 0, 1);
 		gbc_txtPP.fill = GridBagConstraints.HORIZONTAL;
-		gbc_txtPP.gridx = 4;
-		gbc_txtPP.gridy = 2;
-		panel.add(txtPP, gbc_txtPP);
+		gbc_txtPP.insets = new Insets(0, 0, 0, 0);
+		gbc_txtPP.gridx = 0;
+		gbc_txtPP.gridy = 1;
+		panel_1.add(txtPP, gbc_txtPP);
+		txtPP.setEditable(false);
+		txtPP.setColumns(5);
 		
 		JTextField txtGP = new JTextField(StringHelper.toString(item.getValue().getGp()));
-		txtGP.setEditable(false);
-		txtGP.setColumns(10);
 		GridBagConstraints gbc_txtGP = new GridBagConstraints();
-		gbc_txtGP.insets = new Insets(0, 0, 0, 1);
 		gbc_txtGP.fill = GridBagConstraints.HORIZONTAL;
-		gbc_txtGP.gridx = 5;
-		gbc_txtGP.gridy = 2;
-		panel.add(txtGP, gbc_txtGP);
+		gbc_txtGP.insets = new Insets(0, 0, 0, 0);
+		gbc_txtGP.gridx = 1;
+		gbc_txtGP.gridy = 1;
+		panel_1.add(txtGP, gbc_txtGP);
+		txtGP.setEditable(false);
+		txtGP.setColumns(5);
 		
 		JTextField txtSP = new JTextField(StringHelper.toString(item.getValue().getSp()));
-		txtSP.setEditable(false);
-		txtSP.setColumns(10);
 		GridBagConstraints gbc_txtSP = new GridBagConstraints();
-		gbc_txtSP.insets = new Insets(0, 0, 0, 1);
 		gbc_txtSP.fill = GridBagConstraints.HORIZONTAL;
-		gbc_txtSP.gridx = 6;
-		gbc_txtSP.gridy = 2;
-		panel.add(txtSP, gbc_txtSP);
+		gbc_txtSP.insets = new Insets(0, 0, 0, 0);
+		gbc_txtSP.gridx = 2;
+		gbc_txtSP.gridy = 1;
+		panel_1.add(txtSP, gbc_txtSP);
+		txtSP.setEditable(false);
+		txtSP.setColumns(5);
 		
 		JTextField txtCP = new JTextField(StringHelper.toString(item.getValue().getCp()));
-		txtCP.setEditable(false);
-		txtCP.setColumns(10);
 		GridBagConstraints gbc_txtCP = new GridBagConstraints();
 		gbc_txtCP.fill = GridBagConstraints.HORIZONTAL;
-		gbc_txtCP.gridx = 7;
-		gbc_txtCP.gridy = 2;
-		panel.add(txtCP, gbc_txtCP);
-		
-		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);
+		gbc_txtCP.gridx = 3;
+		gbc_txtCP.gridy = 1;
+		panel_1.add(txtCP, gbc_txtCP);
+		txtCP.setEditable(false);
+		txtCP.setColumns(5);
 	}
 }