import javax.swing.*; import java.awt.*; import java.awt.event.*; public class Main { //Variablen GUI JButton button = null; ImageIcon icon = null; JFrame fr = null; JPanel Panele = null; JMenuItem menuItem1 = null; JMenuItem menuItem2 = null; JMenuBar bar =null; JMenu mF= null; JMenu mH = null; JMenu mI = null; //Konstruktor Gui public Main(){ fr = new JFrame("Coutinius Integration SS 2019"); fr.setSize(600,800); fr.setFont(new Font("Helvetica", Font.PLAIN, 12)); fr.setLayout(new FlowLayout()); Panele = new JPanel(); fr.setContentPane(Panele); bar = new JMenuBar(); fr.setJMenuBar(bar); mF = new JMenu("File"); mH = new JMenu("Help"); mI = new JMenu("Info"); bar.add(mF); bar.add(mH); bar.add(mI); menuItem1 = new JMenuItem("Exit"); mF.add(menuItem1); menuItem2 = new JMenuItem("Über"); mI.add(menuItem2); menuItem2.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ie) { try { JOptionPane.showMessageDialog(fr, "Tools entwickelt für CI 2019 Copyright by DEM Consulting"); }catch (Exception ex) { JOptionPane.showMessageDialog(null, "Fehler"); } } }); this.fr.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(-1); } }); fr.setContentPane(Panele); Panele.add(new JLabel("CI Tools von ")); ButtonGroup buttonGroup = new ButtonGroup(); JButton DTools = new JButton("Daniel"); DTools.setBounds(100, 100, 100, 20); buttonGroup.add(DTools); Panele.add(DTools); JButton ETools = new JButton("Eugen"); ETools.setBounds(200, 200, 100, 20); buttonGroup.add(ETools); Panele.add(ETools); JButton MTools = new JButton("Michael"); MTools.setBounds(300, 300, 100, 20); buttonGroup.add(MTools); Panele.add(MTools); DTools.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ie) { try { JOptionPane.showMessageDialog(fr, "Aufruf von Daniels Tools"); fr.setVisible(false); Tage_D gb = new Tage_D(); }catch (Exception ex) { JOptionPane.showMessageDialog(null, "Fehler beim Aufruf von Daniels Tools"); } } }); ETools.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ie) { try { JOptionPane.showMessageDialog(fr, "Aufruf von Eugens Tools"); //fr.setVisible(false); Quiz q = new Quiz(); }catch (Exception ex) { JOptionPane.showMessageDialog(null, "Fehler beim Aufruf von Eugens Tools"); } } }); MTools.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent ie) { try { JOptionPane.showMessageDialog(fr, "Aufruf von Michaels Tools"); fr.setVisible(false); Quiz q = new Quiz(); }catch (Exception ex) { JOptionPane.showMessageDialog(null, "Fehler beim Aufruf von Michaels Tools"); } } }); Panele.setVisible(true); this.fr.setVisible(true); this.fr.setAlwaysOnTop(true); this.fr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String[] args) { Main mn = new Main(); } }