Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JScrollPane;
- import javax.swing.JPanel;
- import javax.swing.JTextArea;
- import javax.swing.JTextField;
- import javax.swing.JTable;
- import javax.swing.BoxLayout;
- import javax.swing.table.DefaultTableModel;
- import javax.swing.table.TableModel;
- import java.awt.BorderLayout;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Dimension;
- import java.awt.event.KeyListener;
- import java.awt.event.KeyEvent;
- /**
- * This class acts as the main GUI, where everything is shown to the player.
- * Information such as Attributes, class, experience and the likes will all
- * be updated and shown here. These informations can also be collected from
- * this class. All Game Text will also be sent to this GUI, and all input
- * from the Player (in form of a String) will be collected here.
- */
- public class RPGWindow extends JFrame implements KeyListener{
- // Minimum and Maximum Physical Damage
- private int dMin, dMax;
- // Minimum and Maximum Magical Damage
- private int mMin, mMax;
- // Minimum and Maximum Health
- private int hMin, hMax;
- // Minimum and Maximum Mana
- private int maMin, maMax;
- // Dodge, Crit and Block
- private float dod, cri, blo;
- // Strength, Agility, Intelligence, Dexterity, Stamina
- private JLabel lStr;
- private JLabel lAgi;
- private JLabel lInt;
- private JLabel lDex;
- private JLabel lSta;
- // Attack Damage, Magic Damage, Dodge Chance, Critical Chance, Block Chance
- private JLabel lDmg;
- private JLabel mDmg;
- private JLabel lDod;
- private JLabel lCri;
- private JLabel lBlo;
- // Class, Level, Health, Mana, Experience
- private JLabel lCla;
- private JLabel lLvl;
- private JLabel lHel;
- private JLabel lMan;
- private JLabel lExp;
- // Main Hand, Off Hand, Head, Chest, Gloves, Legs, Boots, Neklace, Ring1, Ring2
- private JLabel lMah;
- private JLabel lOfh;
- private JLabel lHea;
- private JLabel lChe;
- private JLabel lGlo;
- private JLabel lLeg;
- private JLabel lBts;
- private JLabel lNec;
- private JLabel lRi1;
- private JLabel lRi2;
- // Fire, Poison, Water, Arcane, Lightning
- private JLabel lFir;
- private JLabel lPoi;
- private JLabel lWat;
- private JLabel lArc;
- private JLabel lLig;
- private JTextArea gameBox;
- private JTextArea descBox;
- private JTextField input;
- private JTable table;
- private DefaultTableModel model;
- private JTable table2;
- private DefaultTableModel model2;
- /**
- * Constructor for objects of class RPGWindow
- */
- public RPGWindow() {
- makeFrame();
- lLvl.setText("Level: " + 1);
- lExp.setText("Experience: " + 0);
- dMin = 0; dMax = 0;
- mMin = 0; mMax = 0;
- hMin = 0; hMax = 0;
- maMin = 0; maMax = 0;
- dod = 0; cri = 0; blo = 0;
- this.setVisible(true);
- }
- private void makeFrame() {
- // Setup Frame
- setTitle("Dungeons and Dragons");
- setSize(1100,600);
- setResizable(false);
- setDefaultCloseOperation(this.EXIT_ON_CLOSE);
- setBackground(Color.BLACK);
- // Make a Custom font
- Font font = new Font("Consolas", Font.PLAIN, 16);
- // Make the main JTextArea
- gameBox = new JTextArea();
- gameBox.setFont(font);
- gameBox.setBackground(Color.black);
- gameBox.setForeground(Color.green);
- gameBox.setLineWrap(true);
- gameBox.setWrapStyleWord(true);
- gameBox.setEditable(false);
- // For visualization only. Comment out when done.
- gameBox.setText("This is where the game text is gonna be so " +
- "here is a lot of filler crap to kind of demonstrate " +
- "word wrapping, etc. Please don't really pay attention " +
- "to this text as it is meaningless jabber!\n" +
- "But please do note how sexy it all looks.");
- // Make a panel to hold the main text area
- JScrollPane gScroll = new JScrollPane(gameBox);
- gScroll.setAutoscrolls(true);
- gScroll.setPreferredSize(new Dimension(400,415));
- JPanel gbPanel = new JPanel(new BorderLayout(1,1));
- gbPanel.setLayout(new BoxLayout(gbPanel, BoxLayout.Y_AXIS));
- gbPanel.add(gScroll, BorderLayout.NORTH);
- // Make a field for input and add to the panel
- input = new JTextField();
- input.addKeyListener(this);
- input.setPreferredSize(new Dimension(400,25));
- input.setBackground(Color.black);
- input.setForeground(Color.green);
- input.setFont(font);
- gbPanel.add(input, BorderLayout.CENTER);
- // Make panels for the southren end of the Game box panel
- JPanel gbSouth = new JPanel(new BorderLayout(1,1));
- JPanel gbSouthWest = new JPanel(new BorderLayout(1,1));
- gbSouthWest.setBackground(Color.black);
- gbSouthWest.setLayout(new BoxLayout(gbSouthWest, BoxLayout.Y_AXIS));
- JPanel gbSouthCenter = new JPanel(new BorderLayout(1,1));
- gbSouthCenter.setBackground(Color.black);
- JPanel gbSouthEast = new JPanel(new BorderLayout(1,1));
- gbSouthEast.setBackground(Color.black);
- gbSouthEast.setLayout(new BoxLayout(gbSouthEast, BoxLayout.Y_AXIS));
- // Make Labels
- Font lFont = new Font("Consolas", Font.BOLD, 12);
- JLabel lAtt = new JLabel("Attributes");
- lAtt.setFont(lFont);
- lAtt.setForeground(Color.white);
- lStr = new JLabel("Strength: ");
- lStr.setFont(lFont);
- lStr.setForeground(Color.red);
- lAgi = new JLabel("Agility: ");
- lAgi.setFont(lFont);
- lAgi.setForeground(Color.orange);
- lInt = new JLabel("Intelligence: ");
- lInt.setFont(lFont);
- lInt.setForeground(Color.cyan);
- lDex = new JLabel("Dexterity: ");
- lDex.setFont(lFont);
- lDex.setForeground(Color.yellow);
- lSta = new JLabel("Stamina: ");
- lSta.setFont(lFont);
- lSta.setForeground(Color.green);
- // Add Labels
- gbSouthWest.add(lAtt);
- gbSouthWest.add(lStr);
- gbSouthWest.add(lAgi);
- gbSouthWest.add(lInt);
- gbSouthWest.add(lDex);
- gbSouthWest.add(lSta);
- // Labels for the Center part of the south game box panel
- JLabel lOaD = new JLabel("Offensive/Defensive");
- lOaD.setFont(lFont);
- lOaD.setForeground(Color.white);
- lDmg = new JLabel("Attack Damage: ");
- lDmg.setFont(lFont);
- lDmg.setForeground(Color.white);
- mDmg = new JLabel("Magic Damage: ");
- mDmg.setFont(lFont);
- mDmg.setForeground(Color.white);
- lDod = new JLabel("Dodge Chance: ");
- lDod.setFont(lFont);
- lDod.setForeground(Color.white);
- lCri = new JLabel("Critical Chance: ");
- lCri.setFont(lFont);
- lCri.setForeground(Color.white);
- lBlo = new JLabel("Block Chance: ");
- lBlo.setFont(lFont);
- lBlo.setForeground(Color.white);
- // Resistances
- JLabel lRes = new JLabel("Ressistances");
- lRes.setFont(lFont);
- lRes.setForeground(Color.white);
- lFir = new JLabel("Fire: ");
- lFir.setFont(lFont);
- lFir.setForeground(Color.red);
- lPoi = new JLabel("Poison: ");
- lPoi.setFont(lFont);
- lPoi.setForeground(Color.green);
- lWat = new JLabel("Water: ");
- lWat.setFont(lFont);
- lWat.setForeground(Color.cyan);
- lArc = new JLabel("Arcane: ");
- lArc.setFont(lFont);
- lArc.setForeground(Color.pink);
- lLig = new JLabel("Lightning: ");
- lLig.setFont(lFont);
- lLig.setForeground(Color.yellow);
- JPanel gbSouthCenterWest = new JPanel(new BorderLayout(1,1));
- gbSouthCenterWest.setLayout(new BoxLayout(gbSouthCenterWest, BoxLayout.Y_AXIS));
- gbSouthCenterWest.setBackground(Color.black);
- gbSouthCenterWest.add(lOaD);
- gbSouthCenterWest.add(lDmg);
- gbSouthCenterWest.add(mDmg);
- gbSouthCenterWest.add(lDod);
- gbSouthCenterWest.add(lCri);
- gbSouthCenterWest.add(lBlo);
- JPanel gbSouthCenterEast = new JPanel(new BorderLayout(1,1));
- gbSouthCenterEast.setLayout(new BoxLayout(gbSouthCenterEast, BoxLayout.Y_AXIS));
- gbSouthCenterEast.setBackground(Color.black);
- gbSouthCenterEast.add(lRes);
- gbSouthCenterEast.add(lFir);
- gbSouthCenterEast.add(lPoi);
- gbSouthCenterEast.add(lWat);
- gbSouthCenterEast.add(lArc);
- gbSouthCenterEast.add(lLig);
- // Add Labels
- gbSouthCenter.add(gbSouthCenterWest, BorderLayout.WEST);
- gbSouthCenter.add(gbSouthCenterEast, BorderLayout.EAST);
- // Labels for the East part of the south game box panel
- JLabel lGen = new JLabel("General Information");
- lGen.setFont(lFont);
- lGen.setForeground(Color.white);
- lCla = new JLabel("Class: ");
- lCla.setFont(lFont);
- lCla.setForeground(Color.white);
- lLvl = new JLabel("Level: ");
- lLvl.setFont(lFont);
- lLvl.setForeground(Color.yellow);
- lHel = new JLabel("Health: ");
- lHel.setFont(lFont);
- lHel.setForeground(Color.red);
- lMan = new JLabel("Mana: ");
- lMan.setFont(lFont);
- lMan.setForeground(Color.cyan);
- lExp = new JLabel("Experience: ");
- lExp.setFont(lFont);
- lExp.setForeground(Color.green);
- // Add Labels
- gbSouthEast.add(lGen);
- gbSouthEast.add(lCla);
- gbSouthEast.add(lLvl);
- gbSouthEast.add(lHel);
- gbSouthEast.add(lMan);
- gbSouthEast.add(lExp);
- gbSouth.add(gbSouthWest,BorderLayout.WEST);
- gbSouth.add(gbSouthCenter,BorderLayout.CENTER);
- gbSouth.add(gbSouthEast,BorderLayout.EAST);
- gbPanel.add(gbSouth, BorderLayout.SOUTH);
- // Make the main content panel and 4 sub panels
- // for each section of the JFrame
- JPanel contentPane = (JPanel) getContentPane();
- JPanel northPanel = new JPanel(new BorderLayout(1,1));
- JPanel southPanel = new JPanel(new BorderLayout(1,1));
- JPanel eastPanel = new JPanel(new BorderLayout(1,1));
- JPanel westPanel = new JPanel(new BorderLayout(1,1));
- // Make a "skeleton" for the Backpack
- model = new DefaultTableModel();
- // Make the JTable, and add columns
- table = new JTable(model);
- model.addColumn("Item");
- model.addColumn("Amount");
- model.insertRow(0, new Object []{"Some item", 1});
- // Configure the table
- table.setEnabled(false);
- table.setBackground(Color.black);
- table.setForeground(Color.green);
- JScrollPane tScroll = new JScrollPane(table);
- tScroll.setPreferredSize(new Dimension(300, 450));
- westPanel.add(tScroll, BorderLayout.WEST);
- // Make a "skeleton" for the Ability Pane
- model2 = new DefaultTableModel();
- // Make the JTable, and add Columns
- table2 = new JTable(model2);
- model2.addColumn("Name");
- model2.addColumn("Level");
- model2.addColumn("Mana Cost");
- model2.insertRow(0, new Object [] {"Some Ability", 1, 123});
- // Configure the table
- table2.setEnabled(false);
- table2.setBackground(Color.black);
- table2.setForeground(Color.green);
- JScrollPane tScroll2 = new JScrollPane(table2);
- tScroll2.setPreferredSize(new Dimension(300, 450));
- eastPanel.add(tScroll2, BorderLayout.EAST);
- // Make a Description Box
- descBox = new JTextArea("Some Description");
- descBox.setFont(font);
- descBox.setBackground(Color.black);
- descBox.setForeground(Color.green);
- descBox.setLineWrap(true);
- descBox.setWrapStyleWord(true);
- descBox.setEditable(false);
- // Make a scroll pane for the Description box
- JScrollPane dScroll = new JScrollPane(descBox);
- dScroll.setPreferredSize(new Dimension(300,150));
- eastPanel.add(dScroll, BorderLayout.SOUTH);
- // Labels for Equipment
- lMah = new JLabel("Main Hand:");
- lMah.setFont(lFont);
- lMah.setForeground(Color.white);
- lOfh = new JLabel("Off Hand:");
- lOfh.setFont(lFont);
- lOfh.setForeground(Color.white);
- lHea = new JLabel("Head:");
- lHea.setFont(lFont);
- lHea.setForeground(Color.white);
- lChe = new JLabel("Chest:");
- lChe.setFont(lFont);
- lChe.setForeground(Color.white);
- lGlo = new JLabel("Gloves:");
- lGlo.setFont(lFont);
- lGlo.setForeground(Color.white);
- lLeg = new JLabel("Legs:");
- lLeg.setFont(lFont);
- lLeg.setForeground(Color.white);
- lBts = new JLabel("Boots:");
- lBts.setFont(lFont);
- lBts.setForeground(Color.white);
- lNec = new JLabel("Necklace:");
- lNec.setFont(lFont);
- lNec.setForeground(Color.white);
- lRi1 = new JLabel("Ring 1:");
- lRi1.setFont(lFont);
- lRi1.setForeground(Color.white);
- lRi2 = new JLabel("Ring 2:");
- lRi2.setFont(lFont);
- lRi2.setForeground(Color.white);
- // Equipment Panel
- JPanel equipPanel = new JPanel(new BorderLayout(1,1));
- equipPanel.setBackground(Color.black);
- equipPanel.setLayout(new BoxLayout(equipPanel, BoxLayout.Y_AXIS));
- equipPanel.add(lMah);
- equipPanel.add(lOfh);
- equipPanel.add(lHea);
- equipPanel.add(lChe);
- equipPanel.add(lGlo);
- equipPanel.add(lLeg);
- equipPanel.add(lBts);
- equipPanel.add(lNec);
- equipPanel.add(lRi1);
- equipPanel.add(lRi2);
- westPanel.add(equipPanel, BorderLayout.SOUTH);
- // Add all panels to the main panel.
- contentPane.add(northPanel, BorderLayout.NORTH);
- contentPane.add(southPanel, BorderLayout.SOUTH);
- contentPane.add(eastPanel, BorderLayout.EAST);
- contentPane.add(westPanel, BorderLayout.WEST);
- contentPane.add(gbPanel, BorderLayout.CENTER);
- }
- /**
- *
- */
- public void keyPressed(KeyEvent ePressed) {
- String text = getInput();
- if(ePressed.getKeyCode() == KeyEvent.VK_ENTER) {
- if(text.length() == 0) {
- // No command was entered
- } else {
- gameBox.append("\n" + text);
- input.setText("");
- }
- }
- }
- /**
- * @return The JTextArea that contains the game text.
- */
- public JTextArea getGameBox() {
- return gameBox;
- }
- /**
- * @return The JTextArea that contains descriptions
- */
- public JTextArea getDescBox() {
- return descBox;
- }
- /**
- * @return The input from the JTextField as a String.
- */
- public String getInput() {
- return input.getText();
- }
- /**
- * This method will insert an item into the backpack (JTable)
- *
- * @param item The Item to be inserted
- * @param amount How many of the item to insert
- */
- public void insertItem(String item, int amount) {
- if(model.getRowCount() == 0) {
- model.insertRow(0, new Object[]{item, amount});
- } else {
- for(int i = 0; i < model.getRowCount(); i++) {
- if(model.getValueAt(i,0).equals(item)) {
- int am = (int) model.getValueAt(i,1);
- model.setValueAt(am + amount, i, 1);
- return;
- }
- }
- model.insertRow(model.getRowCount(), new Object[]{item, amount});
- }
- }
- /**
- * This method will remove an item from the backpack (JTable)
- *
- * @param item The item to remove (also called "Use")
- * @param amount How many of the item to use (Usually only 1)
- */
- public void removeItem(String item, int amount) throws NoItemFoundException {
- if(model.getRowCount() == 0) {
- throw new NoItemFoundException(item);
- } else {
- for(int i = 0; i < model.getRowCount(); i++) {
- if(model.getValueAt(i,0).equals(item)) {
- int am = (int) model.getValueAt(i,1);
- if(am - amount <= 0) {
- model.removeRow(i);
- return;
- } else {
- model.setValueAt(am - amount, i, 1);
- return;
- }
- } else {
- throw new NoItemFoundException(item);
- }
- }
- }
- }
- /**
- * Insert a spell or ability into the spell book
- *
- * @param name Name of the Spell
- * @param level The Level of the Spell
- * @param manacost How much mana the spell should cost to use
- */
- public void insertAbility(String name, int level, int manacost) throws DuplicateAbilityException {
- if(model2.getRowCount() == 0) {
- model2.insertRow(0, new Object[]{name, level, manacost});
- } else {
- for(int i = 0; i < model2.getRowCount(); i++) {
- if(model2.getValueAt(i,0).equals(name)) {
- throw new DuplicateAbilityException(name);
- }
- }
- model2.insertRow(model2.getRowCount(), new Object[]{name, level, manacost});
- }
- }
- /**
- * Remove a spell or ability from the spell book.
- *
- * @param name The spell to look for.
- */
- public void removeAbility(String name) throws NoAbilityFoundException {
- if(model2.getRowCount() == 0) {
- throw new NoAbilityFoundException(name);
- } else {
- for(int i = 0; i < model2.getRowCount(); i++) {
- if(model2.getValueAt(i,0).equals(name)) {
- model2.removeRow(i);
- return;
- } else {
- throw new NoAbilityFoundException(name);
- }
- }
- }
- }
- /**
- * Upgrade a spell or ability from the spell book.
- *
- * @param name The spell to upgrade
- * @param manacost The new manacost for the ability, if any.
- */
- public void upgradeAbility(String name, int manacost) throws NoAbilityFoundException {
- if(model2.getRowCount() == 0) {
- throw new NoAbilityFoundException(name);
- } else {
- for(int i = 0; i < model2.getRowCount(); i++) {
- if(model2.getValueAt(i,0).equals(name)) {
- int l = (int) model2.getValueAt(i,1);
- int m = (int) model2.getValueAt(i,2);
- model2.setValueAt(l + 1, i, 1);
- model2.setValueAt(m + manacost, i, 2);
- return;
- } else {
- throw new NoAbilityFoundException(name);
- }
- }
- }
- }
- /**
- * Will return the mana cost for specific spell or ability in the spell book
- *
- * @param name The spell to look for.
- */
- public int getManaCost(String name) throws NoAbilityFoundException {
- int cost = 0;
- if(model2.getRowCount() == 0) {
- throw new NoAbilityFoundException(name);
- } else {
- for(int i = 0; i < model2.getRowCount(); i++) {
- if(model2.getValueAt(i,0).equals(name)) {
- cost = (int) model2.getValueAt(i,2);
- break;
- } else {
- throw new NoAbilityFoundException(name);
- }
- }
- }
- return cost;
- }
- /**
- * ATTRIBUTES
- */
- /**
- * @param val Set the Strength Attribute.
- */
- public void setStr(int val) {
- lStr.setText("Strength: " + val);
- }
- public int getStr() {
- return Integer.parseInt(lStr.getText().substring(10));
- }
- /**
- * @param val Set the Agility Attribute.
- */
- public void setAgi(int val) {
- lAgi.setText("Agility: " + val);
- }
- public int getAgi() {
- return Integer.parseInt(lAgi.getText().substring(9));
- }
- /**
- * @param val Set the Intelligence Attribute.
- */
- public void setInt(int val) {
- lInt.setText("Intelligence: " + val);
- }
- public int getInt() {
- return Integer.parseInt(lInt.getText().substring(14));
- }
- /**
- * @param val Set the Dexterity Attribute.
- */
- public void setDex(int val) {
- lDex.setText("Dexterity: " + val);
- }
- public int getDex() {
- return Integer.parseInt(lDex.getText().substring(11));
- }
- /**
- * @param val Set the Stamina Attribute.
- */
- public void setSta(int val) {
- lSta.setText("Stamina: " + val);
- }
- public int getSta() {
- return Integer.parseInt(lSta.getText().substring(9));
- }
- /**
- * @param dMin Minimum Damage before crit and block
- * @param dMax Maximum Damage before crit and block
- */
- public void setDamage(int dMin, int dMax) {
- this.dMin = dMin;
- this.dMax = dMax;
- lDmg.setText("Attack Damage: " + this.dMin + "-" + this.dMax);
- }
- public int getMinDmg() {
- return dMin;
- }
- public int getMaxDmg() {
- return dMax;
- }
- /**
- * @param dMin Minimum Damage
- * @param dMax Maximum Damage
- */
- public void setMagicDamage(int mMin, int mMax) {
- this.mMin = mMin;
- this.mMax = mMax;
- mDmg.setText("Magic Damage: " + this.dMin + "-" + this.dMax);
- }
- public int getMinMagic() {
- return mMin;
- }
- public int getMaxMagic() {
- return mMax;
- }
- /**
- * @param val Set the Dodge Attribute
- */
- public void setDodge(float val) {
- dod = val;
- lDod.setText("Dodge Chance: " + dod + "%");
- }
- public float getDodge() {
- return dod;
- }
- /**
- * @param val Set the Critical Chance Attribute
- */
- public void setCrit(float val) {
- cri = val;
- lCri.setText("Critical Chance: " + cri + "%");
- }
- public float getCrit() {
- return cri;
- }
- /**
- * @param val Set the Block Chance Attribute
- */
- public void setBlock(float val) {
- blo = val;
- lBlo.setText("Block Chance: " + blo + "%");
- }
- public float getBlock() {
- return blo;
- }
- /**
- * GENERAL
- */
- /**
- * @param rll Set the Name of the Class.
- */
- public void setRole(String rll) {
- lCla.setText("Class: " + rll);
- }
- public String getRole() {
- return lCla.getText().substring(7);
- }
- /**
- * @param val The Level to be set.
- */
- public void setLevel(int val) {
- lLvl.setText("Level: " + val);
- }
- public int getLevel() {
- return Integer.parseInt(lLvl.getText().substring(7));
- }
- /**
- * @param hMin Minimum value of the Health Attribute
- * @param hMax Maximum value of the Health Attribute
- */
- public void setHealth(int hMin, int hMax) {
- this.hMin = hMin;
- this.hMax = hMax;
- lHel.setText("Health: " + this.hMin + "/" + this.hMax);
- }
- public int getMinHp() {
- return hMin;
- }
- public int getMaxHp() {
- return hMax;
- }
- /**
- * @param mMin Minimum value of the Mana Attribute
- * @param mMax Minimum value of the Mana Attribute
- */
- public void setMana(int maMin, int maMax) {
- this.maMin = maMin;
- this.maMax = maMax;
- lMan.setText("Mana: " + this.maMin + "/" + this.maMax);
- }
- public int getMinMana() {
- return maMin;
- }
- public int getMaxMana() {
- return maMax;
- }
- /**
- * @param val The Experience to be set.
- */
- public void setExperience(int val) {
- lExp.setText("Experience: " + val);
- }
- public int getExperience() {
- return Integer.parseInt(lExp.getText().substring(12));
- }
- /**
- * EQUIPIMENT
- */
- /**
- * @param item Set the Main Hand Weapon.
- * @param clr Quality of the item expressed in a Color.
- */
- public void setMainHand(String item, Color clr) {
- lMah.setText("Main Hand: " + item);
- lMah.setForeground(clr);
- }
- public String getMainHand() {
- return lMah.getText().substring(11);
- }
- /**
- * @param item Set the Off Hand Weapon.
- * @param clr Quality of the item expressed in a Color.
- */
- public void setOffHand(String item, Color clr) {
- lOfh.setText("Off Hand: " + item);
- lOfh.setForeground(clr);
- }
- public String getOffHand() {
- return lOfh.getText().substring(10);
- }
- /**
- * @param item Set the Head armor
- * @param clr Quality of the item expressed in a Color.
- */
- public void setHead(String item, Color clr) {
- lHea.setText("Head: " + item);
- lHea.setForeground(clr);
- }
- public String getHead() {
- return lHea.getText().substring(6);
- }
- /**
- * @param item Set the Chest armor
- * @param clr Quality of the item expressed in a Color.
- */
- public void setChest(String item, Color clr) {
- lChe.setText("Chest: " + item);
- lChe.setForeground(clr);
- }
- public String getChest() {
- return lChe.getText().substring(7);
- }
- /**
- * @param item Set the Gloves armor
- * @param clr Quality of the item expressed in a Color.
- */
- public void setGloves(String item, Color clr) {
- lGlo.setText("Gloves: " + item);
- lGlo.setForeground(clr);
- }
- public String getGloves() {
- return lGlo.getText().substring(8);
- }
- /**
- * @param item Set the Legs armor
- * @param clr Quality of the item expressed in a Color.
- */
- public void setLegs(String item, Color clr) {
- lLeg.setText("Legs: " + item);
- lLeg.setForeground(clr);
- }
- public String getLegs() {
- return lLeg.getText().substring(6);
- }
- /**
- * @param item Set the Boots armor
- * @param clr Quality of the item expressed in a Color.
- */
- public void setBoots(String item, Color clr) {
- lBts.setText("Boots: " + item);
- lBts.setForeground(clr);
- }
- public String getBoots() {
- return lBts.getText().substring(7);
- }
- /**
- * @param item Set the Neck item
- * @param clr Quality of the item expressed in a Color.
- */
- public void setNeck(String item, Color clr) {
- lNec.setText("Necklace: " + item);
- lNec.setForeground(clr);
- }
- public String getNeck() {
- return lNec.getText().substring(10);
- }
- /**
- * @param item Set the First Ring item
- * @param clr Quality of the item expressed in a Color.
- */
- public void setRing1(String item, Color clr) {
- lRi1.setText("Ring 1: " + item);
- lRi1.setForeground(clr);
- }
- public String getRing1() {
- return lRi1.getText().substring(8);
- }
- /**
- * @param item Set the Second Ring item
- * @param clr Quality of the item expressed in a Color.
- */
- public void setRing2(String item, Color clr) {
- lRi2.setText("Ring 2: " + item);
- lRi2.setForeground(clr);
- }
- public String getRing2() {
- return lRi2.getText().substring(8);
- }
- /**
- * RESISTANCES
- */
- /**
- * Sets the Fire ressistance
- * @param val The value for the ressistance.
- */
- public void setFireRess(int val) {
- lFir.setText("Fire: " + val);
- }
- public int getFireRess() {
- return Integer.parseInt(lFir.getText().substring(6));
- }
- /**
- * Sets the Poison ressistance
- * @param val The value for the ressistance.
- */
- public void setPoisonRess(int val) {
- lPoi.setText("Poison: " + val);
- }
- public int getPoisonRess() {
- return Integer.parseInt(lPoi.getText().substring(8));
- }
- /**
- * Sets the Water ressistance
- * @param val The value for the ressistance.
- */
- public void setWaterRess(int val) {
- lWat.setText("Water: " + val);
- }
- public int getWaterRess() {
- return Integer.parseInt(lWat.getText().substring(7));
- }
- /**
- * Sets the Arcane ressistance
- * @param val The value for the ressistance.
- */
- public void setArcaneRess(int val) {
- lArc.setText("Arcane: " + val);
- }
- public int getArcaneRess() {
- return Integer.parseInt(lArc.getText().substring(8));
- }
- /**
- * Sets the Lightning ressistance
- * @param val The value for the ressistance.
- */
- public void setLightningRess(int val) {
- lLig.setText("Lightning: " + val);
- }
- public int getLightningRess() {
- return Integer.parseInt(lLig.getText().substring(11));
- }
- /**
- * Unused Method implemented from KeyListener
- */
- public void keyReleased(KeyEvent eReleased) {}
- /**
- * Unused Method implemented from KeyListener
- */
- public void keyTyped(KeyEvent eTyped) {}
- }
Add Comment
Please, Sign In to add comment