package garten.model; | package garten.model; | ||||
import garten.view.Fenster; | import garten.view.Fenster; | ||||
import garten.view.FlaecheBeet; | |||||
import garten.view.FlaechePflanzen; | |||||
import garten.view.FlaecheWeg; | |||||
import garten.view.GUI; | |||||
import java.awt.MouseInfo; | |||||
import java.awt.event.ActionEvent; | import java.awt.event.ActionEvent; | ||||
import java.awt.event.ActionListener; | import java.awt.event.ActionListener; | ||||
import java.awt.event.MouseEvent; | import java.awt.event.MouseEvent; | ||||
* | * | ||||
* @author Jan | * @author Jan | ||||
*/ | */ | ||||
public class Gaertner implements MouseMotionListener, MouseListener, | |||||
ActionListener | |||||
public class Gaertner implements MouseMotionListener, MouseListener,ActionListener | |||||
{ | { | ||||
private Garten meinGarten; | private Garten meinGarten; | ||||
private Fenster fenster; | private Fenster fenster; | ||||
private boolean pflanzebewegt; | private boolean pflanzebewegt; | ||||
private boolean gartenexistiert; | private boolean gartenexistiert; | ||||
private boolean bepflanzungexistiert; | private boolean bepflanzungexistiert; | ||||
private Beet bepflanzeBeet; | |||||
MouseEvent koordinbeet; //x,y Koordinaten reichen eigentlich | MouseEvent koordinbeet; //x,y Koordinaten reichen eigentlich | ||||
private int[] aktuellesBeet; | |||||
Pflanze1 pfl1; | Pflanze1 pfl1; | ||||
Pflanze2 pfl2; | Pflanze2 pfl2; | ||||
Pflanze3 pfl3; | Pflanze3 pfl3; | ||||
int height; | int height; | ||||
int width; | int width; | ||||
GUI gui; | |||||
public Gaertner(Fenster fenster, FlaecheBeet flbeet, FlaecheWeg flweg, | |||||
FlaechePflanzen flpfl) | |||||
public Gaertner(Fenster fenster) | |||||
{ | { | ||||
meinGarten = new Garten(flbeet, flweg, flpfl); | |||||
this.fenster = fenster; //Zur späteren Steuerung Pop up usw. | |||||
this.fenster = fenster; | |||||
meinGarten = new Garten(fenster.getFlbeet(), fenster.getFlweg(), fenster.getFlpfl()); | |||||
//this.gui = gui; | |||||
//meinGarten = new Garten(gui.getFlaecheBeet2(), gui.getFlaecheWeg1(), gui.getFlaechePflanzen1()); | |||||
pflanzebewegt = false; | pflanzebewegt = false; | ||||
gartenexistiert = false; | gartenexistiert = false; | ||||
bepflanzungexistiert = false; | bepflanzungexistiert = false; | ||||
aktuellesBeet = new int[2]; | |||||
} | } | ||||
public void registerEvents() | public void registerEvents() | ||||
fenster.addMouseListener(this); | fenster.addMouseListener(this); | ||||
fenster.addMouseMotionListener(this); | fenster.addMouseMotionListener(this); | ||||
//fenster.getFlbeet().addMouseListener(this); | |||||
//fenster.getFlpfl().addMouseListener(this); | |||||
//fenster.getFlweg().addMouseListener(this); | |||||
fenster.getMnGartenanlegen().addActionListener(this); | fenster.getMnGartenanlegen().addActionListener(this); | ||||
fenster.getMnRandomPflanzenanlegen().addActionListener(this); | fenster.getMnRandomPflanzenanlegen().addActionListener(this); | ||||
fenster.getBtnbepfl2().addActionListener(this); | fenster.getBtnbepfl2().addActionListener(this); | ||||
fenster.getBtnbepfl3().addActionListener(this); | fenster.getBtnbepfl3().addActionListener(this); | ||||
fenster.getRadiobtn1pfl1().addActionListener(this); | |||||
fenster.getRadiobtn1pfl2().addActionListener(this); | |||||
fenster.getRadiobtn1pfl3().addActionListener(this); | |||||
fenster.getRadiobtn2pfl1().addActionListener(this); | |||||
fenster.getRadiobtn2pfl2().addActionListener(this); | |||||
fenster.getRadiobtn2pfl3().addActionListener(this); | |||||
fenster.getRadiobtn3pfl1().addActionListener(this); | |||||
fenster.getRadiobtn3pfl2().addActionListener(this); | |||||
fenster.getRadiobtn3pfl3().addActionListener(this); | |||||
fenster.getRadiobtn4pfl3().addActionListener(this); | |||||
fenster.getRadiobtn1pfl1().setVisible(true); | |||||
/* | |||||
gui.addMouseListener(this); | |||||
gui.addMouseMotionListener(this); | |||||
gui.getMnGartenanlegen().addActionListener(this); | |||||
gui.getMnRandomPflanzenanlegen().addActionListener(this); | |||||
gui.getBtnbepfl1().addActionListener(this); | |||||
gui.getBtnbepfl2().addActionListener(this); | |||||
gui.getBtnbepfl3().addActionListener(this); | |||||
gui.getRadiobtn1pfl1().addActionListener(this); | |||||
gui.getRadiobtn1pfl2().addActionListener(this); | |||||
gui.getRadiobtn1pfl3().addActionListener(this); | |||||
gui.getRadiobtn2pfl1().addActionListener(this); | |||||
gui.getRadiobtn2pfl2().addActionListener(this); | |||||
gui.getRadiobtn2pfl3().addActionListener(this); | |||||
gui.getRadiobtn3pfl1().addActionListener(this); | |||||
gui.getRadiobtn3pfl2().addActionListener(this); | |||||
gui.getRadiobtn3pfl3().addActionListener(this); | |||||
gui.getRadiobtn4pfl3().addActionListener(this); | |||||
*/ | |||||
} | } | ||||
@Override | @Override | ||||
public void mouseClicked(MouseEvent e) | public void mouseClicked(MouseEvent e) | ||||
{ | { | ||||
System.out.println("MouseEvent"); | |||||
if (SwingUtilities.isRightMouseButton(e))//Bei Rechtsklick Popup Menü | if (SwingUtilities.isRightMouseButton(e))//Bei Rechtsklick Popup Menü | ||||
{ | { | ||||
koordinbeet =e; //abspeichern wegen koordinaten zur weiterverarbeitung | |||||
//Zwischenspeichern der Koordinaten der Maus um Beet zu finden | |||||
aktuellesBeet[0] = MouseInfo.getPointerInfo().getLocation().x; | |||||
System.out.println("Beet x: " + aktuellesBeet[0]); | |||||
aktuellesBeet[1] = MouseInfo.getPointerInfo().getLocation().y; | |||||
System.out.println("Beet y: " + aktuellesBeet[1]); | |||||
fenster.showPoPup(e); | fenster.showPoPup(e); | ||||
} | } | ||||
else | else | ||||
public void actionPerformed(ActionEvent e) | public void actionPerformed(ActionEvent e) | ||||
{ | { | ||||
Object key = e.getSource(); | Object key = e.getSource(); | ||||
if (key.equals(fenster.getMnGartenanlegen())) //Garten anlegen | |||||
//Garten anlegen | |||||
if (key.equals(fenster.getMnGartenanlegen())) | |||||
{ | { | ||||
if (gartenexistiert == false) | if (gartenexistiert == false) | ||||
{ | { | ||||
} | } | ||||
} | } | ||||
} | } | ||||
else if (key.equals(fenster.getMnRandomPflanzenanlegen())) //Garten Random Bepflanzen | |||||
//Garten Random Bepflanzen | |||||
else if (key.equals(fenster.getMnRandomPflanzenanlegen())) | |||||
{ | { | ||||
if (gartenexistiert == true && bepflanzungexistiert == false) //falls garten existiert bepflanzen | if (gartenexistiert == true && bepflanzungexistiert == false) //falls garten existiert bepflanzen | ||||
{ | { | ||||
JOptionPane.showConfirmDialog(fenster, "Erst muss ein Garten angelegt werden", "Info", JOptionPane.DEFAULT_OPTION); | JOptionPane.showConfirmDialog(fenster, "Erst muss ein Garten angelegt werden", "Info", JOptionPane.DEFAULT_OPTION); | ||||
} | } | ||||
} | } | ||||
else if (key.equals(fenster.getBtnbepfl1()) || key.equals(fenster.getBtnbepfl2()) ||key.equals(fenster.getBtnbepfl3())) | |||||
//Ein einzelnes Beet bepflanzen | |||||
else if ((key.equals(fenster.getBtnbepfl1()) || key.equals(fenster.getBtnbepfl2()) || key.equals(fenster.getBtnbepfl3())) && gartenexistiert) | |||||
{ | { | ||||
int alter = 0; | |||||
int pflanzentyp = 0; | |||||
int laenge = 0; | |||||
//Pflanzentyp festlegen + Länge festlegen | |||||
if (key.equals(fenster.getBtnbepfl1())) | |||||
{ | |||||
pflanzentyp = 1; | |||||
laenge = Integer.valueOf(JOptionPane.showInputDialog("Start Länge von 30 - 50")); | |||||
} | |||||
else if (key.equals(fenster.getBtnbepfl2())) | |||||
{ | |||||
pflanzentyp = 2; | |||||
laenge = Integer.valueOf(JOptionPane.showInputDialog("Start Länge von 10 - 20")); | |||||
} | |||||
else if (key.equals(fenster.getBtnbepfl3())) | |||||
{ | |||||
pflanzentyp = 3; | |||||
laenge = Integer.valueOf(JOptionPane.showInputDialog("Start Länge von 10 - 20")); | |||||
} | |||||
//alter bekommen | |||||
if (fenster.getRadiobtn1pfl1().isSelected() || fenster.getRadiobtn1pfl2().isSelected() || fenster.getRadiobtn1pfl3().isSelected()) | |||||
{ | |||||
alter = 1; | |||||
} | |||||
else if (fenster.getRadiobtn2pfl1().isSelected() || fenster.getRadiobtn2pfl2().isSelected() || fenster.getRadiobtn2pfl3().isSelected()) | |||||
{ | |||||
alter = 2; | |||||
} | |||||
else if (fenster.getRadiobtn3pfl1().isSelected() || fenster.getRadiobtn3pfl2().isSelected() || fenster.getRadiobtn3pfl3().isSelected()) | |||||
{ | |||||
alter = 3; | |||||
} | |||||
else if (fenster.getRadiobtn4pfl3().isSelected()) | |||||
{ | |||||
alter = 4; | |||||
} | |||||
System.out.println("Pflanzentyp : " + pflanzentyp + " Alter: " + alter + " Länge: " + laenge); | |||||
PflanzengruppenKonfigurator konfig = new PflanzengruppenKonfigurator(); | |||||
konfig.alter(alter); | |||||
konfig.pflanzenTyp(pflanzentyp); | |||||
konfig.startlaenge(laenge); | |||||
konfig.erstellen(); | |||||
System.out.println("Das gefundene Beet : " + meinGarten.getBeet(aktuellesBeet)); | |||||
System.out.println("Alle beete" + meinGarten.getBeete()); | |||||
System.out.println("Pflanze konfiguriert"); | |||||
bepflanzungexistiert = true; | |||||
} | } | ||||
} | } | ||||
{ | { | ||||
flbeet.zeichneBeete(beete); | flbeet.zeichneBeete(beete); | ||||
} | } | ||||
/* | |||||
public int getBeet(MouseEvent e) | |||||
public Beet getBeet(int[] mausposition) | |||||
{ | { | ||||
Beet tempBeet; | |||||
System.out.println("Suche richtiges Beet"); | |||||
Beet tempBeet = null; | |||||
for (Beet b : beete) | for (Beet b : beete) | ||||
{ | { | ||||
tempBeet = b; | |||||
} | |||||
//return tempBeet; | |||||
int[] koordinvergleich = b.getKoordinaten(); | |||||
System.out.println("Maus: " +mausposition[0] +" " + mausposition[1]); | |||||
System.out.println("Beet: " +koordinvergleich[0]+" " + koordinvergleich[1]+" " + koordinvergleich[2]+" " + koordinvergleich[3]); | |||||
if(koordinvergleich[0]<mausposition[0] && koordinvergleich[1]<mausposition[1] && (koordinvergleich[2]+koordinvergleich[0]) >mausposition[0] && (koordinvergleich[3]+koordinvergleich[1]) > mausposition[1] ) | |||||
{ | |||||
System.err.println("Kommt zum Vergleich?"); | |||||
tempBeet = b; | |||||
} | |||||
} | |||||
return tempBeet; | |||||
} | } | ||||
//Funktionen Wege | //Funktionen Wege | ||||
*/ | |||||
public void hinzufuegenWeg(int sx, int sy, int ex, int ey) | public void hinzufuegenWeg(int sx, int sy, int ex, int ey) | ||||
{ | { | ||||
Weg neuerWeg = new Weg(sx, sy, ex, ey); | Weg neuerWeg = new Weg(sx, sy, ex, ey); |
package garten.model; | package garten.model; | ||||
import java.util.ArrayList; | |||||
/** | /** | ||||
* | * | ||||
* @author Jan | * @author Jan | ||||
private int pflanzentyp; | private int pflanzentyp; | ||||
private int startlaenge; | private int startlaenge; | ||||
private ArrayList<Pflanze> pflanzen; | |||||
private Beet beet; | |||||
Pflanze1 pfl1; | Pflanze1 pfl1; | ||||
Pflanze2 pfl2; | Pflanze2 pfl2; | ||||
Pflanze3 pfl3; | Pflanze3 pfl3; | ||||
Pflanzengruppe(int pflanzenTyp,int alter, int startlaenge) | |||||
Pflanzengruppe(int pflanzenTyp,int alter, int startlaenge, Beet beet) | |||||
{ | { | ||||
this.alter = alter; | this.alter = alter; | ||||
this.pflanzentyp = pflanzenTyp; | this.pflanzentyp = pflanzenTyp; | ||||
this.startlaenge = startlaenge; | this.startlaenge = startlaenge; | ||||
this.beet = beet; | |||||
} | } | ||||
public void anzeigen() | public void anzeigen() | ||||
{ | { | ||||
} | } | ||||
public void beginnebepflanzung() | |||||
public ArrayList<Pflanze> beginnebepflanzung() | |||||
{ | { | ||||
beet.getKoordinaten(); | |||||
if(pflanzentyp == 1) | |||||
{ | |||||
pfl1 = new Pflanze1(alter, alter, alter, startlaenge); | |||||
pflanzen.add(pfl1); | |||||
} | |||||
else if (pflanzentyp ==2) | |||||
{ | |||||
pfl2 = new Pflanze2(alter, alter, alter, startlaenge); | |||||
pflanzen.add(pfl1); | |||||
} | |||||
else if (pflanzentyp ==3) | |||||
{ | |||||
pfl3 = new Pflanze3(alter, alter, alter, startlaenge); | |||||
pflanzen.add(pfl1); | |||||
} | |||||
return pflanzen; | |||||
} | } | ||||
} | } |
private int alter = 1; | private int alter = 1; | ||||
private int pflanzenTyp =1; | private int pflanzenTyp =1; | ||||
private int startlaenge =1; | private int startlaenge =1; | ||||
private Beet beet; | |||||
public PflanzengruppenKonfigurator() | public PflanzengruppenKonfigurator() | ||||
{ | { | ||||
} | } | ||||
public Pflanzengruppe erstellen() throws IllegalArgumentException | |||||
public Pflanzengruppe erstellen() throws IllegalArgumentException | |||||
{ | { | ||||
konfigurationPruefen(); | konfigurationPruefen(); | ||||
Pflanzengruppe pflgruppe = new Pflanzengruppe(pflanzenTyp,alter,startlaenge); | |||||
Pflanzengruppe pflgruppe = new Pflanzengruppe(pflanzenTyp,alter,startlaenge,beet); | |||||
return pflgruppe; | return pflgruppe; | ||||
} | } | ||||
this.startlaenge = startlaenge; | this.startlaenge = startlaenge; | ||||
return this; | return this; | ||||
} | } | ||||
public PflanzengruppenKonfigurator beet(Beet beet) | |||||
{ | |||||
this.beet = beet; | |||||
return this; | |||||
} | |||||
private void konfigurationPruefen() throws IllegalArgumentException | private void konfigurationPruefen() throws IllegalArgumentException | ||||
{ | { |
import garten.view.FlaecheBeet; | import garten.view.FlaecheBeet; | ||||
import garten.view.FlaechePflanzen; | import garten.view.FlaechePflanzen; | ||||
import garten.view.FlaecheWeg; | import garten.view.FlaecheWeg; | ||||
import java.awt.Color; | |||||
import java.awt.Container; | |||||
import javax.swing.OverlayLayout; | |||||
import javax.swing.JOptionPane; | |||||
import javax.swing.UIManager; | |||||
/** | /** | ||||
* Builder Class | * Builder Class | ||||
{ | { | ||||
public start() | public start() | ||||
{ | { | ||||
Color hintergrund = new Color(34, 139, 34); | |||||
FlaecheBeet flbeet = new FlaecheBeet(); | FlaecheBeet flbeet = new FlaecheBeet(); | ||||
FlaecheWeg flweg = new FlaecheWeg(); | FlaecheWeg flweg = new FlaecheWeg(); | ||||
FlaechePflanzen flpflanzen = new FlaechePflanzen(); | FlaechePflanzen flpflanzen = new FlaechePflanzen(); | ||||
Fenster view = new Fenster(); | |||||
flpflanzen.setOpaque(false); | |||||
flbeet.setOpaque(false); | |||||
flbeet.setComponentPopupMenu(view.getPopup()); | |||||
flweg.setOpaque(false); | |||||
Container hauptkiste = view.getContentPane(); | |||||
hauptkiste.setLayout(new OverlayLayout(hauptkiste)); | |||||
hauptkiste.setBackground(hintergrund); | |||||
hauptkiste.add(flpflanzen); | |||||
hauptkiste.add(flbeet); | |||||
hauptkiste.add(flweg); | |||||
Fenster fenster = new Fenster(flbeet,flweg,flpflanzen); | |||||
Gaertner ga = new Gaertner(fenster); | |||||
Gaertner ga = new Gaertner(view,flbeet,flweg,flpflanzen); | |||||
ga.registerEvents(); | ga.registerEvents(); | ||||
//GUI gui = new GUI(); | |||||
//Gaertner ga = new Gaertner(gui); | |||||
//ga.registerEvents(); | |||||
//gui.setBackground(Color.yellow); | |||||
//gui.setSize(1000, 1000); | |||||
//ga.registerEvents(); | |||||
//gui.setVisible(true); | |||||
} | } | ||||
/** | /** | ||||
*/ | */ | ||||
public static void main(String[] args) | public static void main(String[] args) | ||||
{ | { | ||||
try | |||||
{ | |||||
for (UIManager.LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) { | |||||
if ("Nimbus".equals(info.getName())) { | |||||
UIManager.setLookAndFeel(info.getClassName()); | |||||
} | |||||
} | |||||
} | |||||
catch(Exception ex) | |||||
{ | |||||
JOptionPane.showMessageDialog(null, "Fehler!!!"); | |||||
} | |||||
new start(); | new start(); | ||||
} | } | ||||
} | } |
*/ | */ | ||||
package garten.view; | package garten.view; | ||||
import java.awt.Color; | |||||
import java.awt.Container; | |||||
import java.awt.MouseInfo; | import java.awt.MouseInfo; | ||||
import java.awt.event.MouseAdapter; | |||||
import java.awt.event.MouseEvent; | import java.awt.event.MouseEvent; | ||||
import javax.swing.ButtonGroup; | import javax.swing.ButtonGroup; | ||||
import javax.swing.JButton; | import javax.swing.JButton; | ||||
import javax.swing.JMenuItem; | import javax.swing.JMenuItem; | ||||
import javax.swing.JPopupMenu; | import javax.swing.JPopupMenu; | ||||
import javax.swing.JRadioButton; | import javax.swing.JRadioButton; | ||||
import javax.swing.OverlayLayout; | |||||
/** | /** | ||||
* | * | ||||
*/ | */ | ||||
public class Fenster extends JFrame | public class Fenster extends JFrame | ||||
{ | { | ||||
JPopupMenu popup; | |||||
JMenu mnbepflanzen1; | |||||
JMenu mnbepflanzen2; | |||||
JMenu mnbepflanzen3; | |||||
JMenuItem mnGartenanlegen; | |||||
JMenuItem mnRandomPflanzenanlegen; | |||||
JButton btnbepfl1; | |||||
JButton btnbepfl2; | |||||
JButton btnbepfl3; | |||||
JRadioButton radiobtn1pfl1; | |||||
JRadioButton radiobtn2pfl1; | |||||
JRadioButton radiobtn3pfl1; | |||||
JRadioButton radiobtn4pfl1; | |||||
JRadioButton radiobtn1pfl2; | |||||
JRadioButton radiobtn2pfl2; | |||||
JRadioButton radiobtn3pfl2; | |||||
JRadioButton radiobtn4pfl2; | |||||
JRadioButton radiobtn1pfl3; | |||||
JRadioButton radiobtn2pfl3; | |||||
JRadioButton radiobtn3pfl3; | |||||
JRadioButton radiobtn4pfl3; | |||||
public Fenster() | |||||
final public JPopupMenu popup; | |||||
public JMenu mnbepflanzen1; | |||||
public JMenu mnbepflanzen2; | |||||
public JMenu mnbepflanzen3; | |||||
public JMenuItem mnGartenanlegen; | |||||
public JMenuItem mnRandomPflanzenanlegen; | |||||
public JButton btnbepfl1; | |||||
public JButton btnbepfl2; | |||||
public JButton btnbepfl3; | |||||
private JRadioButton radiobtn1pfl1; | |||||
private JRadioButton radiobtn2pfl1; | |||||
private JRadioButton radiobtn3pfl1; | |||||
private JRadioButton radiobtn1pfl2; | |||||
private JRadioButton radiobtn2pfl2; | |||||
private JRadioButton radiobtn3pfl2; | |||||
private JRadioButton radiobtn1pfl3; | |||||
private JRadioButton radiobtn2pfl3; | |||||
private JRadioButton radiobtn3pfl3; | |||||
private JRadioButton radiobtn4pfl3; | |||||
private FlaecheBeet flbeet; | |||||
private FlaecheWeg flweg; | |||||
private FlaechePflanzen flpfl; | |||||
Color hintergrund; | |||||
public Fenster(FlaecheBeet flbeet, FlaecheWeg flweg, FlaechePflanzen flpfl) | |||||
{ | { | ||||
//PoPupMenü | |||||
popup = new JPopupMenu(); | |||||
hintergrund = new Color(34, 139, 34); | |||||
this.flbeet = flbeet; | |||||
this.flweg = flweg; | |||||
this.flpfl = flpfl; | |||||
flbeet.setOpaque(false); | |||||
flweg.setOpaque(false); | |||||
flpfl.setOpaque(false); | |||||
Container c = this.getContentPane(); | |||||
c.setLayout(new OverlayLayout(c)); | |||||
c.add(flpfl); | |||||
c.add(flbeet); | |||||
c.add(flweg); | |||||
c.setBackground(hintergrund); | |||||
popup = new JPopupMenu(); | |||||
mnGartenanlegen = new JMenuItem("Garten anlegen"); | mnGartenanlegen = new JMenuItem("Garten anlegen"); | ||||
mnRandomPflanzenanlegen = new JMenuItem("Random Bepflanzung"); | mnRandomPflanzenanlegen = new JMenuItem("Random Bepflanzung"); | ||||
popup.add(mnGartenanlegen); | popup.add(mnGartenanlegen); | ||||
popup.addSeparator(); | popup.addSeparator(); | ||||
popup.add(mnRandomPflanzenanlegen); | popup.add(mnRandomPflanzenanlegen); | ||||
popup.addSeparator(); | popup.addSeparator(); | ||||
//PopUpmenü Pflanze 1 | //PopUpmenü Pflanze 1 | ||||
mnbepflanzen1 = new JMenu("Bepflanze mit Pflanze1"); | mnbepflanzen1 = new JMenu("Bepflanze mit Pflanze1"); | ||||
btnbepfl1 = new JButton("Bepflanzen"); | btnbepfl1 = new JButton("Bepflanzen"); | ||||
radiobtn1pfl1 = new JRadioButton("1 Jahr alt"); | radiobtn1pfl1 = new JRadioButton("1 Jahr alt"); | ||||
radiobtn2pfl1 = new JRadioButton("2 Jahre alt"); | radiobtn2pfl1 = new JRadioButton("2 Jahre alt"); | ||||
radiobtn3pfl1= new JRadioButton("3 Jahre alt"); | |||||
radiobtn4pfl1 = new JRadioButton("4 Jahre alt"); | |||||
radiobtn3pfl1 = new JRadioButton("3 Jahre alt"); | |||||
//Btn Gruppe Pflanz1 | //Btn Gruppe Pflanz1 | ||||
ButtonGroup radiobtngrp1 = new ButtonGroup(); | ButtonGroup radiobtngrp1 = new ButtonGroup(); | ||||
radiobtngrp1.add(radiobtn1pfl1); | radiobtngrp1.add(radiobtn1pfl1); | ||||
radiobtngrp1.add(radiobtn2pfl1); | radiobtngrp1.add(radiobtn2pfl1); | ||||
radiobtngrp1.add(radiobtn3pfl1); | radiobtngrp1.add(radiobtn3pfl1); | ||||
radiobtngrp1.add(radiobtn4pfl1); | |||||
//Alle Elemente zu PopUpmenü Pflanze 1 hinzufügen | //Alle Elemente zu PopUpmenü Pflanze 1 hinzufügen | ||||
mnbepflanzen1.add(radiobtn1pfl1); | mnbepflanzen1.add(radiobtn1pfl1); | ||||
mnbepflanzen1.add(radiobtn2pfl1); | mnbepflanzen1.add(radiobtn2pfl1); | ||||
mnbepflanzen1.add(radiobtn3pfl1); | mnbepflanzen1.add(radiobtn3pfl1); | ||||
mnbepflanzen1.add(radiobtn4pfl1); | |||||
mnbepflanzen1.add(btnbepfl1); | mnbepflanzen1.add(btnbepfl1); | ||||
//PopUpmenü Pflanze 2 | //PopUpmenü Pflanze 2 | ||||
mnbepflanzen2 = new JMenu("Bepflanze mit Pflanze2"); | mnbepflanzen2 = new JMenu("Bepflanze mit Pflanze2"); | ||||
btnbepfl2 = new JButton("Bepflanzen"); | btnbepfl2 = new JButton("Bepflanzen"); | ||||
radiobtn1pfl2 = new JRadioButton("1 Jahr alt"); | radiobtn1pfl2 = new JRadioButton("1 Jahr alt"); | ||||
radiobtn2pfl2 = new JRadioButton("2 Jahre alt"); | radiobtn2pfl2 = new JRadioButton("2 Jahre alt"); | ||||
radiobtn3pfl2= new JRadioButton("3 Jahre alt"); | |||||
radiobtn4pfl2= new JRadioButton("4 Jahre alt"); | |||||
radiobtn3pfl2 = new JRadioButton("3 Jahre alt"); | |||||
//Btn Gruppe Pflanz2 | //Btn Gruppe Pflanz2 | ||||
radiobtngrp1.add(radiobtn1pfl2); | radiobtngrp1.add(radiobtn1pfl2); | ||||
radiobtngrp1.add(radiobtn2pfl2); | radiobtngrp1.add(radiobtn2pfl2); | ||||
radiobtngrp1.add(radiobtn3pfl2); | radiobtngrp1.add(radiobtn3pfl2); | ||||
radiobtngrp1.add(radiobtn4pfl2); | |||||
//Alle Elemente zu PopUpmenü Pflanze 2 hinzufügen | //Alle Elemente zu PopUpmenü Pflanze 2 hinzufügen | ||||
mnbepflanzen2.add(radiobtn1pfl2); | mnbepflanzen2.add(radiobtn1pfl2); | ||||
mnbepflanzen2.add(radiobtn2pfl2); | mnbepflanzen2.add(radiobtn2pfl2); | ||||
mnbepflanzen2.add(radiobtn3pfl2); | mnbepflanzen2.add(radiobtn3pfl2); | ||||
mnbepflanzen2.add(radiobtn4pfl2); | |||||
mnbepflanzen2.add(btnbepfl2); | mnbepflanzen2.add(btnbepfl2); | ||||
//PopUpmenü Pflanze 3 | //PopUpmenü Pflanze 3 | ||||
mnbepflanzen3 = new JMenu("Bepflanze mit Pflanze3"); | mnbepflanzen3 = new JMenu("Bepflanze mit Pflanze3"); | ||||
btnbepfl3 = new JButton("Bepflanzen"); | btnbepfl3 = new JButton("Bepflanzen"); | ||||
radiobtn1pfl3 = new JRadioButton("1 Jahr alt"); | radiobtn1pfl3 = new JRadioButton("1 Jahr alt"); | ||||
radiobtn2pfl3 = new JRadioButton("2 Jahre alt"); | radiobtn2pfl3 = new JRadioButton("2 Jahre alt"); | ||||
radiobtn3pfl3= new JRadioButton("3 Jahre alt"); | |||||
radiobtn4pfl3= new JRadioButton("4 Jahre alt"); | |||||
radiobtn3pfl3 = new JRadioButton("3 Jahre alt"); | |||||
radiobtn4pfl3 = new JRadioButton("4 Jahre alt"); | |||||
//Btn Gruppe Pflanz3 | //Btn Gruppe Pflanz3 | ||||
radiobtngrp1.add(radiobtn1pfl3); | radiobtngrp1.add(radiobtn1pfl3); | ||||
radiobtngrp1.add(radiobtn2pfl3); | radiobtngrp1.add(radiobtn2pfl3); | ||||
mnbepflanzen3.add(radiobtn3pfl3); | mnbepflanzen3.add(radiobtn3pfl3); | ||||
mnbepflanzen3.add(radiobtn4pfl3); | mnbepflanzen3.add(radiobtn4pfl3); | ||||
mnbepflanzen3.add(btnbepfl3); | mnbepflanzen3.add(btnbepfl3); | ||||
//Alle PopUpmenüs dem PoPup hinzufügen | //Alle PopUpmenüs dem PoPup hinzufügen | ||||
popup.add(mnbepflanzen1); | popup.add(mnbepflanzen1); | ||||
popup.addSeparator(); | popup.addSeparator(); | ||||
popup.add(mnbepflanzen2); | popup.add(mnbepflanzen2); | ||||
popup.addSeparator(); | popup.addSeparator(); | ||||
popup.add(mnbepflanzen3); | popup.add(mnbepflanzen3); | ||||
popup.setLightWeightPopupEnabled(false); | |||||
//flbeet.setComponentPopupMenu(popup); | |||||
//popup.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); | |||||
this.setTitle("Garten von Paul und Jan"); | this.setTitle("Garten von Paul und Jan"); | ||||
this.pack(); | this.pack(); | ||||
this.setDefaultCloseOperation(EXIT_ON_CLOSE); | this.setDefaultCloseOperation(EXIT_ON_CLOSE); | ||||
this.setSize(900,900); | |||||
this.setSize(900, 900); | |||||
this.setVisible(true); | this.setVisible(true); | ||||
this.addMouseListener(new MouseAdapter() | |||||
{ | |||||
public void mouseClicked(MouseEvent e) | |||||
{ | |||||
popup.show(flbeet, e.getX(), e.getY()); | |||||
} | |||||
}); | |||||
this.add(popup); | |||||
} | } | ||||
public void showPoPup(MouseEvent e) | public void showPoPup(MouseEvent e) | ||||
{ | { | ||||
popup.setLocation(MouseInfo.getPointerInfo().getLocation().x,MouseInfo.getPointerInfo().getLocation().y); | |||||
popup.setLocation(MouseInfo.getPointerInfo().getLocation().x, MouseInfo.getPointerInfo().getLocation().y); | |||||
popup.setVisible(true); | popup.setVisible(true); | ||||
} | } | ||||
public void hidePopup() | public void hidePopup() | ||||
{ | { | ||||
popup.setVisible(false); | popup.setVisible(false); | ||||
} | } | ||||
public JPopupMenu getPopup() | public JPopupMenu getPopup() | ||||
{ | { | ||||
return popup; | return popup; | ||||
} | } | ||||
public JMenuItem getMnGartenanlegen() | |||||
/** | |||||
* @return the radiobtn1pfl1 | |||||
*/ | |||||
public JRadioButton getRadiobtn1pfl1() | |||||
{ | { | ||||
return mnGartenanlegen; | |||||
return radiobtn1pfl1; | |||||
} | } | ||||
public JMenuItem getMnRandomPflanzenanlegen() | |||||
/** | |||||
* @return the radiobtn2pfl1 | |||||
*/ | |||||
public JRadioButton getRadiobtn2pfl1() | |||||
{ | { | ||||
return mnRandomPflanzenanlegen; | |||||
return radiobtn2pfl1; | |||||
} | |||||
/** | |||||
* @return the radiobtn3pfl1 | |||||
*/ | |||||
public JRadioButton getRadiobtn3pfl1() | |||||
{ | |||||
return radiobtn3pfl1; | |||||
} | |||||
/** | |||||
* @return the radiobtn1pfl2 | |||||
*/ | |||||
public JRadioButton getRadiobtn1pfl2() | |||||
{ | |||||
return radiobtn1pfl2; | |||||
} | |||||
/** | |||||
* @return the radiobtn2pfl2 | |||||
*/ | |||||
public JRadioButton getRadiobtn2pfl2() | |||||
{ | |||||
return radiobtn2pfl2; | |||||
} | } | ||||
/** | |||||
* @return the radiobtn3pfl2 | |||||
*/ | |||||
public JRadioButton getRadiobtn3pfl2() | |||||
{ | |||||
return radiobtn3pfl2; | |||||
} | |||||
/** | |||||
* @return the radiobtn1pfl3 | |||||
*/ | |||||
public JRadioButton getRadiobtn1pfl3() | |||||
{ | |||||
return radiobtn1pfl3; | |||||
} | |||||
/** | |||||
* @return the radiobtn2pfl3 | |||||
*/ | |||||
public JRadioButton getRadiobtn2pfl3() | |||||
{ | |||||
return radiobtn2pfl3; | |||||
} | |||||
/** | |||||
* @return the radiobtn3pfl3 | |||||
*/ | |||||
public JRadioButton getRadiobtn3pfl3() | |||||
{ | |||||
return radiobtn3pfl3; | |||||
} | |||||
/** | |||||
* @return the radiobtn4pfl3 | |||||
*/ | |||||
public JRadioButton getRadiobtn4pfl3() | |||||
{ | |||||
return radiobtn4pfl3; | |||||
} | |||||
/** | |||||
* @return the mnbepflanzen1 | |||||
*/ | |||||
public JMenu getMnbepflanzen1() | public JMenu getMnbepflanzen1() | ||||
{ | { | ||||
return mnbepflanzen1; | return mnbepflanzen1; | ||||
} | } | ||||
/** | |||||
* @return the mnbepflanzen2 | |||||
*/ | |||||
public JMenu getMnbepflanzen2() | public JMenu getMnbepflanzen2() | ||||
{ | { | ||||
return mnbepflanzen2; | return mnbepflanzen2; | ||||
} | } | ||||
/** | |||||
* @return the mnbepflanzen3 | |||||
*/ | |||||
public JMenu getMnbepflanzen3() | public JMenu getMnbepflanzen3() | ||||
{ | { | ||||
return mnbepflanzen3; | return mnbepflanzen3; | ||||
} | } | ||||
/** | |||||
* @return the mnGartenanlegen | |||||
*/ | |||||
public JMenuItem getMnGartenanlegen() | |||||
{ | |||||
return mnGartenanlegen; | |||||
} | |||||
/** | |||||
* @return the mnRandomPflanzenanlegen | |||||
*/ | |||||
public JMenuItem getMnRandomPflanzenanlegen() | |||||
{ | |||||
return mnRandomPflanzenanlegen; | |||||
} | |||||
/** | |||||
* @return the btnbepfl1 | |||||
*/ | |||||
public JButton getBtnbepfl1() | public JButton getBtnbepfl1() | ||||
{ | { | ||||
return btnbepfl1; | return btnbepfl1; | ||||
} | } | ||||
public JButton getBtnbepfl2() | |||||
/** | |||||
* @param btnbepfl1 the btnbepfl1 to set | |||||
*/ | |||||
public void setBtnbepfl1(JButton btnbepfl1) | |||||
{ | { | ||||
return btnbepfl2; | |||||
this.btnbepfl1 = btnbepfl1; | |||||
} | } | ||||
public JButton getBtnbepfl3() | |||||
/** | |||||
* @return the btnbepfl2 | |||||
*/ | |||||
public JButton getBtnbepfl2() | |||||
{ | { | ||||
return btnbepfl2; | return btnbepfl2; | ||||
} | } | ||||
/** | |||||
* @return the btnbepfl3 | |||||
*/ | |||||
public JButton getBtnbepfl3() | |||||
{ | |||||
return btnbepfl3; | |||||
} | |||||
/** | |||||
* @return the flbeet | |||||
*/ | |||||
public FlaecheBeet getFlbeet() | |||||
{ | |||||
return flbeet; | |||||
} | |||||
/** | |||||
* @param flbeet the flbeet to set | |||||
*/ | |||||
public void setFlbeet(FlaecheBeet flbeet) | |||||
{ | |||||
this.flbeet = flbeet; | |||||
} | |||||
/** | |||||
* @return the flweg | |||||
*/ | |||||
public FlaecheWeg getFlweg() | |||||
{ | |||||
return flweg; | |||||
} | |||||
/** | |||||
* @return the flpfl | |||||
*/ | |||||
public FlaechePflanzen getFlpfl() | |||||
{ | |||||
return flpfl; | |||||
} | |||||
} | } |