/**
* Sample application using Frame.
*
* @author
* @version 1.00 05/01/28
*/
import java.awt.*;
import java.awt.event.*;
public class VokabelEditorFrame extends Frame
{
/**
* The constructor.
*/
public VokabelEditorFrame()
{
setLayout( new GridBagLayout() );
final Insets insets = new Insets( 2, 2, 2, 2);
MenuBar menuBar = new MenuBar();
Menu menuFile = new Menu();
MenuItem menuFileExit = new MenuItem();
TextField vokabelanzahl;
//String eingabe="";
vokabelanzahl = new TextField("1");
final String eingabe = vokabelanzahl.getText();
final int eingabe_int = Integer.parseInt(eingabe);
//vokabelanzahl.setBounds(10,30,40,10);
add( vokabelanzahl, new GridBagConstraints( 1, 0, 1, 1, 1.0, 1.0,
GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, insets, 0, 0) );
vokabelanzahl.addKeyListener(new KeyAdapter()
{
public void keyPressed(KeyEvent e)
{
//constraints2.insets = new Insets(0, 5, 0, 5);
if(e.getKeyCode() == KeyEvent.VK_ENTER)
{
System.out.println("making list...");
System.out.println("Anzahl: "+eingabe_int);
TextField latein[] = new TextField[eingabe_int];
TextField deutsch[]= new TextField[eingabe_int];
GridBagConstraints constraintsDEUTSCH = new GridBagConstraints( 0, 0, 2, 1, 1.0, 1.0,
GridBagConstraints.EAST, GridBagConstraints.VERTICAL, insets, 0, 0 );
GridBagConstraints constraintsLATEIN = new GridBagConstraints( 0, 0, 2, 1, 1.0, 1.0,
GridBagConstraints.WEST, GridBagConstraints.VERTICAL, insets, 0, 0 );
//List deutscheListe = new List(10, false);
for(int i = 0; i <eingabe_int; i++)
{
latein[i] = new TextField("latein");
deutsch[i]= new TextField("deutsch");
constraintsLATEIN.gridy = i+1;
constraintsDEUTSCH.gridy = i+1;
add(latein[i], constraintsLATEIN);
add(deutsch[i], constraintsDEUTSCH);
//repaint();
}
validate();
}
}
});
Label anzahl = new Label("Wieviele Vokabeln möchten Sie eingeben?");
add(anzahl, new GridBagConstraints( 0, 0, 1, 1, 1.0, 1.0,
GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, insets, 0, 0));
menuFile.setLabel("File");
menuFileExit.setLabel("Exit");
// Add action listener.for the menu button
menuFileExit.addActionListener
(
new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
VokabelEditorFrame.this.windowClosed();
}
}
);
menuFile.add(menuFileExit);
menuBar.add(menuFile);
setTitle("VokabelEditor");
setMenuBar(menuBar);
setSize(new Dimension(900, 700));
// Add window listener.
this.addWindowListener
(
new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
VokabelEditorFrame.this.windowClosed();
}
}
);
}
/**
* Shutdown procedure when run as an application.
*/
protected void windowClosed()
{
// TODO: Check if it is save to close the application
// Exit application.
System.exit(0);
}
}