JTextField yourInpuFieldt = new JTextField(32); yourInputField.setText("Text data"); String x = yourInputField.getText();