Results 1 to 19 of 19
  1. #1
    Mokomi is offline Member
    Join Date
    May 2011
    Posts
    32
    Rep Power
    0

    Default Creating Party Windows.

    Hello! currently i'm trying convert a DND style game from excel to a java program. I'm doing this to have it more easily played with friends. and an excuse to learn java. I'm currently stuck at making party windows. I cannot seem to come with a solution. My own solution has problems for the future.
    If you know of a better format by all means please for the love of all direct me. but my goal is to get the correct number of parties. and the correct number of members in each party. I would really like make an add party and an add member button. but one step at a time.

    the future problem I have I don't have a way to read each party member. once I pick the party members I do not have a way to read which ones I picked.


    Java Code:
    private class play implements ActionListener{
    	
    	String[] member = new String[0];
    	String[] parties = new String[0];
    	//created the parties and the largest party.  if a party has 2 and another has 3. the party of 2 has a null.
    	public void actionPerformed(ActionEvent event){
    		reseting();
    	//removing the old menu
    		int counter =0;
    	while(counter == 0)
    		try{
    			//goings into reciving the number of parties and the largest party.
    		String fn = JOptionPane.showInputDialog("Enter the Number of Parties. (Numbers only will work");
    		int gs = Integer.parseInt(fn);
    		parties = new String[gs];
    		fn = JOptionPane.showInputDialog("Enter the largest party number");
    		gs = Integer.parseInt(fn);
    		member = new String[gs];
    	
    		counter =1;
    			}
    		catch(Exception e){JOptionPane.showMessageDialog(null,"Invalid Input (Numbers only!!)","FALIURE",JOptionPane.PLAIN_MESSAGE);
    }
    		
    			
    		String fn=null;
    		
    
    		try{
    			//lists.txt has all the Main charater names.
    			Scanner x = new Scanner(new File("lists.txt"));
    		counter = 0;
    		//in the .txt the first line is the number of main charaters
    		
    			x=new Scanner(new File("Lists.txt"));
    			fn = x.next();
    			counter = Integer.parseInt(fn);
    			everyone=new String[counter];
    			counter=0;
    			//while is to get all of the main charater names.
    			while(x.hasNext()){
    			
    				String fake = x.next();
    			everyone[counter]=fake;
    			counter++;
    			System.out.println(counter+" fake");
    			}	x.close();	
    	}catch (FileNotFoundException e) {
    		System.out.println("Error tuna 293");
    		// TODO Auto-generated catch block
    		e.printStackTrace();
    	}
    	//now to make the party windows.
    counter =0;
    int counter2 = 0;
    //makes the total number of parties.
    		while(counter<parties.length){
    counter++;boolean s =false;
    while(s==false){
    	//for each party you make a name
    	 fn = JOptionPane.showInputDialog("Party "+ counter+1 +"'s name?");
    
    	String yes = JOptionPane.showInputDialog("Is "+fn+" Correct? Y Or N only please");
    	//this part works. where you create a new window for each seperate party.
    	if(yes.equalsIgnoreCase("y")){
    		s=true;
    		JFrame q = new JFrame(fn);
    		q.setVisible(true);
    		q.setSize(300,200);
    //yes I know about 	q.repaint(); for w/e reason it doesn't refresh like resizing does.
    		while(counter2<member.length){
    			pick = new JComboBox(everyone);
    	//this is only added once.  I need it added for every member.
    			q.add(pick);
    			counter2++;
    		q.repaint();
    		}
    		q.setSize(300,200);
    	}
    }
    	
    	
    			
    	
    
    	} }
    		
    	}

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default Re: Creating Party Windows.

    I'm currently stuck at making party windows
    Can you explain what a "party" window is and how it differs from the window created by the JFrame class?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Mokomi is offline Member
    Join Date
    May 2011
    Posts
    32
    Rep Power
    0

    Default Re: Creating Party Windows.

    (hit reply to thread after answering instead of quick reply >.> )
    o yes, they are basicly the same thing. here is a picture.
    Attachment 3875
    I call them for what they will be. party windows. but i'm using JFrame.
    The bottom half of my code is making the parties then entering members for each party.
    The future problem comes in when I do not know to get java to read my answers from the JComboBox's.

    (In the example picture I have two parties. party 1 and party awesome. the max number of parties I choose was 2 with 2 members in each JFrame. it only added one JComboBox in the first JFrame. instead of 2 JComboBox's in all JFrame's)
    why do I have two pictures?
    Attached Thumbnails Attached Thumbnails Creating Party Windows.-party.png  
    Last edited by Mokomi; 06-20-2012 at 09:53 PM. Reason: I can't see the fact I have two of the same pictures 0o.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default Re: Creating Party Windows.

    Do you have a question about how to create JFrame objects?

    What is your problem about getting data from a JComboBox?
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Mokomi is offline Member
    Join Date
    May 2011
    Posts
    32
    Rep Power
    0

    Default Re: Creating Party Windows.

    In the example picture I have two parties. party 1 and party awesome. the max number of parties I choose was 2 with 2 members in each JFrame. it only added one JComboBox in the first JFrame. instead of 2 JComboBox's in all JFrame's.
    yes I do. why is it covering the entire JFrame. How would someone place infinte JComboBox's and still be able to record what a person places in each JComboBox.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default Re: Creating Party Windows.

    Can you make a small simple program that compiles, executes and shows the problem. The code you posted looks a mess.
    You are trying to do too many things in an actionPerformed method.
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    Mokomi is offline Member
    Join Date
    May 2011
    Posts
    32
    Rep Power
    0

    Default Re: Creating Party Windows.

    here is the code. yes a lot of things are repeated. but with a simple

    Java Code:
    		fling C = new fling();
    		C.test();
    is needed to run it.

    Java Code:
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    import java.lang.reflect.Type;
    import java.util.Locale;
    import static java.lang.System.out;
    import static java.lang.System.err;
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    import java.util.Arrays;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.AdjustmentEvent;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.util.Scanner;
    import java.util.Scanner;
    
    import javax.swing.*;
    import javax.swing.JFrame;
    
    
    public class fling extends JFrame{
    	public void test(){
    String[] everyone = new String[0];
    		String[] member = new String[0];
    		String[] parties = new String[0];
    		JComboBox pick;
    			int counter =0;
    		while(counter == 0)
    			try{
    				//goings into reciving the number of parties and the largest party.
    			String fn = JOptionPane.showInputDialog("Enter the Number of Parties. (Numbers only will work");
    			int gs = Integer.parseInt(fn);
    			parties = new String[gs];
    			fn = JOptionPane.showInputDialog("Enter the largest party number");
    			gs = Integer.parseInt(fn);
    			member = new String[gs];
    		
    			counter =1;
    				}
    			catch(Exception e){JOptionPane.showMessageDialog(null,"Invalid Input (Numbers only!!)","FALIURE",JOptionPane.PLAIN_MESSAGE);
    	}
    			
    				
    			String fn=null;
    			
    //this right here is getting files. but i'm going to change it after the catch.
    	//********Important******		
    			//it is also going to be an error due to no file exist.
    			try{
    				//lists.txt has all the Main charater names.
    				Scanner x = new Scanner(new File("lists.txt"));
    			counter = 0;
    			//in the .txt the first line is the number of main charaters
    			
    				x=new Scanner(new File("Lists.txt"));
    				fn = x.next();
    				counter = Integer.parseInt(fn);
    				counter=counter+1;
    				everyone=new String[counter];
    				counter=0;
    				//while is to get all of the main charater names.
    				while(x.hasNext()){
    				
    					String fake = x.next();
    				everyone[counter]=fake;
    				counter++;
    				System.out.println(counter+" fake");
    				}	x.close();	
    		}catch (FileNotFoundException e) {
    			System.out.println("!!IGNORE ME!!  THIS MEANS IT IS WORKING!");
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    		//done. the next line is to remake the current file
    		//****important******
    	String[]	everyonetest = {"Olivia","Roton","Presti","Zren","demi",null};
    		
    		//now to make the party windows.
    	counter =0;
    	int counter2 = 0;
    	//makes the total number of parties.
    			while(counter<parties.length){
    	counter++;boolean s =false;
    	while(s==false){
    		//for each party you make a name
    		 fn = JOptionPane.showInputDialog("Party "+ counter+1 +"'s name?");
    
    		String yes = JOptionPane.showInputDialog("Is "+fn+" Correct? Y Or N only please");
    		//this part works. where you create a new window for each seperate party.
    		if(yes.equalsIgnoreCase("y")){
    			s=true;
    			JFrame q = new JFrame(fn);
    			q.setVisible(true);
    			q.setSize(300,200);
    	//yes I know about 	q.repaint(); for w/e reason it doesn't refresh like resizing does.
    			while(counter2<member.length){
    				//using the fake file
    				pick = new JComboBox(everyonetest);
    		//this is only added once.  I need it added for every member.
    				q.add(pick);
    				counter2++;
    			q.repaint();
    			}
    			q.setSize(300,200);
    		
    
    
    	}
    
    	}}}
    		}

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default Re: Creating Party Windows.

    If it is so simple, add a main() method to make it easier for any one to test without requiring their work. Also put the contents of the file in the program so everything is in one place for testing.

    Can you explain what your problem(s) is?
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    Mokomi is offline Member
    Join Date
    May 2011
    Posts
    32
    Rep Power
    0

    Default Re: Creating Party Windows.

    ok. sorry i couldn't get main(String[] args) to work with extends JFrame. I have it now.
    with the unedited code.



    Java Code:
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    import java.lang.reflect.Type;
    import java.util.Locale;
    import static java.lang.System.out;
    import static java.lang.System.err;
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    import java.util.Arrays;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.AdjustmentEvent;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.util.Scanner;
    import java.util.Scanner;
    
    import javax.swing.*;
    
    public class bucky  extends JFrame{
    	public static void main(String[] args){
    String[] everyone = new String[0];
    		String[] member = new String[0];
    		String[] parties = new String[0];
    		JComboBox pick;
    			int counter =0;
    		while(counter == 0)
    			try{
    				//goings into reciving the number of parties and the largest party.
    			String fn = JOptionPane.showInputDialog("Enter the Number of Parties. (Numbers only will work");
    			int gs = Integer.parseInt(fn);
    			parties = new String[gs];
    			fn = JOptionPane.showInputDialog("Enter the largest party number");
    			gs = Integer.parseInt(fn);
    			member = new String[gs];
    		
    			counter =1;
    				}
    			catch(Exception e){JOptionPane.showMessageDialog(null,"Invalid Input (Numbers only!!)","FALIURE",JOptionPane.PLAIN_MESSAGE);
    	}
    			
    				
    			String fn=null;
    
    			//it is also going to be an error due to no file exist.
    			try{
    				//lists.txt has all the Main charater names.
    				Scanner x = new Scanner(new File("lists.txt"));
    			counter = 0;
    			//in the .txt the first line is the number of main charaters
    			
    				x=new Scanner(new File("Lists.txt"));
    				fn = x.next();
    				counter = Integer.parseInt(fn);
    				counter=counter+1;
    				everyone=new String[counter];
    				counter=0;
    				//while is to get all of the main charater names.
    				while(x.hasNext()){
    				
    					String fake = x.next();
    				everyone[counter]=fake;
    				counter++;
    				System.out.println(counter+" fake");
    				}	x.close();	
    		}catch (FileNotFoundException e) {
    			System.out.println("!!IGNORE ME!!  THIS MEANS IT IS WORKING!");
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    		
    		//now to make the party windows.
    	counter =0;
    	int counter2 = 0;
    	//makes the total number of parties.
    			while(counter<parties.length){
    	counter++;boolean s =false;
    	while(s==false){
    		//for each party you make a name
    		 fn = JOptionPane.showInputDialog("Party "+ counter+1 +"'s name?");
    
    		String yes = JOptionPane.showInputDialog("Is "+fn+" Correct? Y Or N only please");
    		//this part works. where you create a new window for each seperate party.
    		if(yes.equalsIgnoreCase("y")){
    			s=true;
    			JFrame q = new JFrame(fn);
    			q.setVisible(true);
    			q.setSize(300,200);
    	//yes I know about 	q.repaint(); for w/e reason it doesn't refresh like resizing does.
    			while(counter2<member.length){
    				//using the fake file
    				pick = new JComboBox(everyone);
    		//this is only added once.  I need it added for every member.
    				q.add(pick);
    				counter2++;
    			q.repaint();
    			}
    			q.setSize(300,200);
    		
    
    
    	}
    
    	}}}
    		}
    (is there a reason why chrome won't let me add attachments?)
    lists.txt
    5
    Olivia
    Roton
    Presti
    Zren
    demi
    Last edited by Mokomi; 06-20-2012 at 11:00 PM.

  10. #10
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default Re: Creating Party Windows.

    Also for testing, hard code ALL of the answers for the JOptionPane's prompts.

    Don't require the tester to answer all those questions.
    For example:
    Java Code:
      String fn = "2"; //JOptionPane.showInputDialog("Enter the Number of Parties. (Numbers only will work");
    If you don't understand my response, don't ignore it, ask a question.

  11. #11
    Mokomi is offline Member
    Join Date
    May 2011
    Posts
    32
    Rep Power
    0

    Default Re: Creating Party Windows.

    kk I can do that i'll be 2 parties with 3 members each to make it easier. with party 1 and party awesome for the JFrame.
    P.s. the add attachments isn't changing. just gives me a gray screen in all firefox/explorer/and chrome.

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default Re: Creating Party Windows.

    Please post the code and an explanation of the problem.

    gives me a gray screen in all firefox/explorer/and chrome.
    What do the browsers have to do with this application?
    If you don't understand my response, don't ignore it, ask a question.

  13. #13
    Mokomi is offline Member
    Join Date
    May 2011
    Posts
    32
    Rep Power
    0

    Default Re: Creating Party Windows.

    I was wondering if it was a script blocker. or direct connection of some kind.
    Your connection to the site is not encrypted.
    The site has not provided the browser with a certificate

  14. #14
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default Re: Creating Party Windows.

    Sorry, I have no idea what you are talking about.
    If you don't understand my response, don't ignore it, ask a question.

  15. #15
    Mokomi is offline Member
    Join Date
    May 2011
    Posts
    32
    Rep Power
    0

    Default Re: Creating Party Windows.

    A working program. for this example I answered the questions with all hard answers .2 parties(2 total JFrames). 3 members(3 total JComboBox's) with all data needed from the list.txt file.
    Java Code:
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    import java.lang.reflect.Type;
    import java.util.Locale;
    import static java.lang.System.out;
    import static java.lang.System.err;
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    import java.util.Arrays;
    import java.awt.*;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.AdjustmentEvent;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.IOException;
    import java.util.Scanner;
    import java.util.Scanner;
    
    import javax.swing.*;
    
    public class bucky  extends JFrame{
    	public static void main(String[] args){
    String[] everyone = new String[0];
    		String[] member = new String[0];
    		String[] parties = new String[0];
    		JComboBox pick;
    		String fn="1";
    			int counter =0;
    		while(counter == 0)
    			try{
    				//goings into reciving the number of parties and the largest party.
    				//String fn = JOptionPane.showInputDialog("Enter the Number of Parties. (Numbers only will work");
    			int gs = Integer.parseInt(fn);
    		gs = 2;
    			parties = new String[gs];
    			//fn = JOptionPane.showInputDialog("Enter the largest party number");
    			gs = Integer.parseInt(fn);
    			gs = 3;
    			member = new String[gs];
    		
    			counter =1;
    				}
    			catch(Exception e){JOptionPane.showMessageDialog(null,"Invalid Input (Numbers only!!)","FALIURE",JOptionPane.PLAIN_MESSAGE);
    	}
    			
    				
    		//	String fn=null;
    
    			//it is also going to be an error due to no file exist.
    			try{
    				//lists.txt has all the Main charater names.
    				Scanner x = new Scanner(new File("lists.txt"));
    			counter = 0;
    			//in the .txt the first line is the number of main charaters
    			
    				x=new Scanner(new File("Lists.txt"));
    				fn = x.next();
    				counter = Integer.parseInt(fn);
    				counter=counter+1;
    				everyone=new String[counter];
    				counter=0;
    				//while is to get all of the main charater names.
    				while(x.hasNext()){
    				
    					String fake = x.next();
    				everyone[counter]=fake;
    				counter++;
    				System.out.println(counter+" fake");
    				}	x.close();	
    		}catch (FileNotFoundException e) {
    			System.out.println("!!IGNORE ME!!  THIS MEANS IT IS WORKING!");
    			e.printStackTrace();
    		}
    		String[] everyones= {"Olivia","Roton","Presti","Zren","demi",null};
    		//now to make the party windows.
    	counter =0;
    	int counter2 = 0;
    	//makes the total number of parties.
    			while(counter<parties.length){
    	counter++;boolean s =false;
    	while(s==false){
    		//for each party you make a name
    		 //fn = JOptionPane.showInputDialog("Party "+ counter+1 +"'s name?");
    if (counter2==0)fn  ="Party 1";
    else fn = "Party Awesome";
    	//	String yes = JOptionPane.showInputDialog("Is "+fn+" Correct? Y Or N only please");
    		//this part works. where you create a new window for each seperate party.
    	//	if(yes.equalsIgnoreCase("y")){
    			s=true;
    			JFrame q = new JFrame(fn);
    			q.setVisible(true);
    			q.setSize(300,200);
    	//yes I know about 	q.repaint(); for w/e reason it doesn't refresh like resizing does.
    			while(counter2<member.length){
    				//using the fake file
    				pick = new JComboBox(everyones);
    		//this is only added once.  I need it added for every member.
    				q.add(pick);
    				counter2++;
    			q.repaint();
    			}
    			q.setSize(300,201);
    		
    
    
    	}
    
    	}}}
    i'm sorry for the inconveniences with working with someone who doesn't understand. my roommate works with a help desk so I can somewhat relate. now the goal is to have multiple JFrames and you have to select your members of your party. later they will do battle with each other. so I do not know how to pull information for all the JComboBoxes if i'm using the same JComboBox for all members of the party.

  16. #16
    Mokomi is offline Member
    Join Date
    May 2011
    Posts
    32
    Rep Power
    0

    Default Re: Creating Party Windows.

    I need to pick someone up. it's ok i'll make a new thread with a different question. how to make multiple JFrames and muti JComboBoxes with a single while loop. and pull information from them.

  17. #17
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default Re: Creating Party Windows.

    I get this error:
    java.io.FileNotFoundException: lists.txt (The system cannot find the file specified)

    What is the app supposed to do? I get two windows, one with a combo box.
    If you don't understand my response, don't ignore it, ask a question.

  18. #18
    Mokomi is offline Member
    Join Date
    May 2011
    Posts
    32
    Rep Power
    0

    Default Re: Creating Party Windows.

    awesome. ignore the error. i made a String[] to fill it in. didn't notice it due to the fact I have a lists.txt file. but that is the problem. it is creating the number of parties in JFrames with correct names. but not the correct members in each party. (inncorrect number of JComboBoxes inside each JFrame) (I also need it to pull information for each of the JComboBoxes. for this example The user input a total of 2 parties with the largest party with 3 members. it is to have 3 JComboBoxes. but only 1 is being added to only the first JFrame.

    the app is to change, do formula's for the change. Then record the change from combat with multiple players. I need the app to open a user input of parties (each with their own window or JFrame) with a unset number of members. each member also has their own move set list. they are going to interact with each other. the interation includes switching from one party to another. If you know a better way of doing this by all means.
    (Looking up solutions someone mentioned having a JPanel class so i'm going give that a try)
    Last edited by Mokomi; 06-21-2012 at 12:38 AM.

  19. #19
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,899
    Rep Power
    25

    Default Re: Creating Party Windows.

    If you have any specific java programming questions. be sure to post them
    If you don't understand my response, don't ignore it, ask a question.

Similar Threads

  1. Replies: 4
    Last Post: 11-21-2011, 08:34 PM
  2. tutorials 4 creating windows components
    By jaytee in forum New To Java
    Replies: 1
    Last Post: 03-07-2010, 09:48 PM
  3. Replies: 3
    Last Post: 01-21-2010, 02:51 AM
  4. Replies: 3
    Last Post: 08-10-2009, 07:34 AM
  5. Third party packages
    By logicbug in forum New To Java
    Replies: 0
    Last Post: 03-23-2009, 04:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •