diff --git a/MooBreeder.java b/MooBreeder.java index fb3e8e2..16dd73d 100755 --- a/MooBreeder.java +++ b/MooBreeder.java @@ -15,13 +15,14 @@ import java.awt.event.*; import javax.swing.*; -public class MooBreeder extends JFrame +public class MooBreeder extends JFrame implements MouseListener { private JMenuBar menubar; private JMenu fileMenu, helpMenu; private JMenuItem reset, quit, help, about; - private Box herdBox, parentBox, offspringBox; - private Box motherBox, fatherBox, child1Box, child2Box; + private JPanel breedPanel; + private JScrollPane herdScroller; + private Box herdBox, motherBox, fatherBox, calf1Box, calf2Box; private JButton add, breed, keep, remove; public static void main(String[] args) @@ -90,14 +91,22 @@ private void createLayout() { //TODO + this.setLayout(new BoxLayout(this.getContentPane(), BoxLayout.X_AXIS)); herdBox = new Box(BoxLayout.Y_AXIS); - Box breedBox = new Box(BoxLayout.Y_AXIS); - parentBox = new Box(BoxLayout.Y_AXIS); - offspringBox = new Box(BoxLayout.Y_AXIS); - this.add(herdBox, BorderLayout.WEST); - this.add(breedBox, BorderLayout.EAST); - breedBox.add(parentBox); - breedBox.add(offspringBox); + herdScroller = new JScrollPane(herdBox, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, + ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); + herdScroller.setWheelScrollingEnabled(true); + this.add(herdScroller); + breedPanel = new JPanel(new GridLayout(2,2)); + fatherBox = new Box(BoxLayout.Y_AXIS); + motherBox = new Box(BoxLayout.Y_AXIS); + calf1Box = new Box(BoxLayout.Y_AXIS); + calf2Box = new Box(BoxLayout.Y_AXIS); + breedPanel.add(fatherBox); + breedPanel.add(motherBox); + breedPanel.add(calf1Box); + breedPanel.add(calf2Box); + this.add(breedPanel); updateGUI(); } @@ -118,16 +127,20 @@ private void updateParentBox() { //TODO - JLabel label = new JLabel("Parents"); - parentBox.add(label); + JLabel dl = new JLabel("Father"); + JLabel ml = new JLabel("Mother"); + fatherBox.add(dl); + motherBox.add(ml); } private void updateOffspringBox() { //TODO - JLabel label = new JLabel("Offspring"); - offspringBox.add(label); + JLabel l1 = new JLabel("Calf 1"); + JLabel l2 = new JLabel("Calf 2"); + calf1Box.add(l1); + calf2Box.add(l2); } private void resetGame() @@ -136,4 +149,36 @@ updateGUI(); } + private Box getCowBox(Cow c) + { + //TODO + Box cowBox = new Box(BoxLayout.Y_AXIS); + cowBox.addMouseListener(this); + return cowBox; + } + + /* + * MouseListener methods + */ + + @Override + public void mouseClicked(MouseEvent me) + { + //TODO + //getSource() + //getClickCount() + } + + @Override + public void mouseEntered(MouseEvent arg0) {} + + @Override + public void mouseExited(MouseEvent arg0) {} + + @Override + public void mousePressed(MouseEvent arg0) {} + + @Override + public void mouseReleased(MouseEvent arg0) {} + }