import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.util.Iterator; public class Tutorial11 extends JFrame implements ActionListener{ JButton bnPrev = new JButton("Prev"); JButton bnShow = new JButton("Show"); JButton bnNext = new JButton("Next"); JTextArea editor = new JTextArea(); // Konstruktor public Tutorial11() { this.setSize( 400, 400); setLocation(400,10); setTitle( "11. Tutorial"); setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); setGUI(); init(); } /** * Aufbau der GUI-Elemente. * Einfuegen der "desktopPane" in CENTER. */ public void setGUI() { // BorderLayout setzen this.getContentPane().setLayout( new BorderLayout() ); JPanel panelBn = new JPanel(); panelBn.setLayout( new FlowLayout(FlowLayout.RIGHT)); panelBn.add(bnPrev); panelBn.add(bnShow); panelBn.add(bnNext); this.getContentPane().add(panelBn,BorderLayout.NORTH); setFonts(getContentPane(), 18); bnPrev.addActionListener(this); bnShow.addActionListener(this); bnNext.addActionListener(this); this.getContentPane().add( new JScrollPane(editor) ,BorderLayout.CENTER); editor.setFont(new Font("Arial", Font.BOLD, 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() == bnPrev) { bnPrev_click(); } if (e.getSource() == bnShow) { bnShow_click(); } if (e.getSource() == bnNext) { bnNext_click(); } } private void init() { editor.setText("2. Test:\n"); /* new Student("Meier",11111); new Student("Müller",11112); new Student("Schmidt",11113); new Student("Schulze",11114); new Student("Gumm",11115); new Student("Dijkstra",11116); new Student("Brandt",11117); new Student("Hohmann",11118); new Student("Hundertwasser",11119); new Student("Bloch",11121); */ bnShow_click(); } private void bnPrev_click() { } private void bnShow_click() { } private void bnNext_click() { /* if(iterator.hasNext()) { editor.append(" "+iterator.next()+"\n"); } */ } public static void main(String[] args) { Tutorial11 frame = new Tutorial11(); frame.setVisible(true); } }