Beispiel
public
static
void
main(
String
[] args ) {
JFrame
frame =
new
JFrame();
JTextField
textField =
new
JTextField();
textField.setBounds(
122
,
26
,
277
,
27
);
frame.getContentPane().add( textField );
frame.setVisible(
true
);
}
Lösung
Verwenden Sie einen Java-Layout-Manager, da die grafische Benutzerschnittstelle dadurch automatisch angepasst wird.
public
static
void
main(
String
[] args ) {
JFrame
frame =
new
JFrame();
JTextField
textField =
new
JTextField();
frame.getContentPane().setLayout(
new
GridLayout() );
frame.getContentPane().add( textField );
frame.setVisible(
true
);
}