import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Arena extends JFrame implements ActionListener{ JTextArea editor1 = new JTextArea(); JTextArea editor2 = new JTextArea(); Timer myTimer; // Timer /* IPerson p1; IPerson p2; IWaffe w1; IWaffe w2; IOrt ort; */ public Arena(Generator gen) { this.setSize( 400, 300); // setLocation(400,10); setTitle( "Arena"); setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); setGUI(); /* editor1.setText("Arena:"); editor1.append("\nPerson1: "+p1.getName()); editor1.append("\nPerson2: "+p2.getName()); editor1.append("\nWaffe1: "+w1.getName()); editor1.append("\nWaffe2: "+w2.getName()); editor1.append("\nOrt: "+ort.getName()); */ setVisible(true); myTimer = new Timer(1000, this); // 200 ms myTimer.start(); // starten } /** * Aufbau der GUI-Elemente. * Einfuegen der "desktopPane" in CENTER. */ public void setGUI() { // BorderLayout setzen this.getContentPane().setLayout( new BorderLayout() ); JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, new JScrollPane(editor1), new JScrollPane(editor2) ); split.setDividerLocation(120); this.getContentPane().add(split,BorderLayout.CENTER); int size=14; editor1.setFont(new Font("Arial", Font.BOLD, size)); editor2.setFont(new Font("Arial", Font.BOLD, size)); setFonts(getContentPane(), 18); } private void setFonts(Container cont, int size) { for (int i = 0; i < cont.getComponentCount(); i++) { Component c = cont.getComponent(i); if (c instanceof JPanel) setFonts((JPanel) c, size); else c.setFont(new Font("Arial", Font.BOLD, size)); } } public void actionPerformed(ActionEvent e) { if (e.getSource()==myTimer) { kaempfe_click(); } } private void kaempfe_click() { editor2.append("Kampf: "+p1.getName()+" vs. "+p2.getName()+"\n"); int value = 0; editor2.append(" "+value+"\n"); } }