import java.awt.*; import java.awt.event.*; import javax.swing.*; import javax.swing.event.*; /** * * Beschreibung * * @version 1.0 vom 17.06.2021 * @author */ public class HalloHorst extends JFrame { // Anfang Attribute private JLabel lName = new JLabel(); private JTextField jTextField1 = new JTextField(); private JButton bSageHallo = new JButton(); // Ende Attribute public HalloHorst() { // Frame-Initialisierung super(); setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); int frameWidth = 241; int frameHeight = 104; setSize(frameWidth, frameHeight); Dimension d = Toolkit.getDefaultToolkit().getScreenSize(); int x = (d.width - getSize().width) / 2; int y = (d.height - getSize().height) / 2; setLocation(x, y); setTitle("HalloHorst"); setResizable(false); Container cp = getContentPane(); cp.setLayout(null); // Anfang Komponenten lName.setBounds(8, 8, 46, 20); lName.setText("Name:"); cp.add(lName); jTextField1.setBounds(64, 8, 150, 20); cp.add(jTextField1); bSageHallo.setBounds(8, 32, 211, 25); bSageHallo.setText("Sage Hallo!"); bSageHallo.setMargin(new Insets(2, 2, 2, 2)); bSageHallo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent evt) { bSageHallo_ActionPerformed(evt); } }); cp.add(bSageHallo); // Ende Komponenten setVisible(true); } // end of public HalloHorst // Anfang Methoden public static void main(String[] args) { new HalloHorst(); } // end of main public void bSageHallo_ActionPerformed(ActionEvent evt) { // TODO hier Quelltext einfügen JOptionPane.showMessageDialog(this, "Hallo, " + jTextField1.getText()); } // end of bSageHallo_ActionPerformed // Ende Methoden } // end of class HalloHorst