Getting JTextArea, JButton, JCheckbox

I'm having some problems calling my GUI display from my driver program.  Instead of running correctly I'm getting just a blank gray screen when I run my Driver.  Any help is appreciated.  

   import java.awt.*;
   import java.awt.event.*;
   import javax.swing.*;
   import java.util.ArrayList;

    public class PetAdoptionGUI extends JPanel
   {
   
      JTextArea dogOutput;
      JCheckBox specialNeeds;
      JRadioButton allButton;
      JRadioButton femaleButton;
      JRadioButton maleButton;
      JScrollPane scrollPane;
      JButton size;
      JButton age;
   
       public PetAdoptionGUI()
      {
         dogOutput = new JTextArea(7, 20);
         
         specialNeeds = new JCheckBox("Special Needs Only");
         //embPanel = new JPanel();
         //myBorder = BorderFactoy.createTileBorder("Filter Options");
         //embPanel.setBorder(myBorder);
         //embPanel.add(Box.createVerticalStrut(20));  
            
         allButton = new JRadioButton("All", true);
         femaleButton = new JRadioButton("Female Only", false);
         maleButton = new JRadioButton("Male Only", false);
     
         //all.setActionCommand();
         //all.setSelected(true);
            
            
         //femaleOnly.setActionCommand();
            
            
         //maleOnly.setActionCommand();
            
     
            
         
         
         ButtonGroup group = new ButtonGroup();
         group.add(allButton);
         group.add(femaleButton);
         group.add(maleButton);
         
         JPanel radioPanel = new JPanel();
         radioPanel.setLayout(new GridLayout(3, 1));
         radioPanel.add(allButton);
         radioPanel.add(femaleButton);
         radioPanel.add(maleButton);
         
            
         size = new JButton("Size");
         age = new JButton("Age");
         
            
         ArrayList <Dog> dogs = new ArrayList<Dog>();
            
         dogs.add(new Dog("Molly", "German Shepherd", Dog.LARGE, 'F', 2.0, 0,""));
         dogs.add(new Dog("Frankie", "Dachshund", Dog.SMALL, 'M', 5.0, 0,""));
         dogs.add(new Dog("Bella", "Dachshund",Dog.MINATURE,'F', 4.0, 1, "Blind") );
         dogs.add(new Dog("Poppy", "Beagle", Dog.MEDIUM, 'F', 7.0, 1,"Deaf"));
         dogs.add(new Dog("Pretzel","Pitbull", Dog.LARGE, 'F', 3.0, 0,""));
         dogs.add(new Dog("Jenna", "Doberman", Dog.LARGE, 'F', 5.0, 0,""));
         dogs.add(new Dog("Bob","Akita", Dog.GIANT, 'M', 2.0, 0,"" ));
         dogs.add(new Dog("Bear", "Labrador", Dog.LARGE, 'M', 1.0, 0, ""));
         dogs.add(new Dog("", "Akita", Dog.GIANT, 'M', 0.5, 0, ""));
         dogs.add(new Dog("", "Mix", Dog.SMALL, 'F', 0.3, 0,""));
         dogs.add(new Dog("Mr. T", "Bulldog", Dog.MEDIUM, 'M', 6.0,0,""));
         dogs.add(new Dog("Java", "Poodle", Dog.MEDIUM, 'M', 3.0, 1, "Neurological"));
         dogs.add(new Dog("Nelly", "Great Dane", Dog.GIANT, 'F', 0.6, 0,""));
         dogs.add(new Dog("Lucy", "Bassett", Dog.MEDIUM, 'M', 1.3, 1,"Missing Leg"));
         dogs.add(new Dog("Sandy", "Mix", Dog.MINATURE, 'F', 6.0, 0, ""));
     
            
     
            
      }
   }
import javax.swing.JFrame;
   
    public class PetAdoptionDriver
   {
       public static void main (String[] args)
      {
      //create panel
         PetAdoptionGUI guiPanel = new PetAdoptionGUI();
      //create frame
         JFrame frame = new JFrame ("Adoption Center");
      //add panel to frame
         frame.getContentPane().add(guiPanel);
      //set up frame
         frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         frame.pack();
         frame.setLocationRelativeTo(null);
         frame.setVisible(true);
      }
   }

Open in new window

Slck_PAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

objectsCommented:
you don't actually add anything to your PetAdoptionGUI

0
robthewolfCommented:
PetAdoptionGUI doesnt do very much, it creates a few objects but doesnt add them to the class object.
for example:
you create this text area
dogOutput = new JTextArea(7, 20);
but you dont do anything with it
you need a line like:
add(dogOutput,null);
or
this.add(dogOutput,null);

you should do this for all your objects that you create and want to see displayed

also
group and radioPanel should be declared as instance variables like all your other components.

Can you please close the other questions that you have asked.  Its not fair that people answer your questions and you move on to the next one with out giving credit to the people who have helped you
0
Slck_PAuthor Commented:
How would I call radioPanel and group to get it to display like the others?   Here's the code I have so far:


   import java.awt.*;
   import java.awt.event.*;
   import javax.swing.*;
   import java.util.ArrayList;

    public class PetAdoptionGUI extends JPanel
   {
   
      JTextArea dogOutput;
      JCheckBox specialNeeds;
      JRadioButton allButton;
      JRadioButton femaleButton;
      JRadioButton maleButton;
      JScrollPane scrollPane;
      JButton size;
      JButton age;
      ButtonGroup group;
      JPanel radioPanel;
   
       public PetAdoptionGUI()
      {
         dogOutput = new JTextArea(7, 20);
         
         add(dogOutput, null);
         
         specialNeeds = new JCheckBox("Special Needs Only");
         
         add(specialNeeds, null);
         //embPanel = new JPanel();
         //myBorder = BorderFactoy.createTileBorder("Filter Options");
         //embPanel.setBorder(myBorder);
         //embPanel.add(Box.createVerticalStrut(20));  
      	
         allButton = new JRadioButton("All", true);
         add(allButton, null);
         femaleButton = new JRadioButton("Female Only", false);
         add (femaleButton, null); 
         maleButton = new JRadioButton("Male Only", false);
         add (maleButton, null); 
      
         //all.setActionCommand();
         //all.setSelected(true);
      	
      	
         //femaleOnly.setActionCommand();
      	
      	
         //maleOnly.setActionCommand();
      	
      
      	
         
         
         ButtonGroup group = new ButtonGroup();
         group.add(allButton);
      
         group.add(femaleButton);
         group.add(maleButton);
         
         JPanel radioPanel = new JPanel();
         radioPanel.setLayout(new GridLayout(3, 1));
         radioPanel.add(allButton);
         radioPanel.add(femaleButton);
         radioPanel.add(maleButton);
         
      	
         size = new JButton("Size");
         add(size, null);
      
         age = new JButton("Age");
         add(age, null);
      
         
      	
         ArrayList <Dog> dogs = new ArrayList<Dog>();
      	
         dogs.add(new Dog("Molly", "German Shepherd", Dog.LARGE, 'F', 2.0, 0,""));
         dogs.add(new Dog("Frankie", "Dachshund", Dog.SMALL, 'M', 5.0, 0,""));
         dogs.add(new Dog("Bella", "Dachshund",Dog.MINATURE,'F', 4.0, 1, "Blind") );
         dogs.add(new Dog("Poppy", "Beagle", Dog.MEDIUM, 'F', 7.0, 1,"Deaf"));
         dogs.add(new Dog("Pretzel","Pitbull", Dog.LARGE, 'F', 3.0, 0,""));
         dogs.add(new Dog("Jenna", "Doberman", Dog.LARGE, 'F', 5.0, 0,""));
         dogs.add(new Dog("Bob","Akita", Dog.GIANT, 'M', 2.0, 0,"" ));
         dogs.add(new Dog("Bear", "Labrador", Dog.LARGE, 'M', 1.0, 0, ""));
         dogs.add(new Dog("", "Akita", Dog.GIANT, 'M', 0.5, 0, ""));
         dogs.add(new Dog("", "Mix", Dog.SMALL, 'F', 0.3, 0,""));
         dogs.add(new Dog("Mr. T", "Bulldog", Dog.MEDIUM, 'M', 6.0,0,""));
         dogs.add(new Dog("Java", "Poodle", Dog.MEDIUM, 'M', 3.0, 1, "Neurological"));
         dogs.add(new Dog("Nelly", "Great Dane", Dog.GIANT, 'F', 0.6, 0,""));
         dogs.add(new Dog("Lucy", "Bassett", Dog.MEDIUM, 'M', 1.3, 1,"Missing Leg"));
         dogs.add(new Dog("Sandy", "Mix", Dog.MINATURE, 'F', 6.0, 0, ""));
      
      	
      
      	
      }
   }

Open in new window

0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

objectsCommented:
just add radioPanel to your gui
0
Slck_PAuthor Commented:
Thanks for the help I've got everything printing except for my JTextArea.  I think I have to use an Actionlistener so would I call it in the Driver or GUI?  Here's what I have so far:


import java.awt.*;
   import java.awt.event.*;
   import javax.swing.*;
   import java.util.ArrayList;

    public class PetAdoptionGUI extends JPanel
   {
   
      JTextArea dogOutput;
      JCheckBox specialNeeds;
      JRadioButton allButton;
      JRadioButton femaleButton;
      JRadioButton maleButton;
      JScrollPane scrollPane;
      JButton size;
      JButton age;
      ButtonGroup group;
      JPanel radioPanel;
   
       public PetAdoptionGUI()
      {
         dogOutput = new JTextArea(7, 20);
         
         add(dogOutput, null);
         
         specialNeeds = new JCheckBox("Special Needs Only");
         
         add(specialNeeds, null);
         //embPanel = new JPanel();
         //myBorder = BorderFactoy.createTileBorder("Filter Options");
         //embPanel.setBorder(myBorder);
         //embPanel.add(Box.createVerticalStrut(20));  
      	
         allButton = new JRadioButton("All", true);
         add(allButton, null);
         femaleButton = new JRadioButton("Female Only", false);
         add (femaleButton, null); 
         maleButton = new JRadioButton("Male Only", false);
         add (maleButton, null); 
      
         //all.setActionCommand();
         //all.setSelected(true);
      	
      	
         //femaleOnly.setActionCommand();
      	
      	
         //maleOnly.setActionCommand();
      	
      
      	
         
         
         ButtonGroup group = new ButtonGroup();
         group.add(allButton);
      
         group.add(femaleButton);
         group.add(maleButton);
         
         JPanel radioPanel = new JPanel();
         radioPanel.setLayout(new GridLayout(3, 1));
         radioPanel.add(allButton);
         add(allButton, null);
      
         radioPanel.add(femaleButton);
         add(femaleButton, null);
      
      	
         radioPanel.add(maleButton);
         
         add(maleButton, null);
      
         
      	
         size = new JButton("Size");
         add(size, null);
      
         age = new JButton("Age");
         add(age, null);
      
      }
       public PetAdoptionGUI(ArrayList <Dog> dogs)
      {
         //ArrayList <Dog> dogs = new ArrayList<Dog>();
      	
         dogs.add(new Dog("Molly", "German Shepherd", Dog.LARGE, 'F', 2.0, 0,""));
         dogs.add(new Dog("Frankie", "Dachshund", Dog.SMALL, 'M', 5.0, 0,""));
         dogs.add(new Dog("Bella", "Dachshund",Dog.MINATURE,'F', 4.0, 1, "Blind") );
         dogs.add(new Dog("Poppy", "Beagle", Dog.MEDIUM, 'F', 7.0, 1,"Deaf"));
         dogs.add(new Dog("Pretzel","Pitbull", Dog.LARGE, 'F', 3.0, 0,""));
         dogs.add(new Dog("Jenna", "Doberman", Dog.LARGE, 'F', 5.0, 0,""));
         dogs.add(new Dog("Bob","Akita", Dog.GIANT, 'M', 2.0, 0,"" ));
         dogs.add(new Dog("Bear", "Labrador", Dog.LARGE, 'M', 1.0, 0, ""));
         dogs.add(new Dog("", "Akita", Dog.GIANT, 'M', 0.5, 0, ""));
         dogs.add(new Dog("", "Mix", Dog.SMALL, 'F', 0.3, 0,""));
         dogs.add(new Dog("Mr. T", "Bulldog", Dog.MEDIUM, 'M', 6.0,0,""));
         dogs.add(new Dog("Java", "Poodle", Dog.MEDIUM, 'M', 3.0, 1, "Neurological"));
         dogs.add(new Dog("Nelly", "Great Dane", Dog.GIANT, 'F', 0.6, 0,""));
         dogs.add(new Dog("Lucy", "Bassett", Dog.MEDIUM, 'M', 1.3, 1,"Missing Leg"));
         dogs.add(new Dog("Sandy", "Mix", Dog.MINATURE, 'F', 6.0, 0, ""));
      
      	
      
      	
      }
   }

Open in new window

0
robthewolfCommented:
you only add the buttons themselves to the gui the group just has to exist to manage the switching properly.
you need to change this line:
         ButtonGroup group = new ButtonGroup();
to:
         group = new ButtonGroup();
and change this line:
         JPanel radioPanel = new JPanel();
To:
         radioPanel = new JPanel();

otherwise the instance variable will not be instantiated and will remain as null.

you havent set a layout manager as far as i can tell so it might look a bit weird until you sort it out.  I recommend using a visual editor that you can download for eclipse (and i think net beans).  This will help you make it look right.

0
robthewolfCommented:
this is a completely new question.  please close this one and ask a new question.  it is not fair on the experts to keep asking these questions
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.