Ich habe Probleme bei der Anzeige der Jtextfield auf JOptionPane.showMessageDialog. Es zeigt so etwas wie Name: javax swing.Jtextfield [, 0,19,195x20, invalid.layout ......... Bereich: javax swing.Jtextfield [, 0,19,195x20, invalid.layout .. ....... Hier ist der Code:Jtextfield auf JOptionPane.showMessageDialog anzeigen
package quiz_application;
import java.awt.Component;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
/**
*
* @author Christian
*/
public class Quiz_application {
public static void main(String[] args){
/**
* Input
*/
JTextField fullName = new JTextField();
JTextField section = new JTextField();
Object[] message = {
"Name:", fullName,
"Section:", section,
};
Component parent = null;
int option = JOptionPane.showConfirmDialog(parent, message,"User Information", JOptionPane.OK_CANCEL_OPTION);
if (option == JOptionPane.OK_OPTION)
{
String value1 = fullName.getText();
String value2 = section.getText();
}
String outputStr="Name: "+ fullName+"\n"
+"Section: "+ section;
JOptionPane.showMessageDialog(null, outputStr,"User Information",JOptionPane.INFORMATION_MESSAGE);
}
}
' "Name: "+ fullname +" \ n"' es sollte sein "" Name: "+ fullName.getText() +" \ n "' –
bitte verbessern Formation in Header –