java - Loop to Create Buttons -


i need create 2 classes within larger class. 1 take info text file in format: string:double

string:double

...

and outputs 2 variables. , second class takes information , loops, creating buttons each text entry label. code far is:

public class mainclass {         scanner readfile = new scanner(new file("text.txt"));         while (filescanner.hasnext()) {            string name = readfile.next();            double value = readfile.nextdouble();     }     class button {         button(string text. double number) {             this.text=text;             this.number=number;         }     } } 

how go here?

not answer here's op's code modified compiles

import java.io.file; import java.io.filenotfoundexception; import java.util.scanner;  import javax.swing.jbutton;  public class mainclass {     class scanfile {         void foo() throws filenotfoundexception{             scanner readfile = new scanner(new file("text.txt")); // don't forget catch filenotfoundexception!             readfile.usedelimiter(":|\\n");             while (readfile.hasnext()) {                string name = readfile.next();                double value = readfile.nextdouble();                system.out.println(name + " " + value);             }         }     }     class button extends jbutton {         string text;         double number;         button(string text, double number) {             super(text);             this.text=text;             this.number=number;         }     } } 

Comments

Popular posts from this blog

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

apache - Add omitted ? to URLs -

php - How can I stop spam on my custom forum/blog? -