Java-GUI-Test
Aus ProgrammingWiki
Archivierte Version vom 2010-12-19T12:34:49+00:00. Aktuelle Version
<eval id="4d0de7d4a6d4f"> JButton myButton = new JButton("Beenden"); JTextField myTextField = new JTextField("Das ist ein Text-Feld!"); JPanel bottomPanel = new JPanel(); JPanel holdAll = new JPanel();</eval>
frame = new JFrame("Information"); frame.setLocation(200, 200); frame.setSize(300, 100);
bottomPanel.setLayout(new FlowLayout()); bottomPanel.add(myButton);
holdAll.setLayout(new BorderLayout()); holdAll.add(bottomPanel, BorderLayout.SOUTH); holdAll.add(myTextField, BorderLayout.CENTER);
frame.getContentPane().add(holdAll, BorderLayout.CENTER); frame.setVisible(true);
myButton.addActionListener(this);
void actionPerformed(ActionEvent Ereignis) {
if (Ereignis.getSource() == myButton)
frame.dispose();
else
myTextField.setText("Eingabefehler?");}