import javax.swing.*;
import java.awt.event.*;
import java.awt.*;
import javax.swing.event.*;
import java.util.Properties;
import java.util.ArrayList;
import java.util.Iterator;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
public class PKONV0003
extends JFrame
implements ActionListener, CaretListener
{
private JTextField tfWcodes = new JTextField(25);
private JTextField tfAVar = new JTextField(5);
private JTextField tfIndAkt = new JTextField(2);
private JTextField tfIndMax = new JTextField(2);
private JButton btnVor = new JButton(">");
private JButton btnZurueck = new JButton("<");
private static int IndMax = 1;
private static int IndAkt = 1;
private static int upd = 0;
private ArrayList<String> AVar = new ArrayList<String>();
private ArrayList<String> Wcodes = new ArrayList<String>();
private static PKONV0003 wnd = new PKONV0003();
public PKONV0003()
{
super("Eingabe der Werbecodes");
Container contentPane = getContentPane();
contentPane.setLayout(new GridLayout(3,1));
// Zeile 1:
JPanel zeile1 = new JPanel();
zeile1.setLayout(new GridLayout(1,2));
JLabel lblAVar = new JLabel(
" Ausgabevariante:",
SwingConstants.LEFT
);
zeile1.add(lblAVar);
tfAVar.addCaretListener(this);
tfWcodes.setToolTipText("Eingabe der Ausgabevariante");
zeile1.add(tfAVar);
zeile1.setBorder(BorderFactory.createEtchedBorder());
contentPane.add(zeile1);
// Zeile 2:
JPanel zeile2 = new JPanel();
zeile2.setLayout(new GridLayout(1,2));
JLabel lblWcodes = new JLabel(
" Werbecodes:",
SwingConstants.LEFT
);
zeile2.add(lblWcodes);
tfWcodes.addCaretListener(this);
tfWcodes.setToolTipText("Eingabe der Werbecodes");
zeile2.add(tfWcodes);
zeile2.setBorder(BorderFactory.createEtchedBorder());
contentPane.add(zeile2);
// Zeile 3:
JPanel zeile3 = new JPanel();
zeile3.setLayout(new FlowLayout());
btnZurueck.setToolTipText("Zurück");
btnZurueck.addActionListener(this);
zeile3.add(btnZurueck);
tfIndAkt.setToolTipText("Springe zu...");
tfIndAkt.addActionListener(this);
tfIndAkt.setText("1");
zeile3.add(tfIndAkt);
JLabel lblFlash = new JLabel(
" /",
SwingConstants.LEFT
);
zeile3.add(lblFlash);
tfIndMax.setEditable(false);
tfIndMax.setText("1");
zeile3.add(tfIndMax);
btnVor.setToolTipText("Vor");
btnVor.addActionListener(this);
zeile3.add(btnVor);
zeile3.setBorder(BorderFactory.createEtchedBorder());
getContentPane().add(zeile3);
AVar.add(0," ");
Wcodes.add(0," ");
}
public void caretUpdate(CaretEvent event)
{
if (upd == 0)
{
AVar.add(IndAkt,tfAVar.getText());
Wcodes.add(IndAkt,tfWcodes.getText());
System.out.println(IndAkt+": "+AVar.get(IndAkt)+" - "+Wcodes.get(IndAkt)+" - *");
IndMax = Wcodes.size();
tfIndMax.setText(String.valueOf(IndAkt));
}
}
public void actionPerformed(ActionEvent event)
{
upd = 1;
String cmd = event.getActionCommand();
// System.out.println(cmd);
if(cmd == ">")
{
if(IndAkt <= IndMax)
{
IndAkt++;
}
}
if (cmd == "<")
{
if(IndAkt > 1)
{
IndAkt--;
}
}
System.out.println(IndAkt+" - "+IndMax);
if (IndAkt <= IndMax)
{
tfAVar.setText(AVar.get(IndAkt));
tfWcodes.setText(Wcodes.get(IndAkt));
}
else
{
tfAVar.setText("");
tfWcodes.setText("");
}
tfIndAkt.setText(String.valueOf(IndAkt));
upd = 0;
}
public void zeige(String plaf)
{
wnd.setResizable(false);
wnd.setLocation(400,250);
wnd.setSize(350 ,115);
wnd.setVisible(true);
}
public static void main(String[] args)
{
}
}