Results 1 to 10 of 10
  1. #1
    Marshall is offline Member
    Join Date
    May 2010
    Posts
    5
    Rep Power
    0

    Default added a 3rd tab to jtab pane now i get an exception error??

    This is the error i receive at run time
    Exception in thread "main" java.lang.NullPointerException
    at java.awt.Container.addImpl(Container.java:1045)
    at java.awt.Container.add(Container.java:365)
    at PersonalPanel.<init>(PersonalPanel.java:126)
    at GameBoxLayout.main(GameBoxLa

    I had two tabs, Aboutpanel.java that is all text and a second tab MadlibPanel.javathat uses the East,West,North South layout. Program compiled fine and ran well. I added on a 3rd tab (Personalpanel.java) that also uses teh East,West,North South layout and now i'm getting the above exception error when i try to run it. I would imagine that it somehow does not like the fact that i am adding a nother tab with the east/west/north layout??
    Here's my code - This is a final project and this is the only thing i have left to do so i'm totally stressing out. (The program works fine outside of this, as panel 2 and 3 use the same exact code, just different variables.)

    Java Code:
    import java.awt.*;
    import javax.swing.*;
    
    public class GameBoxLayout
    {
    
    //create a frame that contains a 3 tabbed pane.  
    
    	public static void main (String[] args)
    
    	{
    	//Use the Java look and feel instead of the windwos look and feel on JFrame.
    		JFrame.setDefaultLookAndFeelDecorated(true);
    
    	//Create JFrame
    		JFrame frame = new JFrame ("Mad Libs Game Box");
    		frame.setDefaultCloseOperation (JFrame.EXIT_ON_CLOSE);
    		
    	//Create tabbed panes for JFrame	
    		JTabbedPane tp = new JTabbedPane();
    		tp.addTab ("Hamlet", new MadlibPanel());
    		tp.addTab ("About MadLibs", new AboutPanel());
    		tp.addTab ("Personal Ad", new PersonalPanel());
    //		tp.addTab ("Grammar Lesson", new GrammarPanel());
    		
    		frame.getContentPane().add(tp);
    		frame.setSize(900,600);
    		
    	
    		frame.setVisible(true);
    	}
    }
    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.BorderFactory; 
    import javax.swing.border.Border;
    import javax.swing.border.TitledBorder;
    import javax.swing.border.EtchedBorder;
    	
    	
    public class MadlibPanel extends JPanel
    {
    
    // Set global class variables
    
    	
    	private JLabel resultLabel, verb1Input, adj1Input, verb2Input,nounpInput;
    	private JLabel weaponpInput, adj2Input, noun1Input, foodpInput, verb3Input, adj3Input, noun2Input;
    	private JLabel verb4Input, verbedInput, noun4Input, adj4Input, noun3Input;
       private JTextField fahrenheit, verb1, adj1, verb2, nounp, weaponp, adj2, noun1, foodp, verb3, adj3, noun2;
       private JTextField verb4, verbed, noun4, adj4, noun3;
    	JButton Display;		
    	JTextArea ta;
    	JScrollPane sp;
    	JPanel eastPanel, centerPanel, westPanel, northPanel, panel;
    	String line, line1, line2, line3, line4, line5, line6, line7, line8, line9, line10, line11, line12, line13, line14;
    	
    	
    
     //  Constructor: Sets up the main GUI components.
      
       public MadlibPanel()
       {
    	
    
    //apply decorative border to the frame
    
          Border paneEdge = BorderFactory.createEmptyBorder(0,10,10,10);
    	   Border etched;
    
      	   etched = BorderFactory.createEtchedBorder();
    		
    
    //creates JPanels  
           panel = new JPanel();
           panel.setLayout(new BorderLayout());
           panel.setBackground (Color.cyan);
           panel.setPreferredSize(new Dimension(900,500));  
    	   eastPanel = new JPanel();
    	   eastPanel.setLayout(new GridLayout(16,2));
    	   eastPanel.setBackground(Color.pink);
    	   centerPanel = new JPanel();
    	   centerPanel.setBackground(Color.pink);
    	   westPanel = new JPanel();
    	   westPanel.setBackground(Color.pink);
    	   northPanel = new JPanel();
    	   northPanel.setBackground(Color.pink);
    	   
            
    
    //Creaet a titled border
    TitledBorder title1;
    title1 = BorderFactory.createTitledBorder(etched, "MADLIBS as written by Shakespeare");
    setBorder(title1);
    
    	
    //Define text fields and Jlabels to request user input.
    //Define each field to a lenght of 15 for consistancy.
    
    		verb1Input = new JLabel ("Enter a verb");
    		verb1 = new JTextField (15);  
    		adj1Input = new JLabel ("Enter an adjective");
    		adj1 = new JTextField (15);  
    		verb2Input = new JLabel ("Enter a verb");
    		verb2 = new JTextField (15);  
    		nounpInput = new JLabel ("Enter a noun (plural)");
    		nounp = new JTextField (15);  
    		weaponpInput = new JLabel ("Enter a weapon (plural)");
    		weaponp = new JTextField (15);  
    		adj2Input = new JLabel ("Enter an adjective");
    		adj2 = new JTextField (15);  
    		noun1Input = new JLabel ("Enter a noun");
    		noun1 = new JTextField (15);  
    		foodpInput = new JLabel ("Enter a food (plural)");
    		foodp = new JTextField (15);  
    		verb3Input = new JLabel ("Enter a verb");
    		verb3 = new JTextField (15);  
    		adj3Input = new JLabel ("Enter an adjective");
    		adj3 = new JTextField (15);  
    		noun2Input = new JLabel ("Enter a noun");
    		noun2 = new JTextField (15);  
    		verb4Input = new JLabel ("Enter a verb");
    		verb4 = new JTextField (15);  
    		noun3Input = new JLabel ("Enter a noun");
    		noun3 = new JTextField (15);  
    		verbedInput = new JLabel ("Enter a verb (ending in ed)");
    		verbed = new JTextField (15);  
    		noun4Input = new JLabel ("Enter a noun");
    		noun4 = new JTextField (15);  
    		adj4Input = new JLabel ("Enter an adjective");
    		adj4 = new JTextField (15);  
    	
    
         	adj4.addActionListener (new TempListener()); 
    		Display = new JButton ("Display");			//initializes my new button
    		Display.addActionListener (new TempListener());	//creates a new instance 
    
    	
    //add text fields and Jlabels to request user input.
    //add each field to a lenght of 15 for consistancy.
    
    		eastPanel.add (verb1Input);
    		eastPanel.add (verb1);
    		eastPanel.add (adj1Input);
    		eastPanel.add (adj1);
    		eastPanel.add (verb2Input);
    		eastPanel.add (verb2);
    		eastPanel.add (nounpInput);
    		eastPanel.add (nounp);
    		eastPanel.add (weaponpInput);
    		eastPanel.add (weaponp);
    		eastPanel.add (adj2Input);
    		eastPanel.add (adj2);
    		eastPanel.add (noun1Input);
    		eastPanel.add (noun1);
    		eastPanel.add (foodpInput);
    		eastPanel.add (foodp);
    		eastPanel.add (verb3Input);
    		eastPanel.add (verb3);
    		eastPanel.add (adj3Input);
    		eastPanel.add (adj3);
    		eastPanel.add (noun2Input);
    		eastPanel.add (noun2);
    		eastPanel.add (noun2Input);
    		eastPanel.add (noun2);
    		eastPanel.add (verb4Input);
    		eastPanel.add (verb4);
    		eastPanel.add (verbedInput);
    		eastPanel.add (verbed);
    		eastPanel.add (noun4Input);
    		eastPanel.add (noun4);
    		eastPanel.add (adj4Input);
    		eastPanel.add (adj4);
       	eastPanel.add (Display);
    
    //define text area to panel with specified size of 30,40
    //define scroll pane to the panel
    //add the center panel
            ta = new JTextArea("Your story will appear here", 30, 40);
            sp = new JScrollPane(ta);
            centerPanel.add(sp);
    
    //add individual panels to the frame.
            
            panel.add (eastPanel, BorderLayout.EAST);
            panel.add (centerPanel, BorderLayout.CENTER);
            panel.add (westPanel, BorderLayout.WEST);
            panel.add (northPanel, BorderLayout.NORTH);
    
    //add main panel to the frame        
            add (panel);
    	   
       }
    	
    
    
    //  ActionListener defined for display button
      
       private class TempListener implements ActionListener
       {
    
    
    //  concatenates user input to the madlib story 
    
          public void actionPerformed (ActionEvent event)
          {
     		
    		
    		  line1 = "To " + verb1.getText() + ", or not to " + verb1.getText() + ",--that is the question:--\n";
    	     line2 = "Whether tis more " + adj1.getText() + " in the mind to " + verb2.getText() + "\n";
    		  line3 = "The " + nounp.getText() + " and " + weaponp.getText() + " of " + adj2.getText() + " fortune\n";
    		  line4 = "Or to take " + noun1.getText() + " against a sea of " + foodp.getText() + ",\n";
    		  line5 = "And by opposing end them?--To die,--to " + verb3.getText() + ",--\n";
    		  line6 = "No more; and by a " + verb3.getText() + " to say we end \n";
    		  line7 = "The heartache, and the thousand " + adj3.getText() + " shocks\n";
    		  line8 = "That flesh is heir to,--`tis a " + noun2.getText() + "\n";
    		  line9 = "Devoutly to be wish`d. To die,--to " + verb4.getText() + ";--\n";
    		  line10 = "To " + verb4.getText() + "! perchance to dream:--ay, there`s the " + noun3.getText() +"\n";
    		  line11 = "For in that " + verb4.getText() + " of death what dreams may come,\n";
    		  line12 = "When we have " + verbed.getText() + " off this mortal " + noun4.getText()+ "\n";
    		  line13 = "Must give us pause: there`s the respect\n";
    		  line14 = "That makes calamity of so " + adj4.getText() + " life...\n"; 
            line = line1+line2+line3+line4+line5+line6+line7+line8+line9+line10+line11+line12+line13+line14;
    
    //sets the value of the text area to be the madlib output
    
    	      ta.setText(line);
     
    	 }
      }
    }
    Java Code:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.BorderFactory; 
    import javax.swing.border.Border;
    import javax.swing.border.TitledBorder;
    import javax.swing.border.EtchedBorder;
    	
    	
    public class PersonalPanel extends JPanel
    {
    
    // Set global class variables
    
    
    	private JTextField liquid, famous, place, job, nationality, famousg, girlfriend, num;
    	private JTextField nounp1, nounp2, nounp3, noun1, noun2;
    	private JTextField adj1, adj2;
    	private JTextField verbed;
    	private JLabel verbedInput, adj1Input, adj2Input, nounp1Input, nounp2Input, nounp3Input, noun1Input;
    	private JLabel noun2Input, liquidInput, famousInput, placeInput, jobInput, nationalityInput;
    	private JLabel famousgInput, girlfriendInput, numInput, resultLabel;
    	JButton Display;		
    	JTextArea ta;
    	JScrollPane sp;
    	JPanel eastPanel, centerPanel, westPanel, northPanel, panel;
    	String line, line1, line2, line3, line4, line5, line6, line7, line8, line9, line10;
    	
    	
    
     //  Constructor: Sets up the main GUI components.
      
       public PersonalPanel()
       {
    	
    
    //apply decorative border to the frame
    
          Border paneEdge = BorderFactory.createEmptyBorder(0,10,10,10);
    	   Border etched;
    
      	   etched = BorderFactory.createEtchedBorder();
    		
    
    //creates JPanels  
           panel = new JPanel();
           panel.setLayout(new BorderLayout());
           panel.setBackground (Color.cyan);
           panel.setPreferredSize(new Dimension(900,500));  
    	   eastPanel = new JPanel();
    	   eastPanel.setLayout(new GridLayout(16,2));
    	   eastPanel.setBackground(Color.pink);
    	   centerPanel = new JPanel();
    	   centerPanel.setBackground(Color.pink);
    	   westPanel = new JPanel();
    	   westPanel.setBackground(Color.pink);
    	   northPanel = new JPanel();
    	   northPanel.setBackground(Color.pink);
    	   
            
    
    //Creaet a titled border
    TitledBorder title1;
    title1 = BorderFactory.createTitledBorder(etched, "MADLIBS as written by Shakespeare");
    setBorder(title1);
    
    	
    //Define text fields and Jlabels to request user input.
    //Define each field to a lenght of 15 for consistancy.
    
    		adj1Input = new JLabel ("Enter an adjective");
    		adj1 = new JTextField (15);  
    		verbedInput = new JLabel ("Enter a verb ending in ed");
    		verbed = new JTextField (15);  
    		nounp1Input = new JLabel ("Enter a noun (plural)");
    		noun1 = new JTextField (15);  
    		liquidInput = new JLabel ("Enter a liquid");
    		liquid = new JTextField (15);  
    		nounp2Input = new JLabel ("Enter a noun (plural)");
    		nounp2 = new JTextField (15);  
    		famousInput = new JLabel ("Enter a famous person");
    		famous = new JTextField (15);  
    		placeInput = new JLabel ("Enter a place");
    		place = new JTextField (15);  
    		jobInput = new JLabel ("Enter an occupation");
    		job = new JTextField (15);  
    		noun1Input = new JLabel ("Enter a noun");
    		noun1 = new JTextField (15);  
    		nationalityInput = new JLabel ("Enter an nationality");
    		nationality = new JTextField (15);  
    		famousgInput = new JLabel ("Enter a female celebrity");
    		famousg = new JTextField (15);  
    		noun2Input = new JLabel ("Enter a noun");
    		noun2 = new JTextField (15);  
    		girlfriendInput = new JLabel ("Enter a female friend");
    		girlfriend = new JTextField (15);  
    		nounp3Input = new JLabel ("Enter a noun (plural)");
    		nounp3 = new JTextField (15);  
    		numInput = new JLabel ("Enter a number");
    		num = new JTextField (15);  
    		adj2Input = new JLabel ("Enter an adjective");
    		adj2 = new JTextField (15);  
    	
    
         	adj2.addActionListener (new TempListener()); 
    		Display = new JButton ("Display");			//initializes my new button
    		Display.addActionListener (new TempListener());	//creates a new instance 
    
    	
    //add text fields and Jlabels to request user input.
    //add each field to a lenght of 15 for consistancy.
    
    		eastPanel.add (adj1Input);
    		eastPanel.add (adj1);
    		eastPanel.add (verbedInput);
    		eastPanel.add (verbed);
    		eastPanel.add (nounp1Input);
    		eastPanel.add (nounp1);
    		eastPanel.add (liquidInput);
    		eastPanel.add (liquid);
    		eastPanel.add (nounp2Input);
    		eastPanel.add (nounp2);
    		eastPanel.add (famousInput);
    		eastPanel.add (famous);
    		eastPanel.add (placeInput);
    		eastPanel.add (place);
    		eastPanel.add (jobInput);
    		eastPanel.add (job);
    		eastPanel.add (noun1Input);
    		eastPanel.add (noun1);
    		eastPanel.add (nationalityInput);
    		eastPanel.add (nationality);
    		eastPanel.add (famousgInput);
    		eastPanel.add (famousg);
    		eastPanel.add (noun2Input);
    		eastPanel.add (noun2);
    		eastPanel.add (girlfriendInput);
    		eastPanel.add (girlfriend);
    		eastPanel.add (nounp3Input);
    		eastPanel.add (nounp3);
    		eastPanel.add (numInput);
    		eastPanel.add (num);
    		eastPanel.add (adj2Input);
    		eastPanel.add (adj2);
       	eastPanel.add (Display);
    
    //define text area to panel with specified size of 30,40
    //define scroll pane to the panel
    //add the center panel
            ta = new JTextArea("Your story will appear here", 30, 40);
            sp = new JScrollPane(ta);
            centerPanel.add(sp);
    
    //add individual panels to the frame.
            
            panel.add (eastPanel, BorderLayout.EAST);
            panel.add (centerPanel, BorderLayout.CENTER);
            panel.add (westPanel, BorderLayout.WEST);
            panel.add (northPanel, BorderLayout.NORTH);
    
    //add main panel to the frame        
            add (panel);
    	   
       }
    	
    
    
    //  ActionListener defined for display button
      
       private class TempListener implements ActionListener
       {
    
    
    //  concatenates user input to the madlib story 
    
          public void actionPerformed (ActionEvent event)
          {
     		
    		
    		
    		
    		line1 = "I enjoy long, " + adj1.getText() + " walks on the beach, getting " + verbed.getText()+ "\n";
    		line2 = "in the rain and serendipitous encounters with " + nounp1.getText() + ". I really\n"; 
    		line3 = "like piña coladas mixed with liquid, and romantic, candle-lit " + nounp2.getText() + "\n";
    		line4 = ". I am well-read from Dr. Seuss to " + famous.getText() + ". I travel frequently,\n";
    		line5 = "especially to " + place.getText() + ", when I am not busy with work. (I am a " + job.getText() + ".) I am \n";
    		line6 = "looking for " + noun1.getText() + " and beauty in the form of a " + nationality.getText() + " goddess.\n";
    		line7 = "She should have the physique of " + famousg.getText() + " and the " + noun2.getText() + " of \n";
    		line8 = girlfriend.getText() + ". I would prefer if she knew how to cook, clean, and wash my" + "\n";
    		line9 = noun2.getText() + ". I know I’m not very attractive in my picture, but it was taken" + "\n";
    		line10 = num.getText() + " days ago, and I have since become more " + adj2.getText() + ".\n"; 
    		line = line1+line2+line3+line4+line5+line6+line7+line8+line9+line10;
    
    //sets the value of the text area to be the madlib output
    
    	      ta.setText(line);
     
    	 }
      }
    }
    Java Code:
     
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.border.*;
    import javax.swing.BorderFactory; 
    import javax.swing.border.Border;
    import javax.swing.border.TitledBorder;
    import javax.swing.border.EtchedBorder;
    import javax.swing.ImageIcon;
    import javax.swing.JTabbedPane;
    import javax.swing.JLabel;
    import javax.swing.JPanel; 
    import javax.swing.JFrame;
    import javax.swing.Box;
    import javax.swing.BoxLayout;
    
     
     public class AboutPanel extends JPanel
     { 
     
     //define the panel and its labels
     
     	public AboutPanel()
    	{
    		     super(new GridLayout(1,0));
    
          Border paneEdge = BorderFactory.createEmptyBorder(0,10,10,10);
    		Border etched;
    
       	etched = BorderFactory.createEtchedBorder();
    		
    //creates JPanel    
    		  JPanel simpleBorders = new JPanel();
            simpleBorders.setBorder(paneEdge);
            simpleBorders.setLayout(new BoxLayout(simpleBorders,
                                                  BoxLayout.Y_AXIS));
    
    //Titled borders
    TitledBorder title1, title2, title3, title4, title5;
    title1 = BorderFactory.createTitledBorder(etched, "ALL ABOUT MADLIBS");
    setBorder(title1);
    
    //Sets background Colors
    		Color color = new Color(245,222,179);
    		setBackground (color);
    		 				 
    		setLayout (new BoxLayout(this, BoxLayout.Y_AXIS));
    		
    		JLabel l1 = new JLabel ("Mad Libs (from ad lib, a spontaneous improvisation) is a phrasal template word game where one player");
    		JLabel blank1 = new JLabel (" ");
    		JLabel l1a = new JLabel ("prompts another for a list of words to substitute for blanks in a story; these word substitutions have");
    		JLabel blank1a = new JLabel (" ");
    		JLabel l1b = new JLabel ("a humorous effect when the resulting story is then read aloud.");
    		JLabel blank1b = new JLabel (" ");
    		JLabel l2 = new JLabel ("  ");
    		JLabel blank2 = new JLabel (" ");
    //		JLabel l2a = new JLabel (" ");		//reserved spaces
    //		JLabel blank2a = new JLabel (" ");  //reserved spaces
    		
    		JLabel l3 = new JLabel ("Mad Libs was invented in 1953 by Leonard Stern and Roger Price, who published the first Mad Libs book");
    		JLabel blank3 = new JLabel (" ");
    		JLabel l3a = new JLabel ("themselves in 1958.");
    		JLabel blank3a = new JLabel (" ");
    		
    		
    		JLabel l4 = new JLabel ("Mad Libs consist of a book that has a short story on each page, but with many of the key words");
    		JLabel blank4 = new JLabel (" ");
    		JLabel l4a = new JLabel ("replaced with blanks. Beneath each blank is specified a lexical or other category, such as noun,");
    		JLabel blank4a = new JLabel (" ");
    		JLabel l4b = new JLabel ("verb, place, or a part of the body.  One player asks the other players, in turn, to contribute");
    		JLabel blank4b = new JLabel (" ");
    		JLabel l4c = new JLabel ("some word for the specified type for each blank, but without revealing the context for that word.");
    		JLabel blank4c = new JLabel (" ");
    		JLabel l4d = new JLabel ("Finally, the completed story is read aloud. The result is usually comic, surreal and somewhat");
    		JLabel blank4d = new JLabel (" ");
    		JLabel l4e = new JLabel ("nonsensical.");
    		JLabel blank4e = new JLabel (" ");
    		JLabel l4f = new JLabel ("");
    		JLabel blank4f = new JLabel (" ");
    	
    	
    		ImageIcon imageIcon = new ImageIcon("madlibLogo4.gif");
     	   JLabel pic1 = new JLabel(imageIcon);
    
    	  
    		add (l1);
    		add (blank1);
    		add (l1a);
    		add (blank1a);
    		add (l1b);
    		add (blank1b);
     		add (l2);
    		add (blank2);
    	//	add (l2a);
    	//	add (blank2a);
    		add (l3);
    		add (blank3);
    		add (l3a);
    		add (blank3a);
    		add (l4);
    		add (blank4);
    		add (l4a);
    		add (blank4a);
    		add (l4b);
    		add (blank4b);
    		add (l4c);
    		add (blank4c);
    		add (l4d);
    		add (blank4d);
    		add (l4e);
    		add (blank4e);
    		add (l4f);
    		add (blank4f);
    		add (pic1);
    		
    
    	}
    }

  2. #2
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Read the exception message.
    It's telling you that something that shouldn't be null is null at line 126 of the PersonalPanel.java file. What code do you have at that line?

  3. #3
    Marshall is offline Member
    Join Date
    May 2010
    Posts
    5
    Rep Power
    0

    Default no null value found

    thank you for responding. still doesnt make much sense to me as line 126 is where i'm adding a value to the east panel.

    eastPanel.add (nounp1);

    everything compiles properly - its only on run time that the error displays

  4. #4
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Like I said, at that line something is null.
    My bet is that nounp1 is null because it was never initialised.

  5. #5
    Marshall is offline Member
    Join Date
    May 2010
    Posts
    5
    Rep Power
    0

    Default

    ahhh!! ok - i was thinking 'null' as in empty!
    That was it exactly!!
    THANK YOU!!!

  6. #6
    r035198x is offline Senior Member
    Join Date
    Aug 2009
    Posts
    2,388
    Rep Power
    8

    Default

    Welcome, do pay attention to those exceptions (and compiler error messages too). A lot can be learnt from the information given by them.

  7. #7
    Marshall is offline Member
    Join Date
    May 2010
    Posts
    5
    Rep Power
    0

    Default Message

    Well I did stare at it a bit to see If I could figure it out but it was referencing . Container and the personal panel plus it had the word (init) taking all that in I made the erroneous conclusion that it was related to the new tab. I need to figure put what info is fluff and what is really wortwhile. I'd like to add an additional tab that has radio buttons - quick question for u. My frame is the main container and in that container is stored the tabbed panes if I make a 4th tab o would need to add a panel to be a subcontainer and then I can add the radio buttons but where would the button data go? For instance one button should display the word hat and the next button will show the word egg ( examples). Do the words have to be in their own panel or would I be better off using a grid layout?

  8. #8
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    You're better off experimenting with different layouts and program set ups to find what works best in this situation.

    One thing you might want to consider is separating out your data from your code a bit more because at the moment you appear to be hard-coding data into your program. Doing this will effectively hamstring your program making it large and unwieldy, and prevent you from easily changing data and upgrading the code. For instance consider how the code would look if the story text plus some type of placeholders (to mark the location of missing words and the type of the missing words) were held in a text file? If you wrote code to handle this, then you could use the very same code to display any madlib story you desire.

  9. #9
    Marshall is offline Member
    Join Date
    May 2010
    Posts
    5
    Rep Power
    0

    Default good idea - i'll get there eventually

    yeah, i'm sooo new to this - i know my code is probably way to robust for what its actually doing. i'm sure i could break it into smaller pieces althjough i'm not sure i get what your'e saying in your last post?

    one thing that i had considered was sending my output ot a text file to see if hat would be easier to do.

  10. #10
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    I'm saying to create a text input file looking something like so:

    Hamlet Soliloquy:
    <infinitive verb> or not <infinitive verb> -- that is the <noun>:
    Whether 'tis <adjective ending in "er"> in the <part of human anatomy> to suffer
    The <pl noun> and <pl noun> of <adj> fortune,
    and then create a Java class that can parse this file and use the parsed information to help the GUI create JLabels and respective JTextFields to input the appropriate parts of speech, and then combine the text and new words into the created mad lib.

Similar Threads

  1. exception error
    By kira137 in forum New To Java
    Replies: 5
    Last Post: 10-12-2009, 07:46 AM
  2. Exception error
    By Rose88 in forum New To Java
    Replies: 8
    Last Post: 07-06-2009, 10:22 PM
  3. Exception error
    By jaiminparikh in forum New To Java
    Replies: 0
    Last Post: 03-20-2009, 09:06 PM
  4. JSF error+exception
    By Peter in forum SWT / JFace
    Replies: 1
    Last Post: 07-04-2007, 06:29 AM
  5. tomcat exception-error
    By Nick15 in forum Eclipse
    Replies: 2
    Last Post: 05-11-2007, 01:32 AM

Posting Permissions

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