import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Tutorial10 extends JFrame implements ActionListener{ JButton bnAngryBirds = new JButton("AngryBirds"); JButton bnAngryCats = new JButton("AngryCats"); // Konstruktor public Tutorial10() { this.setSize( 400, 100); setLocation(400,10); setTitle( "Prog2_Tutorial10"); setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE ); setGUI(); } /** * 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(bnAngryBirds); panelBn.add(bnAngryCats); this.getContentPane().add(panelBn,BorderLayout.NORTH); setFonts(getContentPane(), 18); bnAngryBirds.addActionListener(this); bnAngryCats.addActionListener(this); } 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() == bnAngryBirds) { bnAngryBirds_click(); } if (e.getSource() == bnAngryCats) { bnAngryCats_click(); } } private void bnAngryBirds_click() { } private void bnAngryCats_click() { } public static void main(String[] args) { Tutorial10 frame = new Tutorial10(); frame.setVisible(true); } }