import java.awt.BorderLayout;
import java.awt.FocusTraversalPolicy;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.WindowConstants;
/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit [url]www.cloudgarden.com[/url] for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class Karvonen_GUI extends javax.swing.JFrame implements KeyListener {
{
//Set Look & Feel
try {
javax.swing.UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
} catch(Exception e) {
e.printStackTrace();
}
}
private JPanel jPanel1;
private JLabel labelAerob1;
private JLabel labelFett1;
private JLabel labelGesu1;
private JLabel labelWarn;
private JLabel labelAnaerob;
private JLabel labelAerob;
private JLabel labelFett;
private JLabel labelGesu;
private JTextField textRP;
private JTextField textMaxHF;
private JLabel labelRP;
private JLabel labelMaxHF;
private JButton buttonWarnInfo;
private JButton buttonAnaerobInfo;
private JButton buttonAerobInfo;
private JButton buttonFettInfo;
private JButton buttonGesInfo;
private JLabel labelIconMaxHF;
private JLabel labylCopyright;
private JButton buttonClear;
private JButton buttonCalc;
private JTextField textAnaerob2;
private JTextField textAerob2;
private JTextField textFett2;
private JTextField textGesu2;
private JLabel labelTrennWarn;
private JLabel labelTrennAnaerob;
private JLabel labelTrennAerob;
private JLabel labelTrennFett;
private JLabel labelTrennGesu;
private JTextField textWarn;
private JTextField textFett;
private JTextField textGesu;
private JTextField textAerob;
private JTextField textAnaerob;
private JLabel labelWarn1;
private JLabel labelAnaerob1;
/**
* Auto-generated main method to display this JFrame
*/
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
Karvonen_GUI inst = new Karvonen_GUI();
inst.setLocationRelativeTo(null);
inst.setVisible(true);
}
});
}
public Karvonen_GUI() {
super();
initGUI();
}
private void initGUI() {
try {
setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
this.setTitle("Trainingsbereich-Rechner");
this.setIconImage(new ImageIcon("src/images/diagramm.png").getImage());
{
jPanel1 = new JPanel();
getContentPane().add(jPanel1, BorderLayout.CENTER);
jPanel1.setLayout(null);
jPanel1.setPreferredSize(new java.awt.Dimension(501, 275));
{
labelIconMaxHF = new JLabel();
jPanel1.add(labelIconMaxHF);
labelIconMaxHF.setIcon(new ImageIcon("src/images/icon_01herz.gif"));
labelIconMaxHF.setBounds(15, 18, 27, 28);
}
{
labelMaxHF = new JLabel();
jPanel1.add(labelMaxHF);
labelMaxHF.setText("maximale Herzfrequenz");
labelMaxHF.setBounds(52, 23, 173, 14);
labelMaxHF.setFont(new java.awt.Font("Tahoma",0,16));
}
{
labelRP = new JLabel();
jPanel1.add(labelRP);
labelRP.setText("Ruhepuls");
labelRP.setBounds(52, 50, 173, 14);
labelRP.setFont(new java.awt.Font("Tahoma",0,16));
}
{
textMaxHF = new JTextField();
textMaxHF.addKeyListener(this);
jPanel1.add(textMaxHF);
textMaxHF.setBounds(252, 21, 40, 21);
textMaxHF.setFont(new java.awt.Font("Tahoma",0,16));
}
{
textRP = new JTextField();
textRP.addKeyListener(this);
jPanel1.add(textRP);
textRP.setBounds(252, 48, 40, 21);
textRP.setFont(new java.awt.Font("Tahoma",0,16));
}
{
labelGesu = new JLabel();
jPanel1.add(labelGesu);
labelGesu.setText("Gesundheitszone");
labelGesu.setBounds(36, 111, 165, 18);
labelGesu.setFont(new java.awt.Font("Tahoma",0,16));
}
{
labelFett = new JLabel();
jPanel1.add(labelFett);
labelFett.setText("Fettverbrennungszone");
labelFett.setBounds(36, 137, 165, 18);
labelFett.setFont(new java.awt.Font("Tahoma",0,16));
}
{
labelAerob = new JLabel();
jPanel1.add(labelAerob);
labelAerob.setText("Aerobe Zone");
labelAerob.setBounds(36, 163, 165, 18);
labelAerob.setFont(new java.awt.Font("Tahoma",0,16));
}
{
labelAnaerob = new JLabel();
jPanel1.add(labelAnaerob);
labelAnaerob.setText("Anaerobe Zone");
labelAnaerob.setBounds(36, 189, 165, 18);
labelAnaerob.setFont(new java.awt.Font("Tahoma",0,16));
}
{
labelWarn = new JLabel();
jPanel1.add(labelWarn);
labelWarn.setText("Warnzone");
labelWarn.setBounds(36, 215, 165, 18);
labelWarn.setFont(new java.awt.Font("Tahoma",0,16));
}
{
labelGesu1 = new JLabel();
jPanel1.add(labelGesu1);
labelGesu1.setText("50-60% der HFmax");
labelGesu1.setBounds(207, 111, 149, 18);
labelGesu1.setFont(new java.awt.Font("Tahoma",0,16));
}
{
labelFett1 = new JLabel();
jPanel1.add(labelFett1);
labelFett1.setText("60-70% der HFmax");
labelFett1.setBounds(207, 137, 149, 18);
labelFett1.setFont(new java.awt.Font("Tahoma",0,16));
}
{
labelAerob1 = new JLabel();
jPanel1.add(labelAerob1);
labelAerob1.setText("70-80% der HFmax");
labelAerob1.setBounds(207, 163, 149, 18);
labelAerob1.setFont(new java.awt.Font("Tahoma",0,16));
}
{
labelAnaerob1 = new JLabel();
jPanel1.add(labelAnaerob1);
labelAnaerob1.setText("80-90% der HFmax");
labelAnaerob1.setBounds(207, 191, 149, 14);
labelAnaerob1.setFont(new java.awt.Font("Tahoma",0,16));
}
{
labelWarn1 = new JLabel();
jPanel1.add(labelWarn1);
labelWarn1.setText("90-100% der HFmax");
labelWarn1.setBounds(207, 215, 149, 18);
labelWarn1.setFont(new java.awt.Font("Tahoma",0,16));
}
{
textAnaerob = new JTextField();
jPanel1.add(textAnaerob);
textAnaerob.setBounds(384, 186, 40, 21);
textAnaerob.setEditable(false);
textAnaerob.setFont(new java.awt.Font("Tahoma",0,16));
}
{
textAerob = new JTextField();
jPanel1.add(textAerob);
textAerob.setBounds(384, 160, 40, 21);
textAerob.setEditable(false);
textAerob.setFont(new java.awt.Font("Tahoma",0,16));
}
{
textGesu = new JTextField();
jPanel1.add(textGesu);
textGesu.setBounds(384, 108, 40, 21);
textGesu.setEditable(false);
textGesu.setFont(new java.awt.Font("Tahoma",0,16));
}
{
textFett = new JTextField();
jPanel1.add(textFett);
textFett.setBounds(384, 134, 40, 21);
textFett.setEditable(false);
textFett.setFont(new java.awt.Font("Tahoma",0,16));
}
{
textWarn = new JTextField();
jPanel1.add(textWarn);
textWarn.setBounds(444, 212, 40, 21);
textWarn.setEditable(false);
textWarn.setFont(new java.awt.Font("Tahoma",0,16));
}
{
labelTrennGesu = new JLabel();
jPanel1.add(labelTrennGesu);
labelTrennGesu.setText("-");
labelTrennGesu.setBounds(434, 111, 10, 14);
}
{
labelTrennFett = new JLabel();
jPanel1.add(labelTrennFett);
labelTrennFett.setText("-");
labelTrennFett.setBounds(434, 137, 10, 14);
}
{
labelTrennAerob = new JLabel();
jPanel1.add(labelTrennAerob);
labelTrennAerob.setText("-");
labelTrennAerob.setBounds(434, 163, 10, 14);
}
{
labelTrennAnaerob = new JLabel();
jPanel1.add(labelTrennAnaerob);
labelTrennAnaerob.setText("-");
labelTrennAnaerob.setBounds(434, 189, 10, 14);
}
{
labelTrennWarn = new JLabel();
jPanel1.add(labelTrennWarn);
labelTrennWarn.setText(">");
labelTrennWarn.setBounds(434, 215, 10, 14);
}
{
textGesu2 = new JTextField();
jPanel1.add(textGesu2);
textGesu2.setBounds(444, 108, 40, 21);
textGesu2.setEditable(false);
textGesu2.setFont(new java.awt.Font("Tahoma",0,16));
}
{
textFett2 = new JTextField();
jPanel1.add(textFett2);
textFett2.setBounds(444, 134, 40, 21);
textFett2.setEditable(false);
textFett2.setFont(new java.awt.Font("Tahoma",0,16));
}
{
textAerob2 = new JTextField();
jPanel1.add(textAerob2);
textAerob2.setBounds(444, 160, 40, 21);
textAerob2.setEditable(false);
textAerob2.setFont(new java.awt.Font("Tahoma",0,16));
}
{
textAnaerob2 = new JTextField();
jPanel1.add(textAnaerob2);
textAnaerob2.setBounds(444, 186, 40, 21);
textAnaerob2.setEditable(false);
textAnaerob2.setFont(new java.awt.Font("Tahoma",0,16));
}
{
ImageIcon calc = new ImageIcon("src/images/kalkulation16.gif");
buttonCalc = new JButton();
jPanel1.add(buttonCalc);
buttonCalc.setText("berechnen");
buttonCalc.setIcon(calc);
buttonCalc.setBounds(316, 21, 151, 21);
buttonCalc.setToolTipText("Trainingsbereiche berechnen");
buttonCalc.setFont(new java.awt.Font("Tahoma",0,14));
}
{
buttonClear = new JButton();
jPanel1.add(buttonClear);
buttonClear.setText("Eingaben löschen");
buttonClear.setBounds(316, 48, 151, 21);
buttonClear.setToolTipText("alle Felder löschen");
buttonClear.setFont(new java.awt.Font("Tahoma",0,14));
}
{
buttonGesInfo = new JButton();
jPanel1.add(buttonGesInfo);
buttonGesInfo.setBounds(3, 110, 24, 20);
buttonGesInfo.setToolTipText("Info Gesundheitszone");
buttonGesInfo.setIcon(new ImageIcon("src/images/Info.png"));
}
{
buttonFettInfo = new JButton();
jPanel1.add(buttonFettInfo);
buttonFettInfo.setBounds(3, 136, 24, 20);
buttonFettInfo.setToolTipText("Info Fettverbrennungszone");
buttonFettInfo.setIcon(new ImageIcon("src/images/Info.png"));
}
{
buttonAerobInfo = new JButton();
jPanel1.add(buttonAerobInfo);
buttonAerobInfo.setBounds(3, 162, 24, 20);
buttonAerobInfo.setToolTipText("Info Aerobe Zone");
buttonAerobInfo.setIcon(new ImageIcon("src/images/Info.png"));
}
{
buttonAnaerobInfo = new JButton();
jPanel1.add(buttonAnaerobInfo);
buttonAnaerobInfo.setBounds(3, 188, 24, 20);
buttonAnaerobInfo.setToolTipText("Info Anaerobe Zone");
buttonAnaerobInfo.setIcon(new ImageIcon("src/images/Info.png"));
}
{
buttonWarnInfo = new JButton();
jPanel1.add(buttonWarnInfo);
buttonWarnInfo.setBounds(3, 214, 24, 20);
buttonWarnInfo.setToolTipText("Info Warnzone");
buttonWarnInfo.setIcon(new ImageIcon("src/images/Info.png"));
}
/*Setzt die richtige Tabulatorenreihenfolge */
FocusTraversalPolicy policy = getFocusTraversal(
new JComponent[]
{textMaxHF, textRP}); //hier alles eintragen was man focussieren will
setFocusTraversalPolicy(policy); //setzen
setFocusCycleRoot(true);//enablen
ButtonHandler handler = new ButtonHandler();
buttonClear.addActionListener(handler);
buttonCalc.addActionListener(handler);
buttonGesInfo.addActionListener(handler);
buttonFettInfo.addActionListener(handler);
buttonAerobInfo.addActionListener(handler);
buttonAnaerobInfo.addActionListener(handler);
buttonWarnInfo.addActionListener(handler);
}
pack();
this.setSize(502, 309);
} catch (Exception e) {
e.printStackTrace();
}
}
class ButtonHandler implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
String text = null;
// Berechnungen der Trainingsbereiche
if (event.getSource() == buttonCalc)
calculate();
// alle Felder löschen
if (event.getSource() == buttonClear)
clearAllValues();
if (event.getSource() == buttonGesInfo)
text = "noch kein Text";
popupAnzeigen("Info Gesundheitszone", text);
if (event.getActionCommand() == buttonFettInfo.getText())
text = "noch kein Text";
popupAnzeigen("Info Fettverbrennungszone", text);
if (event.getActionCommand() == buttonAerobInfo.getText())
text = "Erhöhung und Entwicklung der Grundlagenausdauer auf einem etwas höheren Niveau.
Starke Wirkung auf das Herz- Kreislaufsystem (Sauerstofftransportkapazität) aber auch auf die Muskelkraft.";
popupAnzeigen("Info Aerobe Zone", text);
if (event.getActionCommand() == buttonAnaerobInfo.getText())
text = "Hier findet das anaerobe Schwellentraining statt. Ab einem bestimmten Punkt kann der
Körper das bei der anaeroben Verbrennung anfallende Laktat nicht mehr so schnell beseitigen wie es entsteht
(=anaerobe Schwelle). Ein Training in dieser Zone führt zu einer verbesserten Laktatbeseitung und Laktattoleranz
(Laktatkompensationstraining). Die persönliche anerobe Schwelle verschiebt sich Richtung maximaler Herzfrequenz
(Anhebung der AS), die Fähigkeit der Muskeln mit dem zur Verfügung stehenden Sauerstoff Glykogen und Fett zu
Energie zu verwandeln verbessert sich. Das alles führt dazu, dass der Läufer länger schneller laufen kann.";
popupAnzeigen("Info Anaerobe Zone", text);
if (event.getActionCommand() == buttonWarnInfo.getText())
text = "Hier kann man nur für sehr kurze Zeit trainieren. Dabei profitieren vor allem die
schnellkräftigen Muskelfasern, was die Schnelligkeit erhöht. Die AS wird angehoben. Laktattoleranz und -beseitung
werden stark verbessert. Die VO2max wird erweitert. Der Wille und die Tempohärte werden geschult.";
popupAnzeigen("Info Warnzone", text);
}
}
public void keyPressed(KeyEvent event) {
if (event.getKeyCode() == KeyEvent.VK_ENTER)
calculate();
}
public void keyReleased(KeyEvent event) {
}
public void keyTyped(KeyEvent event) {
}
public String getMaxHF() {
String maxHF = textMaxHF.getText();
return maxHF;
}
public String getRP() {
String RP = textRP.getText();
return RP;
}
public void setValues(String ges,
String ges2,
String fett,
String fett2,
String aerob,
String aerob2,
String anaerob,
String anaerob2,
String warn) {
textGesu.setText(ges);
textGesu2.setText(ges2);
textFett.setText(fett);
textFett2.setText(fett2);
textAerob.setText(aerob);
textAerob2.setText(aerob2);
textAnaerob.setText(anaerob);
textAnaerob2.setText(anaerob2);
textWarn.setText(warn);
}
private void calculate() {
String ges;
String ges2;
String fett;
String fett2;
String aerob;
String aerob2;
String anaerob;
String anaerob2;
String warn;
int maxHFCalc = 0;
int RPCalc = 0;
int erg;
String maxHF = getMaxHF();
String RP = getRP();
if (!maxHF.equals("") && !RP.equals(""))
{
maxHFCalc = Integer.parseInt(maxHF);
RPCalc = Integer.parseInt(RP);
}
erg = (int) ((maxHFCalc-RPCalc)*0.5+RPCalc);
ges = erg + "";
erg = (int) ((maxHFCalc-RPCalc)*0.6+RPCalc);
ges2 = erg + "";
fett = erg + "";
erg = (int) ((maxHFCalc-RPCalc)*0.7+RPCalc);
fett2 = erg + "";
aerob = erg + "";
erg = (int) ((maxHFCalc-RPCalc)*0.8+RPCalc);
aerob2 = erg + "";
anaerob = erg + "";
erg = (int) ((maxHFCalc-RPCalc)*0.9+RPCalc);
anaerob2 = erg + "";
warn = erg + "";
setValues(ges,
ges2,
fett,
fett2,
aerob,
aerob2,
anaerob,
anaerob2,
warn);
}
private void clearAllValues() {
textMaxHF.setText(null);
textRP.setText(null);
textGesu.setText(null);
textGesu2.setText(null);
textFett.setText(null);
textFett2.setText(null);
textAerob.setText(null);
textAerob2.setText(null);
textAnaerob.setText(null);
textAnaerob2.setText(null);
textWarn.setText(null);
}
public int getFramePositionX()
{
int x = this.getLocation().x;
return x;
}
public int getFramePositionY()
{
int y = this.getLocation().y;
return y;
}
private void popupAnzeigen(String infoText, String text)
{
DialogInfo info = new DialogInfo(this);
info.setTitle(infoText);
info.setTextArea(text);
info.setModal(true);
info.setVisible(true);
}
/****************************************************************************
* Gibt die Reihenfolge der in order[] gespeicherten Componenten als FocusTraversalPolicy Objekt zurück
* @param order sind die Componenten in richtiger Reihenfolge und notfalls muss eine Typkonvertierung
* mittels (JComponent) durchgeführt werden
* @return das Objekt mit dem man mit setFocusTraversalPolicy(FocsTraersalPolicy) und aktivieren mit
* setFocusCycleRoot(true)
***************************************************************************/
public static FocusTraversalPolicy getFocusTraversal(final JComponent order[])
{
FocusTraversalPolicy policy = new FocusTraversalPolicy()
{
java.util.List list = java.util.Arrays.asList(order);
public java.awt.Component getFirstComponent(java.awt.Container
focusCycleRoot)
{
return order[0];
}
public java.awt.Component getLastComponent(java.awt.Container
focusCycleRoot)
{
return order[order.length - 1];
}
public java.awt.Component getComponentAfter(java.awt.Container
focusCycleRoot,
java.awt.Component aComponent)
{
int index = list.indexOf(aComponent);
return order[ (index + 1) % order.length];
}
public java.awt.Component getComponentBefore(java.awt.Container
focusCycleRoot,
java.awt.Component aComponent)
{
int index = list.indexOf(aComponent);
return order[ (index - 1 + order.length) % order.length];
}
public java.awt.Component getDefaultComponent(java.awt.Container
focusCycleRoot)
{
return order[0];
}
public java.awt.Component getInitialComponent(java.awt.Window window)
{
return order[0];
}
};
return policy;
}
}