+ Reply to Thread
Results 1 to 20 of 20
  1. #1

    Java program Help: KI tracker

    Ok im trying to make a java program to help me keep up with my emp weapons Ki progress. Im a newby programer that kind of sucks. Basicly what I want is to be able to add players names. Have check boxes beside KI names and check boxes for players names. When check player name , KI, and hit the add button it adds the KI to the players KI list and updates on the screen. What is the best way to go about this? I know its going to have to update teh JLables from a txt file so it can be closed/open and data will be saved (everytime you hit add/remove/add player). Is there alredy something like this already out?


    Layout:

    Top: scrollable menu that has Player name: ( all KI's for selected NM )

    left: Check boxes that have all KI's needed for selected NM

    center: check boxes that have all players on list

    bottom: add player, add KI, remove KI, Remove Player buttons.

    Right now im making it stagnet for just glavoid to get something working, and then add other NM's later.

    Right now i have the program layed out. It has hard coded names for my group at the top. I have check boxes and names for all KI's for glavoid. It has hard coded check boxes for players in my group, and the Add/remove button are in place. (will post code and a pic of kinda what im looking for. Anyone willing to help me out on this project?

    Thanks a ton!

    Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import javax.swing.JCheckBox;
    
    
    
    public class Emphelper extends JFrame implements ActionListener {
    
    	JCheckBox manticoreMane, wormHusk, adzeWing, fatSkin, aylee, blackmass, meika, spitfyre;
    	JButton addki, removeki, addp, removep ;
    	JLabel me, bm, whitney, mule, empty, empty2, empty3, empty4;
    	JTextField me2, bm2, whitney2, mule2;
    
    	public Emphelper() {
    
            JPanel panel = new JPanel();
            panel.setLayout(new BorderLayout());
    		
    		JPanel popList = new JPanel();
    		popList.setLayout(new GridLayout(4,0));
    		
    		JPanel blank = new JPanel();
    		blank.setLayout(new FlowLayout());
    		
    		JPanel blank2 = new JPanel();
    		blank2.setLayout(new GridLayout(2,0));
    		
    		JPanel subPanelA = new JPanel();
    		subPanelA.setLayout(new BorderLayout());
    		
    		JPanel subPanelB = new JPanel();
    		subPanelB.setLayout(new BorderLayout());
    		
    		JPanel popList2 = new JPanel();
    		popList2.setLayout(new GridLayout(4,0));
    		
    		JPanel kiPanel = new JPanel();
    		kiPanel.setLayout(new GridLayout(4,0));
    
    		JPanel playerPanel = new JPanel();
    		playerPanel.setLayout(new GridLayout(4,0));		
    		
    		JPanel buttonPanel = new JPanel();
    		buttonPanel.setLayout(new FlowLayout());
    		
    		me = new JLabel("Aylee :     ");
    		bm = new JLabel("Blackmass :    ");
    		whitney = new JLabel("Meika :    ");
    		mule = new JLabel("Spitfyre :    ");
    		
    		me2 = new JTextField("test, test2");
    		bm2 = new JTextField("test");
    		whitney2 = new JTextField("");
    		mule2 = new JTextField("test,test,test,test");
    		
    		empty = new JLabel("       ");
    		empty2 = new JLabel("         ");
    		empty3 = new JLabel("         ");
    		empty4 = new JLabel("         ");
    		
    		fatSkin = new JCheckBox("Fat-lined Cockatrice Skin");
    		manticoreMane = new JCheckBox("Luxuriant Manticore Mane");
    		wormHusk = new JCheckBox("Sodden Sandworm Husk");
    		adzeWing = new JCheckBox("Sticky Gnat Wing");
    		
    		aylee = new JCheckBox("Aylee");
    		blackmass = new JCheckBox("Blackmass");
    		meika = new JCheckBox("Meika");
    		spitfyre = new JCheckBox("Spitfyre");
    		
    		addki = new JButton("Add KI");
    		addki.addActionListener(this);
    		removeki = new JButton("Remove KI");
    		removeki.addActionListener(this);
    		addp = new JButton("Add Player");
    		addp.addActionListener(this);
    		removep = new JButton("Remove Player");
    		removep.addActionListener(this);
    		
    		popList.add(me);
    		popList.add(bm);
    		popList.add(whitney);
    		popList.add(mule);
    		
    		popList2.add(me2);
    		popList2.add(bm2);
    		popList2.add(whitney2);
    		popList2.add(mule2);
    		
    		blank.add(empty);
    		blank.add(empty2);
    		blank2.add(empty3);
    		blank2.add(empty4);
    		
    		kiPanel.add(fatSkin);
    		kiPanel.add(manticoreMane);
    		kiPanel.add(wormHusk);
    		kiPanel.add(adzeWing);
    		
    		playerPanel.add(aylee);
    		playerPanel.add(blackmass);
    		playerPanel.add(meika);
    		playerPanel.add(spitfyre);
    		
    		buttonPanel.add(addki);
    		buttonPanel.add(removeki);
    		buttonPanel.add(addp);
    		buttonPanel.add(removep);
    		
    		subPanelA.add(subPanelB, BorderLayout.NORTH);
    		subPanelA.add(blank2, BorderLayout.SOUTH);
    		
    		subPanelB.add(popList, BorderLayout.WEST);
    		subPanelB.add(popList2, BorderLayout.CENTER);
    
    
    		panel.add(subPanelA, BorderLayout.NORTH);
    		panel.add(kiPanel, BorderLayout.WEST);
    		panel.add(blank, BorderLayout.CENTER);
    		panel.add(playerPanel, BorderLayout.EAST);
    		panel.add(buttonPanel, BorderLayout.SOUTH);
    		
            add(panel);
    
        }
    	
    	public void actionPerformed(ActionEvent e) {
    		if (e.getSource() == addki) {
    			
    		}
    		if (e.getSource() == removeki) {
    			
    		}
    		if (e.getSource() == addp) {
    		
    		}
    		if (e.getSource() == removep) {
    		
    		}
    
    	}
    	
    	public static void main(String[] args) {
            Emphelper win = new Emphelper();
            win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            win.pack();
            win.setVisible(true);
        }
    }
    http://i185.photobucket.com/albums/x.../KItracker.png
    something like this

    This is what i have so far (hard coded for only my small static)

    http://i185.photobucket.com/albums/x...5/Untitled.png

  2. #2
    The Wang
    Join Date
    Jun 2006
    Posts
    1,345
    BG Level
    6
    FFXIV Character
    Furt Wangler
    FFXIV Server
    Coeurl
    FFXI Server
    Sylph

    Do you want to be able to add multiple KI items to multiple people at once? for instance adding a skin + husk to Meika and Spitfyre? If you don't consider using radio buttons instead of check boxes. Also, look into JScrollPanes for the ability to scroll when you have too many people in the list. Consider re-laying out the display for what they have already. You can make it much more readable by having a table for each player, where the respective columns have a frequency of each item. Since your item's are a fixed number(it only drops x type of items) you can have set columns for each item.

    For file saving, I'd suggest using a CSV text file (stands for Comma separated values, the commas delimit different parts of your data that you catch when reading/writing). You could have each line represent a player, so it may look like
    Blackmass,item1,item1,item1,item2,item3 OR, Blackmass,item1;4,item2;4,item3;5 where the second number is the frequency of what they have so far.

    The text file gets loaded in to your program and stored upon start, and then re-written with updated values when you save or close (you'll need to catch for the on close of the window and/or make a save button, OR have it do it after each addition which is kinda in-efficient.)

    edit;
    class wise, you want to separate your logic as much as possible. Have a view class, a class that models your data, and a class that interacts between the two. Also, you'll want a separate class (to once again keep your concerns separated) to deal with writing and reading from a file. I can draw out some class diagrams for you later if you want, in class atm.

  3. #3

    Quote Originally Posted by Furtwangler View Post
    Do you want to be able to add multiple KI items to multiple people at once? for instance adding a skin + husk to Meika and Spitfyre? If you don't consider using radio buttons instead of check boxes.
    I was intending it to be one at a time. Kind of takes away the accuracy and point if you do multiple ones at a time. If radio buttons are better for this i can change the check boxes to them.


    Quote Originally Posted by Furtwangler View Post
    Also, look into JScrollPanes for the ability to scroll when you have too many people in the list.
    Can I use the JScrollPanes like a JPanel and add my JLables and JTextArea's to it? I dont have much experience with them.

    Quote Originally Posted by Furtwangler View Post
    Consider re-laying out the display for what they have already. You can make it much more readable by having a table for each player, where the respective columns have a frequency of each item. Since your item's are a fixed number(it only drops x type of items) you can have set columns for each item.
    Im not really sure what you mean here. If It can be more readable by all means im game. Are you meaning have it set up like a table where the y axis is the KI and the X axis is the player and puting like X's if they have the item and banks if they dont?

    Quote Originally Posted by Furtwangler View Post
    For file saving, I'd suggest using a CSV text file (stands for Comma separated values, the commas delimit different parts of your data that you catch when reading/writing). You could have each line represent a player, so it may look like
    Blackmass,item1,item1,item1,item2,item3 OR, Blackmass,item1;4,item2;4,item3;5 where the second number is the frequency of what they have so far.
    Can you find me an example of this. I knew I would have to use it but haven't been able to find a really good example of it.

    Quote Originally Posted by Furtwangler View Post
    The text file gets loaded in to your program and stored upon start, and then re-written with updated values when you save or close (you'll need to catch for the on close of the window and/or make a save button, OR have it do it after each addition which is kinda in-efficient.)
    I was planing on when you hit a button (any of the current 4) it would add it to the text file, save the text file, then update the respective fields on the program. If there is a better way please let me know. (with examples if possible)

    Quote Originally Posted by Furtwangler View Post
    For file saving, I'd suggest using a CSV text file (stands for Comma separated values, the commas delimit different parts of your data that you catch when reading/writing). You could have each line represent a player, so it may look like
    Blackmass,item1,item1,item1,item2,item3 OR, Blackmass,item1;4,item2;4,item3;5 where the second number is the frequency of what they have so far.
    Can you find me an example of this. I knew I would have to use it but haven't been able to find a really good example of it.

    Quote Originally Posted by Furtwangler View Post
    class wise, you want to separate your logic as much as possible. Have a view class, a class that models your data, and a class that interacts between the two. Also, you'll want a separate class (to once again keep your concerns separated) to deal with writing and reading from a file. I can draw out some class diagrams for you later if you want, in class atm.
    are you talking about new classes with each kinda section per class? I hate having to flip threw multiple files to find one im looking for lol but it is getting kind of complex and looks like im going to have to. I always have trouble with this. I can never get multiple classes to work in the same file.

    Anyway I applicate all the help. I'll make the changes I can and post results. Thanks!

  4. #4

    Quote Originally Posted by Skie View Post
    Ok im trying to make a java program to help me keep up with my emp weapons Ki progress. Im a newby programer that kind of sucks. What is the best way to go about this?
    dont know how far you are .. make the ui in html/jsp, get a java server .. easier than dealing with javax.swing.* imo

  5. #5

    Quote Originally Posted by quannum View Post
    dont know how far you are .. make the ui in html/jsp, get a java server .. easier than dealing with javax.swing.* imo
    no where close. But i would like to get it on a server so anyone in the static can update it when they solo farm. I can probably get a server spot from ls mate. if someone could walk me through it once the project is finished.

  6. #6
    The Wang
    Join Date
    Jun 2006
    Posts
    1,345
    BG Level
    6
    FFXIV Character
    Furt Wangler
    FFXIV Server
    Coeurl
    FFXI Server
    Sylph

    I'm not familiar with html/jsp so if you want to go that route can't really help you.

    I just quickly changed this up to what I was thinking, http://img830.imageshack.us/img830/2463/mockupi.jpg
    The way I was thinking of it, is to have a Jpanel for each player up top. Use a 1x4, or 1x5 or however many items you have+1 grid layout, with the name, and then JLabels for numbers for the respective items. You can change the text on those items when something is added or removed. You will know which label corresponds to which item based on its index.

    I'd suggest radio buttons because then it forces the user to only be able to click 1 button per group, less error checking.

    You add one JPanel into a JScrollPane and then add that JScrollPane into your main frame. You can then add/remove stuff from your JPANEL and the scrollpane will automatically scroll if necessary.

    Do you want an example of how to use a CSV file? or how to deal with file i/o in general? the CSV logic is fairly straightforward and something you will want to create on your own since it will be tailored to your implementation. You read in each line, and then you can split that string into array elements delimited by a ",", then further process each array into whatever data structure you want to use.

    I feel like good practice when dealing with files is only to read when initializing, and save when requested, and to keep a current database stored in memory. In this case it's going to depend how much changing you are doing at any one time the program is open. I would lay it out like this:
    Open program -> Read file -> make internal database from file.
    Add Item/player/etc -> edit internal database.
    Save - > write internal database to file.

    If you want to automatically save that could work too, in which case any time something changes you immediately call a save function that writes to file. No need to re-read anything.

    The size of this is going to get a bit larger than I think you are planning for. You want to try to avoid making a blob as much as possible. Just panels and shit with swing should be its own class. I also create subclasses (INSIDE THAT MAIN CLASS) for my ActionListeners, so you don't have to say if(action = this){} else if(action = this{} etc. Each listener only does one thing. Also, I have my main class extend JFrame, and then you can add things directly to it.

    I would have a separate class that deals with holding that database you create, possibly also dealing with file I/O. I'd use ArrayLists or Vectors (same thing basically, vectors are thread safe, if you don't know what that means don't worry about it.)
    Each item in the list could be an Array that has {[name],[itemcount#1],[itemcount#2],[itemcount#3]}The action listeners can call that class for their information.

    In larger systems an architectural pattern called MVC or Model-View-Controller is commonly used, which helps separate your Data Model, from your physical View, and a Controller is the interaction between them. In a perfect world, your View has no real logic in it, just physical components. Google it if you're interested. This isn't really going to be necessary since there is not too much going on here.

    Look into developing in Eclipse if you're just using a text editor, will make using multiple class files a lot easier.

  7. #7

    Awesome gonna work on what you commented on for about 2 hours and let you know what i get.

    Also a player can only hold 0 or 1 of the items. So the value will never be greater than 1 But i'll go with the table. Gonna try to figure out how to a JScrollPane in a JPanel.

    Is this how to do it? where popList is the list of Ki's each people hold (going to be the table)

    Code:
      JPanel scrollingList = new JPanel(new GridLayout(4,5));
      JScrollPane sp = new JScrollPane(scrollingList);
      popList.add(sp, BorderLayout.CENTER);

  8. #8
    The Wang
    Join Date
    Jun 2006
    Posts
    1,345
    BG Level
    6
    FFXIV Character
    Furt Wangler
    FFXIV Server
    Coeurl
    FFXI Server
    Sylph

    aim me or something if you have any smaller specific questions. swing is a giant pain in the ass, i have to use it alot lol

  9. #9

    In class atm, then strait to work I might hit you up tomorrow. Thanks for the help

    Update 1: changed to radio buttons and grouped them

    Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import javax.swing.JRadioButton;
    
    
    
    public class KItracker extends JFrame implements ActionListener {
    
    	JRadioButton manticoreMane, wormHusk, adzeWing, fatSkin, aylee, blackmass, meika, spitfyre;
    	JButton addki, removeki, addp, removep ;
    	JLabel me, bm, whitney, mule;
    	JTextField me2, bm2, whitney2, mule2;
    
    	public KItracker() {
    		
    		//Groups the radio buttons for Players and possible KI's
    		ButtonGroup bgroup = new ButtonGroup();
    		ButtonGroup agroup = new ButtonGroup();
    		
    		// Main over all Panel
    		JPanel panel = new JPanel();
            panel.setLayout(new BorderLayout());
    		
    		//Contains Pop items currently held
    		JPanel popList = new JPanel();
    		popList.setLayout(new GridLayout(4,0));
    		
    		//Container for SubPanelB that is converted into the scrollingPane
    		JPanel subPanelA = new JPanel();
    		subPanelA.setLayout(new BorderLayout());
    		
    		//Container for the popList1 and popList 2
    		JPanel subPanelB = new JPanel();
    		subPanelB.setLayout(new BorderLayout());
    		
    		//Contains the JTextArea's used in subPanelB
    		JPanel popList2 = new JPanel();
    		popList2.setLayout(new GridLayout(4,0));
    		
    		//Contains the radio buttons for the possible KI's
    		JPanel kiPanel = new JPanel();
    		kiPanel.setLayout(new GridLayout(4,0));
    		
    		//contains the radio buttons for the possible players
    		JPanel playerPanel = new JPanel();
    		playerPanel.setLayout(new GridLayout(4,0));		
    		
    		//contains all the buttons
    		JPanel buttonPanel = new JPanel();
    		buttonPanel.setLayout(new FlowLayout());
    		
    		//creats the lables for each player used in the Held KI List "used in subPanelB which is used in the scrollPanle"
    		me = new JLabel("Aylee :     ");
    		bm = new JLabel("Blackmass :    ");
    		whitney = new JLabel("Meika :    ");
    		mule = new JLabel("Spitfyre :    ");
    		
    		//creats the  textfields for each player used in the Held KI List "used in subpanelB which is used in the scrollPanle"
    		me2 = new JTextField("");
    		bm2 = new JTextField("");
    		whitney2 = new JTextField("");
    		mule2 = new JTextField("");
    
    		//Radio buttons for all KI's
    		fatSkin = new JRadioButton("Fat-lined Cockatrice Skin");
    		manticoreMane = new JRadioButton("Luxuriant Manticore Mane");
    		wormHusk = new JRadioButton("Sodden Sandworm Husk");
    		adzeWing = new JRadioButton("Sticky Gnat Wing");
    		
    		//Radio buttons for all Players
    		aylee = new JRadioButton("Aylee");
    		blackmass = new JRadioButton("Blackmass");
    		meika = new JRadioButton("Meika");
    		spitfyre = new JRadioButton("Spitfyre");
    		
    		//Groups all KI radio buttons
    		agroup.add(aylee);
    		agroup.add(blackmass);
    		agroup.add(meika);
    		agroup.add(spitfyre);
    		
    		//Groups all player KI buttons
    		bgroup.add(fatSkin);
    		bgroup.add(manticoreMane);
    		bgroup.add(wormHusk);
    		bgroup.add(adzeWing);
    		
    		//Creates the buttons 
    		addki = new JButton("Add KI");
    		addki.addActionListener(this);
    		removeki = new JButton("Remove KI");
    		removeki.addActionListener(this);
    		addp = new JButton("Add Player");
    		addp.addActionListener(this);
    		removep = new JButton("Remove Player");
    		removep.addActionListener(this);
    		
    		//turns subPanelB into a scrollPane
    		JPanel scrollingList = new JPanel(new FlowLayout());
    		JScrollPane sp = new JScrollPane(scrollingList);
    		
    		//Grpups all the JLables in SubPanelA
    		popList.add(me);
    		popList.add(bm);
    		popList.add(whitney);
    		popList.add(mule);
    		
    		//groups all the JTextFields in SubPanelA
    		popList2.add(me2);
    		popList2.add(bm2);
    		popList2.add(whitney2);
    		popList2.add(mule2);
    
    		//Groups the KI radio buttons
    		kiPanel.add(fatSkin);
    		kiPanel.add(manticoreMane);
    		kiPanel.add(wormHusk);
    		kiPanel.add(adzeWing);
    		
    		//Groups the Player Radio buttons
    		playerPanel.add(aylee);
    		playerPanel.add(blackmass);
    		playerPanel.add(meika);
    		playerPanel.add(spitfyre);
    		
    		//Groups the Button Panel
    		buttonPanel.add(addki);
    		buttonPanel.add(removeki);
    		buttonPanel.add(addp);
    		buttonPanel.add(removep);
    		
    		//Adds Popllist (Player Name JLables) and PopList2 (KI held TextArea) to a container
    		subPanelB.add(popList, BorderLayout.WEST);
    		subPanelB.add(popList2, BorderLayout.CENTER);
    		
    		//puts subPanelB in the scrolling list
    		scrollingList.add(subPanelB);
    
    		//Adds all the panels to the main panel
    		panel.add(scrollingList, BorderLayout.NORTH);
    		panel.add(kiPanel, BorderLayout.WEST);
    		panel.add(playerPanel, BorderLayout.EAST);
    		panel.add(buttonPanel, BorderLayout.SOUTH);
    		
    		//adds the main panel
            add(panel);
    
        }
    	
    	public void actionPerformed(ActionEvent e) {
    		if (e.getSource() == addki) {
    			
    		}
    		if (e.getSource() == removeki) {
    			
    		}
    		if (e.getSource() == addp) {
    		
    		}
    		if (e.getSource() == removep) {
    		
    		}
    
    	}
    	
    	public static void main(String[] args) {
            KItracker win = new KItracker();
            win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            win.pack();
            win.setVisible(true);
        }
    }

  10. #10

    Added the new JPanel to the scrollpane and it shows up fine, but doesnt scroll :/

    update 2: started seting up the chart style. Unsure about how to get spacing to make it easier to read while keeping it simi small

    http://i39.photobucket.com/albums/e1...ci720/test.jpg

    Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.util.*;
    import javax.swing.JRadioButton;
    
    
    
    public class KItracker extends JFrame implements ActionListener {
    
    	JRadioButton manticoreMane, wormHusk, adzeWing, fatSkin, aylee, blackmass, meika, spitfyre;
    	JButton addki, removeki, addp, removep ;
    	JLabel me, bm, whitney, mule, manticoreMane2, wormHusk2, adzeWing2, fatSkin2, empty;
    	JTextField me2, bm2, whitney2, mule2;
    	
    
    	public KItracker() {
    		
    		//Groups the radio buttons for Players and possible KI's
    		ButtonGroup bgroup = new ButtonGroup();
    		ButtonGroup agroup = new ButtonGroup();
    		
    		// Main over all Panel
    		JPanel panel = new JPanel();
            panel.setLayout(new BorderLayout());
    		
    		//Contains Pop items currently held
    		JPanel popList = new JPanel();
    		popList.setLayout(new GridLayout(4,0));
    		
    		//Container for SubPanelB that is converted into the scrollingPane
    		JPanel subPanelA = new JPanel();
    		subPanelA.setLayout(new BorderLayout());
    		
    		//Container for the popList1 and popList 2
    		JPanel subPanelB = new JPanel();
    		subPanelB.setLayout(new BorderLayout());
    		
    		//Contains the JTextField's used in subPanelB
    		JPanel popList2 = new JPanel();
    		popList2.setLayout(new GridLayout(4,0));
    		
    		//Contains the radio buttons for the possible KI's
    		JPanel kiPanel = new JPanel();
    		kiPanel.setLayout(new GridLayout(4,0));
    		
    		//contains the radio buttons for the possible players
    		JPanel playerPanel = new JPanel();
    		playerPanel.setLayout(new GridLayout(4,0));		
    		
    		//contains all the buttons
    		JPanel buttonPanel = new JPanel();
    		buttonPanel.setLayout(new FlowLayout());
    		
    		//Groups all KI lables
    		JPanel kilabel = new JPanel();
    		kilabel.setLayout(new FlowLayout());
    		
    		
    		//creats the lables for each player used in the Held KI List "used in subPanelB which is used in the scrollPanle"
    		me = new JLabel("Aylee :     ");
    		bm = new JLabel("Blackmass :    ");
    		whitney = new JLabel("Meika :    ");
    		mule = new JLabel("Spitfyre :    ");
    		
    		//creats the  textfields for each player used in the Held KI List "used in subpanelB which is used in the scrollPanle"
    		me2 = new JTextField("");
    		bm2 = new JTextField("");
    		whitney2 = new JTextField("");
    		mule2 = new JTextField("");
    		
    		//JLables for all the KI's
    		empty = new JLabel("                        ");
    		fatSkin2 = new JLabel("Fat-Lined Cockatrice Skin");
    		manticoreMane2 = new JLabel("Luxuriant Manticore Mane");
    		wormHusk2 = new JLabel("Sodden Sandworm Husk");
    		adzeWing2 = new JLabel("Sticky Gnat Wing");
    
    		//Radio buttons for all KI's
    		fatSkin = new JRadioButton("Fat-lined Cockatrice Skin");
    		manticoreMane = new JRadioButton("Luxuriant Manticore Mane");
    		wormHusk = new JRadioButton("Sodden Sandworm Husk");
    		adzeWing = new JRadioButton("Sticky Gnat Wing");
    		
    		//Radio buttons for all Players
    		aylee = new JRadioButton("Aylee");
    		blackmass = new JRadioButton("Blackmass");
    		meika = new JRadioButton("Meika");
    		spitfyre = new JRadioButton("Spitfyre");
    		
    		//Groups all KI radio buttons
    		agroup.add(aylee);
    		agroup.add(blackmass);
    		agroup.add(meika);
    		agroup.add(spitfyre);
    		
    		//Groups all player KI buttons
    		bgroup.add(fatSkin);
    		bgroup.add(manticoreMane);
    		bgroup.add(wormHusk);
    		bgroup.add(adzeWing);
    		
    		//adds the ki lables to the container
    		kilabel.add(empty);
    		kilabel.add(fatSkin2);
    		kilabel.add(manticoreMane2);
    		kilabel.add(wormHusk2);
    		kilabel.add(adzeWing2);
    		
    		//Creates the buttons 
    		addki = new JButton("Add KI");
    		addki.addActionListener(this);
    		removeki = new JButton("Remove KI");
    		removeki.addActionListener(this);
    		addp = new JButton("Add Player");
    		addp.addActionListener(this);
    		removep = new JButton("Remove Player");
    		removep.addActionListener(this);
    		
    		//turns subPanelB into a scrollPane
    		JPanel scrollingList = new JPanel(new FlowLayout());
    		JScrollPane sp = new JScrollPane(scrollingList);
    		
    		//Grpups all the JLables in SubPanelA
    		popList.add(me);
    		popList.add(bm);
    		popList.add(whitney);
    		popList.add(mule);
    		
    		//groups all the JTextFields in SubPanelA
    		popList2.add(me2);
    		popList2.add(bm2);
    		popList2.add(whitney2);
    		popList2.add(mule2);
    
    		//Groups the KI radio buttons
    		kiPanel.add(fatSkin);
    		kiPanel.add(manticoreMane);
    		kiPanel.add(wormHusk);
    		kiPanel.add(adzeWing);
    		
    		//Groups the Player Radio buttons
    		playerPanel.add(aylee);
    		playerPanel.add(blackmass);
    		playerPanel.add(meika);
    		playerPanel.add(spitfyre);
    		
    		//Groups the Button Panel
    		buttonPanel.add(addki);
    		buttonPanel.add(removeki);
    		buttonPanel.add(addp);
    		buttonPanel.add(removep);
    		
    		//Adds Popllist (Player Name JLables) and PopList2 (KI held TextArea) to a container
    		subPanelB.add(kilabel, BorderLayout.NORTH);
    		subPanelB.add(popList, BorderLayout.WEST);
    		subPanelB.add(popList2, BorderLayout.CENTER);
    		
    		//puts subPanelB in the scrolling list
    		scrollingList.add(subPanelB);
    
    		//Adds all the panels to the main panel
    		panel.add(scrollingList, BorderLayout.NORTH);
    		panel.add(kiPanel, BorderLayout.WEST);
    		panel.add(playerPanel, BorderLayout.EAST);
    		panel.add(buttonPanel, BorderLayout.SOUTH);
    		
    		//adds the main panel
            add(panel);
    
        }
    	
    	public void actionPerformed(ActionEvent e) {
    		if (e.getSource() == addki) {
    			
    		}
    		if (e.getSource() == removeki) {
    			
    		}
    		if (e.getSource() == addp) {
    		
    		}
    		if (e.getSource() == removep) {
    		
    		}
    
    	}
    	
    	public static void main(String[] args) {
            KItracker win = new KItracker();
            win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            win.pack();
            win.setVisible(true);
        }
    }

  11. #11
    The Wang
    Join Date
    Jun 2006
    Posts
    1,345
    BG Level
    6
    FFXIV Character
    Furt Wangler
    FFXIV Server
    Coeurl
    FFXI Server
    Sylph

    Hang on for one sec, I have some code i wrote up that should fix part of your problem and set you on the right path to keep going, I'll post in 5mins

    edit: hm, didnt see that you can only have 1 or none, in that case I'd change things a bit. I'd keep the items on the left to check boxes, that way you can check what you want to add, or remove, then click the button for whatever player. Let me see what I can change with what I have here.

  12. #12
    The Wang
    Join Date
    Jun 2006
    Posts
    1,345
    BG Level
    6
    FFXIV Character
    Furt Wangler
    FFXIV Server
    Coeurl
    FFXI Server
    Sylph

    This is what I have so far, and I've run out of time to continue for tonight.

    Here's what I changed :

    1. Each button has its own listener, defined in a subclass at the bottom. Same idea as what you had but more readable and technically more efficient since there is no checking going on when you click a button.

    2. I figured a JTable is best to use since we know what we want for each column. If you don't like it you can go back to what you had but this made sense to me.

    3. Both the table and buttons for players are scrollable, this supports adding or removing players

    4. I made methods that populate the tables, and buttons, based on a dummy arraylist of data. I did this because you will have to call methods when the program runs to update the list, and these will work for that. the methods look at the current arraylist, and populate based on that. As long as you make sure that ArrayList is updated before you call those methods, that will update your shit.

    5. I commented stuff I think you won't understand. I'm out of time to comment anything else so hopefully you can trace anything you aren't sure of.

    I just realized you could actually edit a JTable for the values to change and not even have to use add/remove buttons, but you may not want to do that, and may want to just use the table as informational, in which case this is fine. I disabled being able to edit the table by clicking.

    Hope this helped!

    Code:
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.ArrayList;
    
    import javax.swing.BoxLayout;
    import javax.swing.ButtonGroup;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JRadioButton;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    import javax.swing.table.DefaultTableModel;
    
    public class ScrollTest extends JFrame {
    
    	JRadioButton manticoreMane, wormHusk, adzeWing, fatSkin;
    	JButton addki, removeki, addp, removep ;
    	
    	JPanel topPanel;
    	JPanel playerPanel;
    	
    	ButtonGroup kIButtonGroup;
    	ButtonGroup playerButtonGroup;
    	
    	AddKIListener addKI;
    	RemoveKIListener removeKI;
    	AddPlayerListener addPlayer;
    	RemovePlayerListener removePlayer;
    	
    	ArrayList<String[]> dummyData;
    	
    	DefaultTableModel playerDataModel;
    	JTable playerDataTable;
    	String[] tableNames;
    
    	public ScrollTest() {
    	                      
    	                       
    	                        
    	    //making some dummy data. This will come from your other class that reads in the file/maintains an updated list.                     
    	    String[] ayleeSt = {"Aylee","1","0","0","1"};
    	    String[] blackmassSt = {"Blackmass","0","0","1","1"};
    	    String[] meikaSt = {"Meika","1","1","1","1"};
    	    String[] spitfyreSt = {"Spitfyre","1","1","0","0"};
    		
    	    dummyData = new ArrayList<String[]>();
    		dummyData.add(ayleeSt);
    		dummyData.add(blackmassSt);
    		dummyData.add(meikaSt);
    		dummyData.add(spitfyreSt);
    		
    		
    		addKI = new AddKIListener();
    		removeKI = new RemoveKIListener();
    		addPlayer = new AddPlayerListener();
    		removePlayer = new RemovePlayerListener();
    		
    		kIButtonGroup = new ButtonGroup();
    		playerButtonGroup = new ButtonGroup();
    		
    		playerPanel = new JPanel();
    		playerPanel.setLayout(new BoxLayout(playerPanel,BoxLayout.Y_AXIS));
    		JScrollPane playerPanelScrollPane = new JScrollPane(playerPanel);
    		playerPanelScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    		playerPanelScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    
    		topPanel = new JPanel();
    		
    		this.setLayout(new BorderLayout());
    		
    		
    		
    		JPanel blank = new JPanel();
    		blank.setLayout(new FlowLayout());
    		
    		JPanel blank2 = new JPanel();
    		blank2.setLayout(new GridLayout(2,0));
    		
    		JPanel subPanelA = new JPanel();
    		subPanelA.setLayout(new BorderLayout());
    		
    		JPanel subPanelB = new JPanel();
    		subPanelB.setLayout(new BorderLayout());
    		
    		JPanel popList2 = new JPanel();
    		popList2.setLayout(new GridLayout(4,0));
    		
    		JPanel kiPanel = new JPanel();
    		kiPanel.setLayout(new GridLayout(4,0));
    
    		JPanel buttonPanel = new JPanel();
    		buttonPanel.setLayout(new FlowLayout());
    		
    		
    		
    		tableNames = new String[] {"Player Name",
    								"Fat-lined Cockatrice Skin",
    								"Luxuriant Manticore Mane",
    								"Sodden Sandworm Husk",
    								"Sticky Gnat Wing"};
    		
    		//Populate the table!
    		drawPlayerTable();
    		
    		//stick the table in a scroller
    		JScrollPane tableScroller = new JScrollPane(playerDataTable);
    		tableScroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    		tableScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    		
    
    		
    		fatSkin = new JRadioButton("Fat-lined Cockatrice Skin");
    		manticoreMane = new JRadioButton("Luxuriant Manticore Mane");
    		wormHusk = new JRadioButton("Sodden Sandworm Husk");
    		adzeWing = new JRadioButton("Sticky Gnat Wing");
    		
    		
    		kIButtonGroup.add(fatSkin);
    		kIButtonGroup.add(manticoreMane);
    		kIButtonGroup.add(wormHusk);
    		kIButtonGroup.add(adzeWing);
    		
    		addki = new JButton("Add KI");
    		addki.addActionListener(addKI);
    		removeki = new JButton("Remove KI");
    		removeki.addActionListener(removeKI);
    		addp = new JButton("Add Player");
    		addp.addActionListener(addPlayer);
    		removep = new JButton("Remove Player");
    		removep.addActionListener(removePlayer);
    		
    		addPlayerRadioButtons();
    		
    
    		kiPanel.add(fatSkin);
    		kiPanel.add(manticoreMane);
    		kiPanel.add(wormHusk);
    		kiPanel.add(adzeWing);
    		
    
    		
    		buttonPanel.add(addki);
    		buttonPanel.add(removeki);
    		buttonPanel.add(addp);
    		buttonPanel.add(removep);
    						
    		
    		this.add(tableScroller, BorderLayout.NORTH);
    		this.add(kiPanel, BorderLayout.WEST);
    		//this.add(blank, BorderLayout.CENTER);
    		this.add(playerPanelScrollPane, BorderLayout.EAST);
    		this.add(buttonPanel, BorderLayout.SOUTH);
    		
    		
        }
    	
    	
    	private class AddKIListener implements ActionListener{
    
    		public void actionPerformed(ActionEvent arg0) {
    			// TODO Auto-generated method stub
    			
    		}
    		
    	}
    	
    	private class RemoveKIListener implements ActionListener{
    
    		public void actionPerformed(ActionEvent e) {
    			// TODO Auto-generated method stub
    			
    		}
    		
    	}
    	
    	private class AddPlayerListener implements ActionListener{
    
    		public void actionPerformed(ActionEvent e) {
    			// TODO Auto-generated method stub
    			
    		}
    		
    	}
    	
    	private class RemovePlayerListener implements ActionListener{
    
    		public void actionPerformed(ActionEvent e) {
    			// TODO Auto-generated method stub
    			
    		}
    		
    	}
    	
    	/**
    	 * Creates the buttons for players.
    	 */
    	private void addPlayerRadioButtons(){
    		for(String[] eachPlayer : dummyData){
    			System.out.println(eachPlayer[0]);
    			JRadioButton playerButton = new JRadioButton(eachPlayer[0]);
    			playerButtonGroup.add(playerButton);
    			playerPanel.add(playerButton);
    		}
    	}
    	
    	
    	/**
    	 * Creates the table for the players and their items.
    	 */
    	private void drawPlayerTable(){
    		String [][] dummyDataAry =  new String[dummyData.size()][5];
    		int row = 0;
    		for(String[] eachPlayer : dummyData){
    			dummyDataAry[row][0] = dummyData.get(row)[0];
    			dummyDataAry[row][1] = dummyData.get(row)[1];
    			dummyDataAry[row][2] = dummyData.get(row)[2];
    			dummyDataAry[row][3] = dummyData.get(row)[3];
    			dummyDataAry[row][4] = dummyData.get(row)[4];
    			row++;
    		}
    		playerDataModel = new DefaultTableModel(dummyDataAry,tableNames);
    		playerDataTable = new JTable(playerDataModel){
    			public boolean isCellEditable(int rowIndex, int colIndex){
    				return false;
    			}
    		};
    	}
    	
    	
    	
    	
    	public static void main(String[] args) {
           ScrollTest win = new ScrollTest();
            win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            win.pack();
            win.setVisible(true);
        }
    }

  13. #13

    Awesome tyvm u went above and beyond. I'm going to start working on it and trying to pretty it up. Also a few more things to keep in mind.

    Atm im just trying to get a working program with glavoid. It would be nice not to have everything hard coded like I have it set up now. I would like to have a drop down menu with multiple NM names such as barbiarus, sobek, chloirs, ext and when the user selects one the table updates (who has what KI, and the name of the KI's) and the check boxes update with the respective Key items that are addable / removable from the list. this shouldent be this bad i was just planing to use diffrent txt files depending on the selected NM. But at the moment I just want it to work for glavoid. Then spice it up a little.

    So al that is really left of just geting glavoid done is to implement the listeners to write the selected choices to a text file, populate the list from the text file. The bigest thing is going to be geting the list to update after each change.

  14. #14
    The Wang
    Join Date
    Jun 2006
    Posts
    1,345
    BG Level
    6
    FFXIV Character
    Furt Wangler
    FFXIV Server
    Coeurl
    FFXI Server
    Sylph

    that will actually be easy. You know from the buttons selected what the requested change will be. You call a method in your class that holds the database like .add(playername,item) or .remove(playername,item) (both these will check if you already have it and if so do nothing), and then after the action listener calls that, call a method from the database like .getList() that returns that arrayList, set it = to the one you have stored, and then just call the populate players method and it will the data from that list. The only thing not really implemented is adding a player, in which case you need a 3rd method in your database class like .add(player) where it makes another array in the data arraylist with 0'd values for everything but name. then call the create buttons method already there to re-add buttons.

  15. #15

    Will also need to make a pop up asking for the new users name when adding a player, but i'll get to that later. Am i doing the buttons right?

    I figured i would need to set new variables so it know which KI is selected and which player, but im kinda of confused how you did the radio buttons for the players using the tables, im not really good with them.

    Code:
    		private class AddKIListener implements ActionListener{
    
    		public void actionPerformed(ActionEvent arg0) {
    			String selection = "";
    			String player = "";
    			if(fatSkin.isSelected()) {
    				selection = "Fat-lined Cockatrice Skin";
    			}
    			else if(manticoreMane.isSelected()) {
    				selection = "Luxuriant Manticore Mane";
    			}
    			else if(wormHusk.isSelected()) {
    				selection = "Sodden Sandworm Husk";
    			}
    			else if(adzeWing.isSelected()) {
    				selection = "Sticky Gnat Wing";
    			}
    			
    			//add methods to find which player is selected
    			
    			// print to the file the selected KI for the selected player
    		}
    		
    	}
    Gonna head to bed for the night and work on it tomorrow i'm off all day. Heres what i got so far.

    Update:

    -Started working on KI add/remove actionlisteners
    - Now writes to glavoidPlayer.txt when add player is added (I think the list should atuo update its self the way its wrote sence its rewriting the file each time.
    - JOptionPane now pops up when hitting add Player
    - saves added players name to txt file (currently overwrites need to fix to simply add)


    Code:
    import java.awt.BorderLayout;
    import java.awt.Dimension;
    import java.awt.FlowLayout;
    import java.awt.GridLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.util.ArrayList;
    
    import javax.swing.BoxLayout;
    import javax.swing.ButtonGroup;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JRadioButton;
    import javax.swing.JScrollPane;
    import javax.swing.JTable;
    import javax.swing.JTextField;
    import javax.swing.table.DefaultTableModel;
    import java.io.*;
    import javax.swing.JOptionPane;
    
    public class KItracker extends JFrame {
    
    	JRadioButton manticoreMane, wormHusk, adzeWing, fatSkin;
    	JButton addki, removeki, addp, removep ;
    	
    	JPanel topPanel;
    	JPanel playerPanel;
    	
    	ButtonGroup kIButtonGroup;
    	ButtonGroup playerButtonGroup;
    	
    	AddKIListener addKI;
    	RemoveKIListener removeKI;
    	AddPlayerListener addPlayer;
    	RemovePlayerListener removePlayer;
    	
    	ArrayList<String[]> dummyData;
    	
    	DefaultTableModel playerDataModel;
    	JTable playerDataTable;
    	String[] tableNames;
    
    	public KItracker() {
    	                                             
    	    //making some dummy data. This will come from your other class that reads in the file/maintains an updated list.                     
    	    String[] ayleeSt = {"Aylee","0","0","0","0"};
    	    String[] blackmassSt = {"Blackmass","0","0","0","0"};
    	    String[] meikaSt = {"Meika","0","0","0","0"};
    	    String[] spitfyreSt = {"Spitfyre","0","0","0","0"};
    		
    	    dummyData = new ArrayList<String[]>();
    		dummyData.add(ayleeSt);
    		dummyData.add(blackmassSt);
    		dummyData.add(meikaSt);
    		dummyData.add(spitfyreSt);
    		
    		
    		addKI = new AddKIListener();
    		removeKI = new RemoveKIListener();
    		addPlayer = new AddPlayerListener();
    		removePlayer = new RemovePlayerListener();
    		
    		kIButtonGroup = new ButtonGroup();
    		playerButtonGroup = new ButtonGroup();
    		
    		playerPanel = new JPanel();
    		playerPanel.setLayout(new BoxLayout(playerPanel,BoxLayout.Y_AXIS));
    		JScrollPane playerPanelScrollPane = new JScrollPane(playerPanel);
    		playerPanelScrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    		playerPanelScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    
    		topPanel = new JPanel();
    		
    		this.setLayout(new BorderLayout());
    		
    		
    		
    		JPanel blank = new JPanel();
    		blank.setLayout(new FlowLayout());
    		
    		JPanel blank2 = new JPanel();
    		blank2.setLayout(new GridLayout(2,0));
    		
    		JPanel subPanelA = new JPanel();
    		subPanelA.setLayout(new BorderLayout());
    		
    		JPanel subPanelB = new JPanel();
    		subPanelB.setLayout(new BorderLayout());
    		
    		JPanel popList2 = new JPanel();
    		popList2.setLayout(new GridLayout(4,0));
    		
    		JPanel kiPanel = new JPanel();
    		kiPanel.setLayout(new GridLayout(4,0));
    
    		JPanel buttonPanel = new JPanel();
    		buttonPanel.setLayout(new FlowLayout());
    		
    		
    		
    		tableNames = new String[] {"Player Name",
    								"Fat-lined Cockatrice Skin",
    								"Luxuriant Manticore Mane",
    								"Sodden Sandworm Husk",
    								"Sticky Gnat Wing"};
    		
    		//Populate the table!
    		drawPlayerTable();
    		
    		//stick the table in a scroller
    		JScrollPane tableScroller = new JScrollPane(playerDataTable);
    		tableScroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    		tableScroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    		
    
    		
    		fatSkin = new JRadioButton("Fat-lined Cockatrice Skin", true);
    		manticoreMane = new JRadioButton("Luxuriant Manticore Mane", false);
    		wormHusk = new JRadioButton("Sodden Sandworm Husk", false);
    		adzeWing = new JRadioButton("Sticky Gnat Wing", false);
    		
    		
    		kIButtonGroup.add(fatSkin);
    		kIButtonGroup.add(manticoreMane);
    		kIButtonGroup.add(wormHusk);
    		kIButtonGroup.add(adzeWing);
    		
    		addki = new JButton("Add KI");
    		addki.addActionListener(addKI);
    		removeki = new JButton("Remove KI");
    		removeki.addActionListener(removeKI);
    		addp = new JButton("Add Player");
    		addp.addActionListener(addPlayer);
    		removep = new JButton("Remove Player");
    		removep.addActionListener(removePlayer);
    		
    		addPlayerRadioButtons();
    		
    
    		kiPanel.add(fatSkin);
    		kiPanel.add(manticoreMane);
    		kiPanel.add(wormHusk);
    		kiPanel.add(adzeWing);
    		
    		buttonPanel.add(addki);
    		buttonPanel.add(removeki);
    		buttonPanel.add(addp);
    		buttonPanel.add(removep);
    						
    		
    		this.add(tableScroller, BorderLayout.NORTH);
    		this.add(kiPanel, BorderLayout.WEST);
    		//this.add(blank, BorderLayout.CENTER);
    		this.add(playerPanelScrollPane, BorderLayout.EAST);
    		this.add(buttonPanel, BorderLayout.SOUTH);
    		
    		
        }
    	
    	
    	private class AddKIListener implements ActionListener{
    
    		public void actionPerformed(ActionEvent arg0) {
    			String selection = "";
    			String player = "";
    			if(fatSkin.isSelected()) {
    				selection = "Fat-lined Cockatrice Skin";
    			}
    			else if(manticoreMane.isSelected()) {
    				selection = "Luxuriant Manticore Mane";
    			}
    			else if(wormHusk.isSelected()) {
    				selection = "Sodden Sandworm Husk";
    			}
    			else if(adzeWing.isSelected()) {
    				selection = "Sticky Gnat Wing";
    			}
    			
    			//add methods to find which player is selected
    			
    			// print to the file the selected KI for the selected player
    		}
    		
    	}
    	
    	private class RemoveKIListener implements ActionListener{
    
    		public void actionPerformed(ActionEvent e) {
    			String selection = "";
    			if(fatSkin.isSelected()) {  
    				selection = "Luxuriant Manticore Mane";
    			}
    			else if(manticoreMane.isSelected()) {
    				selection = "Luxuriant Manticore Mane";
    			}
    			else if(wormHusk.isSelected()) {
    				selection = "Sodden Sandworm Husk";
    			}
    			else if(adzeWing.isSelected()) {
    				selection = "Sodden Sandworm Husk";
    			}
    		}
    		
    	}
    	
    	private class AddPlayerListener implements ActionListener{
    
    		public void actionPerformed(ActionEvent event) {
    			String chrName = JOptionPane.showInputDialog("Character Name :");
    			
    			try{
    				FileWriter fstream = new FileWriter("glavoidPlayers.txt");
    				BufferedWriter out = new BufferedWriter(fstream);
    				out.write(chrName);
    				out.close();
    			}
    			catch (Exception e){//Catch exception if any
    				System.err.println("Error: " + e.getMessage());
    			}
    		}
    	}
    	
    	private class RemovePlayerListener implements ActionListener{
    
    		public void actionPerformed(ActionEvent e) {
    			// TODO Auto-generated method stub
    			
    		}
    		
    	}
    	
    	/**
    	 * Creates the buttons for players.
    	 */
    	private void addPlayerRadioButtons(){
    		for(String[] eachPlayer : dummyData){
    			System.out.println(eachPlayer[0]);
    			JRadioButton playerButton = new JRadioButton(eachPlayer[0]);
    			playerButtonGroup.add(playerButton);
    			playerPanel.add(playerButton);
    		}
    	}
    	
    	
    	/**
    	 * Creates the table for the players and their items.
    	 */
    	private void drawPlayerTable(){
    		String [][] dummyDataAry =  new String[dummyData.size()][5];
    		int row = 0;
    		for(String[] eachPlayer : dummyData){
    			dummyDataAry[row][0] = dummyData.get(row)[0];
    			dummyDataAry[row][1] = dummyData.get(row)[1];
    			dummyDataAry[row][2] = dummyData.get(row)[2];
    			dummyDataAry[row][3] = dummyData.get(row)[3];
    			dummyDataAry[row][4] = dummyData.get(row)[4];
    			row++;
    		}
    		playerDataModel = new DefaultTableModel(dummyDataAry,tableNames);
    		playerDataTable = new JTable(playerDataModel){
    			public boolean isCellEditable(int rowIndex, int colIndex){
    				return false;
    			}
    		};
    	}
    	
    	
    	
    	
    	public static void main(String[] args) {
           KItracker win = new KItracker();
            win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            win.pack();
            win.setVisible(true);
        }
    }

  16. #16
    Banned.

    Join Date
    Mar 2011
    Posts
    11
    BG Level
    1

    well done. so good job, brah.

  17. #17

    Ok looking over it this morning im kind of clueless on the actionlisteners for add/remove KI. The KI part is easy, just planed on finding assigning it a variable, then finding the player (this is where im lost) then adding both the the file (still working on that part). But i have no clue how to find the user that is.

  18. #18
    The Wang
    Join Date
    Jun 2006
    Posts
    1,345
    BG Level
    6
    FFXIV Character
    Furt Wangler
    FFXIV Server
    Coeurl
    FFXI Server
    Sylph

    so you want to know how to access what player is currently selected? the button group is a global variable, you can say group.getSelection() and it will return the model of whatever button is currently selected.

  19. #19
    Banned.

    Join Date
    Jul 2005
    Posts
    5,836
    BG Level
    8
    FFXI Server
    Sylph
    WoW Realm
    Arthas

    Good job, I like the style of community programs like this.

  20. #20

    Quote Originally Posted by Furtwangler View Post
    so you want to know how to access what player is currently selected? the button group is a global variable, you can say group.getSelection() and it will return the model of whatever button is currently selected.
    Awesome thank you, I dont have time to work on it today/tomorrow due to school/work but I'll post something when i get stuck again.

Similar Threads

  1. Programming help
    By Lost in forum Tech
    Replies: 13
    Last Post: 2012-02-28, 09:28
  2. Programming help
    By Bloodfire in forum Tech
    Replies: 15
    Last Post: 2011-04-07, 16:40
  3. Beginner Programming Help Thread
    By Callisto in forum Tech
    Replies: 13
    Last Post: 2011-03-04, 18:24
  4. Java Code help
    By Skie in forum Tech
    Replies: 11
    Last Post: 2010-10-11, 14:37
  5. java program.
    By Skie in forum Tech
    Replies: 11
    Last Post: 2010-09-19, 15:20
  6. Replies: 8
    Last Post: 2010-02-20, 01:21