How can I .getText(long) ????? I can not figure out how to get a string from a GUI and turn a String into a long .

As far as i know getText doesnt have any parameters. you would just say

String x=box.getText();
Long l= Long.parseLong(s);

As far as i know getText doesnt have any parameters. you would just say

String x=box.getText();
Long l= Long.parseLong(s);

Well, yes, mostly correct, except you want "long" not "Long" and the parameter should be "x" instead of "s". It also needs to deal with the potential NumberFormatException

JTextField txtField = new JTextField();
String textValue = txtField.getText();
long value = 0;
try {
    value = Long.parseLong(textValue);
} catch (NumberFormatException nfe){
    // you can either leave it zero or tell the user it's not a good value
    // or whatever you need to do if the text can't be parsed to long.
    System.out.println("bad value");
}
System.out.println("value="+value);

As far as i know getText doesnt have any parameters. you would just say

String x=box.getText();
Long l= Long.parseLong(s);

thanks

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.