Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package butka;
- import java.awt.BorderLayout;
- import java.awt.Container;
- import java.awt.FlowLayout;
- import java.awt.Graphics;
- import java.awt.GridLayout;
- import java.awt.Image;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.ItemListener;
- import java.awt.event.ItemEvent;
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- import javax.swing.Icon;
- import javax.swing.ImageIcon;
- import javax.swing.JButton;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JOptionPane;
- import javax.swing.JPanel;
- import javax.swing.JRadioButton;
- import javax.swing.JTextField;
- import javax.swing.JCheckBox;
- import javax.swing.text.*;
- import javax.swing.ButtonGroup;
- public class CharTraits extends JFrame implements ActionListener {
- private GridLayout advsSectionLayout;
- private GridLayout disadvsSectionLayout;
- private ButtonGroup raceRGroup;
- private JPanel nameRaceJPanel;
- private JPanel advJPanel;
- private JPanel disadvJPanel;
- private JPanel traitsJPanel;
- private JPanel infoJPanel;
- private JPanel graphicJPanel;
- private JCheckBox advantages[];
- private JCheckBox disadvantages[];
- private JRadioButton races[];
- private String name;
- private String race;
- private Icon pcGraphic;
- private JButton pcGraphicButton;
- private int expNeed = 100;
- private final String disadvNames[] = {"PlaceHolder (%1)", "PlaceHolder (%2)", "PlaceHolder (%3)",
- "PlaceHolder (%4)", "PlaceHolder (%5)"};
- private final String advNames[] = {"Toughness (%10)", "Woodsman (%6)", "Magically Apt. (%20)",
- "Good Constitution (%10)", "Ambidextrous (%8)", "Highly Alert (%7)", "Nimble Fingers (%10)",
- "Exceptional Strength (%12)", "Cave Lore (%4)", "Recuperation (%15)"};
- private final String raceNames[] = {"Human (%0)", "Nephil (%12)", "Slithzerikai (%20)"};
- // private Icon human1L = new ImageIcon(getClass().getResource("C:/Human1Left.png"));
- private Icon human1R = new ImageIcon("C:/Human1Right.png");
- // private Icon nephil1L = new ImageIcon(getClass().getResource("C:/Nephil1LeftA.png"));
- private Icon nephil1R = new ImageIcon("C:/Nephil1RightA.png");
- // private Icon slith4L = new ImageIcon(getClass().getResource("C:/Slith4LeftA.png"));
- private Icon slith4R = new ImageIcon("C:/Slith4RightA.png");
- private JButton human1Button;
- private JButton nephil1Button;
- private JButton slith4Button;
- public CharTraits() {
- super("Pick Stats");
- ///////////////////////////SELECT NAME/RACE---NAME/RACE
- JLabel nameLabel = new JLabel("Name:");
- JTextField nameField = new JTextField("", 10);
- JLabel raceLabel = new JLabel(" Race:");
- raceRGroup = new ButtonGroup();
- nameRaceJPanel = new JPanel();
- nameRaceJPanel.add(nameLabel);
- nameRaceJPanel.add(nameField);
- nameRaceJPanel.add(raceLabel);
- races = new JRadioButton[raceNames.length];
- for (int count = 0; count < raceNames.length; ++count) {
- races[count] = new JRadioButton(raceNames[count]);
- races[count].addActionListener(this);
- nameRaceJPanel.add(races[count]);
- raceRGroup.add(races[count]);
- }
- //////////////////////////SELECT ADVANTAGES--ADVANTAGES
- JLabel advLabel = new JLabel("Advantages:");
- advsSectionLayout = new GridLayout(5, 2, 2, 8);
- advJPanel = new JPanel();
- advJPanel.setLayout(advsSectionLayout);
- advantages = new JCheckBox[advNames.length];
- for (int count = 0; count < advNames.length; ++count) {
- advantages[count] = new JCheckBox(advNames[count]);
- advantages[count].addActionListener(this);
- advJPanel.add(advantages[count]);
- }
- ////////////////////SELECT DISADVANTAGES--DISADVANTAGES
- JLabel disadvLabel = new JLabel("Disadvantages:");
- disadvsSectionLayout = new GridLayout(5, 1, 0, 8);
- disadvJPanel = new JPanel();
- disadvJPanel.setLayout(disadvsSectionLayout);
- disadvantages = new JCheckBox[disadvNames.length];
- for (int count = 0; count < disadvNames.length; ++count) {
- disadvantages[count] = new JCheckBox(disadvNames[count]);
- disadvantages[count].addActionListener(this);
- disadvJPanel.add(disadvantages[count]);
- }
- ///////////////////////////////SELECT GRAPHIC---GRAPHIC
- JLabel graphicLabel = new JLabel("Graphic:");
- graphicJPanel = new JPanel();
- graphicJPanel.setLayout(new GridLayout(2, 1, 2, 2));
- human1Button = new JButton(/*"Human 1",*/ human1R);
- nephil1Button = new JButton(/*"Nephilim 1",*/ nephil1R);
- slith4Button = new JButton(/*"Slithzerikai 4",*/ slith4R);
- graphicJPanel.add(human1Button);
- graphicJPanel.add(nephil1Button);
- graphicJPanel.add(slith4Button);
- ButtonHandler handler = new ButtonHandler();
- human1Button.addActionListener(handler);
- nephil1Button.addActionListener(handler);
- slith4Button.addActionListener(handler);
- human1Button.setActionCommand("Human1Right");
- nephil1Button.setActionCommand("Nephil1RightA");
- slith4Button.setActionCommand("Slith4RightA");
- /////SHOW CHARACTER INFORMATION---CHARACTER INFORMATION
- name = "FillerName";
- infoJPanel = new JPanel();
- pcGraphicButton = new JButton(human1R);//pcGraphic);
- // JLabel picture = new JLabel(createImageIcon("C:\\Human1Right.png"));
- // infoJPanel.add(pcGraphic);
- infoJPanel.add(pcGraphicButton);
- JLabel nameDisplay = new JLabel(name + " is " + race + " and needs " + expNeed + " experience per level.");
- infoJPanel.add(nameDisplay);
- ///////////////////////SET SIZE/LOCATON---SIZE/LOCATION
- nameRaceJPanel.setSize(600, 40);
- nameRaceJPanel.setLocation(0, 0);
- advLabel.setSize(70, 30);
- advLabel.setLocation(40, 50);
- advJPanel.setSize(400, 120);
- advJPanel.setLocation(50, 80);
- disadvLabel.setSize(90, 30);
- disadvLabel.setLocation(40, 200);
- disadvJPanel.setSize(125, 120);
- disadvJPanel.setLocation(50, 240);
- graphicLabel.setSize(50, 30);
- graphicLabel.setLocation(200, 200);
- graphicJPanel.setSize(70, 90);
- graphicJPanel.setLocation(200, 240);
- infoJPanel.setSize(600, 60);
- infoJPanel.setLocation(0, 400);
- ///////////////////ADD TO traitsJPanel/ADD traitsJPanel
- traitsJPanel = new JPanel();
- traitsJPanel.setLayout(null);
- traitsJPanel.add(nameRaceJPanel);
- traitsJPanel.add(advLabel);
- traitsJPanel.add(advJPanel);
- traitsJPanel.add(disadvLabel);
- traitsJPanel.add(disadvJPanel);
- traitsJPanel.add(graphicLabel);
- traitsJPanel.add(graphicJPanel);
- traitsJPanel.add(infoJPanel);
- add(traitsJPanel);
- }
- public void actionPerformed(ActionEvent e) {
- // pcGraphicButton.setImage("images/" + e.getActionCommand() + ".gif");
- }
- private class ButtonHandler implements ActionListener {
- public void actionPerformed( ActionEvent event ) {
- if (event.getActionCommand() == "Human") {
- pcGraphic = human1R;
- race = "Human";
- } else if (event.getActionCommand() == "Nephilim") {
- pcGraphic = nephil1R;
- race = "Nephilim";
- } else if (event.getActionCommand() == "Slithzerikai") {
- pcGraphic = slith4R;
- race = "Slithzerikai";
- }
- JOptionPane.showMessageDialog(CharTraits.this, (race));
- }
- }
- }
Add Comment
Please, Sign In to add comment