/*
* AdvantagesCreatorGUI.java
*
* Created on 17. Oktober 2004, 17:45
*/
package gurpscharacter4.gui;
import gurpscharacter4.system.AdvantageTemplate;
import gurpscharacter4.system.GurpsSystem;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Vector;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
/**
*
* @author Administrator
*/
public class AdvantagesCreatorGUI extends InternalFrame implements ActionListener {
GurpsSystem system;
Vector<AdvantageTemplate> advantages;
Vector<AdvantageTemplate> disadvantages;
AdvantageTemplate atWork=null;
JButton addAdv=new JButton("Add Advantage");
JButton remAdv=new JButton("Remove Advantage");
JButton addPre=new JButton("Add Prereq.");
JButton remPre=new JButton("Rem Prereq.");
JScrollPane scroll_list=new JScrollPane();
JScrollPane scroll_prereq=new JScrollPane();
JLabel id=new JLabel("ID");
JLabel name=new JLabel("Name");
JLabel cost=new JLabel("Cost");
JLabel exclusive=new JLabel("Exclusive");
JLabel level=new JLabel("Level");
JLabel prereq=new JLabel("Prereq.");
JCheckBox chk_exclusive=new JCheckBox();
JCheckBox chk_level=new JCheckBox();
JTextField prereq_input=new JTextField();
JTextField id_input=new JTextField();
JTextField name_input=new JTextField();
JTextField cost_input=new JTextField();
JList list_adv=new JList();
JList list_prereq=new JList();
JComboBox selector=new JComboBox();
/** Creates a new instance of AdvantagesCreatorGUI */
public AdvantagesCreatorGUI() {
super("Advantages Library",
true, //resizable
true, //closable
true, //maximizable
true);//iconifiable
setLocation(xOffset*openFrameCount, yOffset*openFrameCount);
openFrameCount++;
system=GurpsSystem.getInstance();
advantages=system.getAdvTemplates();
disadvantages=system.getDisadvTemplates();
//Layout
selector.addItem("Advantages");
selector.addItem("Disadvantages");
selector.addActionListener(this);
id_input.setColumns(20);
name_input.setColumns(20);
cost_input.setColumns(20);
prereq_input.setColumns(20);
scroll_list.getViewport().add(list_adv);
scroll_prereq.getViewport().add(list_prereq);
list_adv.setListData(advantages);
addComponent(selector,8,0,1,1,GridBagConstraints.HORIZONTAL,1,1);
addComponent(id,0,1,2,1);
addComponent(id_input,2,1,3,1,GridBagConstraints.HORIZONTAL,1,1,new Insets(5,10,5,10));
addComponent(scroll_list,8,1,1,8,GridBagConstraints.BOTH,1,1);
addComponent(name,0,2,2,1);
addComponent(name_input,2,2,3,1,GridBagConstraints.HORIZONTAL,1,1,new Insets(5,10,5,10));
addComponent(exclusive,5,2,2,1);
addComponent(chk_exclusive,7,2,1,1);
addComponent(cost,0,3,2,1);
addComponent(cost_input,2,3,3,1,GridBagConstraints.HORIZONTAL,1,1,new Insets(5,10,5,10));
addComponent(level,5,3,2,1);
addComponent(chk_level,7,3,1,1);
addComponent(prereq,0,4,2,1);
addComponent(prereq_input,2,4,3,1,GridBagConstraints.HORIZONTAL,1,1,new Insets(5,10,5,10));
addComponent(scroll_prereq,2,5,3,4,GridBagConstraints.BOTH,1,1,new Insets(5,10,5,10));
addComponent(addPre,5,4,3,1,GridBagConstraints.HORIZONTAL,0,0);
addComponent(remPre,5,5,3,1,GridBagConstraints.HORIZONTAL,0,0);
addComponent(addAdv,0,9,5,1,GridBagConstraints.HORIZONTAL,1,1);
addComponent(remAdv,5,9,4,1,GridBagConstraints.HORIZONTAL,1,1);
pack();
}
public void actionPerformed(java.awt.event.ActionEvent actionEvent) {
if (actionEvent.getSource()==this.selector) {
int selection=selector.getSelectedIndex();
switch (selection) {
case 1:
addAdv.setText("Add Advantage");
remAdv.setText("Remove Advantage");
list_adv.removeAll();
list_adv.setListData(advantages);
break;
case 2:
addAdv.setText("Add Disadvantage");
remAdv.setText("Remove Disadvantage");
list_adv.removeAll();
list_adv.setListData(disadvantages);
break;
}
}
this.updateUI();
}
}