PetGUIDriver.java:16: cannot find symbol
symbol : method getMenu()
location: class PetAdoptionGUI
frame.setJMenuBar(guiPanel.getMenu());
^
PetAdoptionGUI.java:159: cannot find symbol
symbol : class SelectionListener
location: class PetAdoptionGUI.ButtonListener.SelectedItemListener
AnimalListDisplay.addJListSelectionListener(new SelectionListener());
^
2 errors
Here's the GUI and the Driver:
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.ArrayList;
import javax.swing.JMenuBar;
public class PetGUIDriver{
public static void main(String args[]){
PetAdoptionGUI guiPanel = new PetAdoptionGUI();
JFrame frame = new JFrame("Animal Adoption");
frame.getContentPane().add(guiPanel);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
frame.setJMenuBar(guiPanel.getMenu());
}
}
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.ArrayList;
import javax.swing.border.TitledBorder;
import java.awt.List;
public class PetAdoptionGUI extends JPanel{
private AnimalListDisplay displayList;
private JScrollPane scroller;
private ArrayList<Animal> aList;
private JButton ageButton, sizeButton;
private JCheckBox specialNeeds, showDogs, showCats, showBirds;
private JPanel buttonPanel, checkPanel;
private JMenuItem read, write;
private JButton addAnimal;
private InputPanel panel;
private static final int LARGE_VERTICAL_SPACE = 60, SMALL_VERTICAL_SPACE = 20,
X_DIMENSION = 600, Y_DIMENSION = 400;
public PetAdoptionGUI(){
populateList();
displayList.setListData(aList.toArray());
// instantiate GUI components
scroller = new JScrollPane(displayList);
panel = new InputPanel();
buttonPanel = new JPanel();
TitledBorder sortBorder = BorderFactory.createTitledBorder("Sort Options");
buttonPanel.setBorder(sortBorder);
sizeButton = new JButton("Size");
ageButton = new JButton("Age");
checkPanel = new JPanel();
checkPanel.setLayout(new BoxLayout(checkPanel, BoxLayout.Y_AXIS));
sortBorder = BorderFactory.createTitledBorder("Filter Options");
checkPanel.setBorder(sortBorder);
specialNeeds = new JCheckBox("Special needs only");
showDogs = new JCheckBox("Show Dogs");
showCats = new JCheckBox("Show Cats");
showBirds = new JCheckBox("Show Birds");
showDogs.setSelected(true);
showCats.setSelected(true);
showBirds.setSelected(true);
this.setLayout(new BorderLayout());
this.add(scroller, BorderLayout.CENTER);
checkPanel.add(Box.createVerticalStrut(SMALL_VERTICAL_SPACE));
checkPanel.add(specialNeeds);
checkPanel.add(Box.createVerticalStrut(LARGE_VERTICAL_SPACE));
checkPanel.add(showDogs);
checkPanel.add(Box.createVerticalStrut(SMALL_VERTICAL_SPACE));
checkPanel.add(showCats);
checkPanel.add(Box.createVerticalStrut(SMALL_VERTICAL_SPACE));
checkPanel.add(showBirds);
this.add(checkPanel, BorderLayout.EAST);
buttonPanel.add(sizeButton, BorderLayout.SOUTH);
buttonPanel.add(ageButton, BorderLayout.SOUTH);
this.add(buttonPanel, BorderLayout.SOUTH);
this.add(panel, BorderLayout.WEST);
this.setPreferredSize(new Dimension(X_DIMENSION,Y_DIMENSION));
specialNeeds.addItemListener(new CheckBoxListener());
showBirds.addItemListener(new CheckBoxListener());
showDogs.addItemListener(new CheckBoxListener());
showCats.addItemListener(new CheckBoxListener());
sizeButton.addActionListener(new ButtonListener());
ageButton.addActionListener(new ButtonListener());
}
// public Bird(int aniID, int aniAge, int aniSize, Boolean aniNeeds, String animalDesc,String type)
private void populateList(){
ArrayList<Animal> list = new ArrayList<Animal>();
list.add(new Bird(1001, 5, 7, true,"", "PARROT"));
list.add(new Bird(1002, 3, 7, true, "", "Small Bird"));
list.add(new Bird(1003, 2, 7, true,"", "Outdoor Bird"));
list.add(new Bird(1004, 1, 7, false,"One Leg", "Outdoor Bird"));
list.add(new Bird(1005, 1, 7, false,"One Eye", "Parrot"));
list.add(new Cat(1006, 2, 6, true, "", "Syphnx", "Mel", 11, "Indoor Only"));
list.add(new Cat(1007, 1, 6, true, "", "Persian", "General", 12, "Indoor Only"));
list.add(new Cat(1008, 3, 6, false, "", "Unknown", "Killer", 13, "Indoor Only"));
list.add(new Cat(1009, 1, 6, false, "", "Unknown", "Oust", 14, "Outdoor/Indoor"));
list.add(new Cat(1010, 1, 6, false, "", "Unknown", "Lysol", 15, "Outdoor/Indoor"));
list.add(new Dog(1011, 1, 1, false, "", "Pitbull", "Sky", 17, false));
list.add(new Dog(1012, 2, 2, false, "", "Pitbull", "Riley", 18, false));
list.add(new Dog(1013, 3, 3, false, "", "Pitbull", "", 19, false));
list.add(new Dog(1014, 4, 4, false, "", "Pitbull", "Washington", 20, false));
list.add(new Dog(1015, 5, 5, false, "", "Pitbull", "Sprite", 21, false));
// add them to an array list
aList = list;
displayList = new AnimalListDisplay(list);
// send the arraylist to AnimalListDisplay
}
private class CheckBoxListener implements ItemListener
{
public void itemStateChanged(ItemEvent event)
{
if(event.getSource() == specialNeeds)
{
displayList.filterSpecialNeeds();
}
else if(event.getSource() == showDogs)
{
displayList.filterDogs();
}
else if(event.getSource() == showCats)
{
displayList.filterCats();
}
}
}
private class ButtonListener implements ActionListener
{
public void actionPerformed(ActionEvent eve)
{
if(eve.getSource() == sizeButton)
{
displayList.sortSize();
}
else if(eve.getSource() == ageButton)
{
displayList.sortAge();
}
}
private class SelectedItemListener implements ActionListener
{
public void actionPerformed(ActionEvent sel)
{
AnimalListDisplay.addJListSelectionListener(new SelectionListener());
}
}
public JMenuBar getMenu(){
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
read = new JMenuItem("Read from file");
write = new JMenuItem("Write from file");
menuBar.add(fileMenu);
fileMenu.add(read);
fileMenu.add(write);
return menuBar;
}
}
}

New Topic/Question
Reply




MultiQuote



|