ProjektGraph/OurApplication/OurMethodButtons.java

74 lines
1.7 KiB
Java
Raw Blame History

package OurApplication;
import visualisation.ParameterArea;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* This class provides an example for using visualization.ParameterArea.
* @see ParameterArea
* @author MSch<63>fer
* DHBW Stuttgart/Campus Horb AI2008<br>
* <br>
*/
public class OurMethodButtons extends ParameterArea{
private static final long serialVersionUID = 1L;
protected JRadioButton button1;
protected JRadioButton button2;
private boolean isDjikstra;
/** TextField containing maximum sum up value. */
protected JTextField maxValue;
/**
* Standard constructor.
* Creates SumUpMethodArea with an empty JTextField.
*/
public OurMethodButtons() {
super();
isDjikstra = true; // Standardmäßig Djikstra
// Layout-Manager setzen, um die Buttons vertikal anzuordnen
setLayout(new GridLayout(1, 2, 5, 5)); // 1 Zeile, 2 Spalten, 5 Pixel Abstand
// Buttons erstellen
button1 = new JRadioButton("Djikstra", true);
button2 = new JRadioButton("A-Stern");
// ButtonGroup erstellen und Buttons hinzufügen, um die gegenseitige Ausschließung zu gewährleisten
ButtonGroup group = new ButtonGroup();
group.add(button1);
group.add(button2);
// ActionListener hinzufügen
button1.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
isDjikstra = true;
}
});
button2.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
isDjikstra = false;
}
});
// Buttons zum Panel hinzufügen
this.add(button1);
this.add(button2);
}
public boolean getSelectedMethod() {
return isDjikstra;
}
}