i'm, trying small app , need take data jtextfield
when press button. problem when press button, nothing happens.. tested println("yes")
, its working printing "yes' on
actionlistener`. should ?
here part of code:
label = new label("width:"); label.setmaximumsize(new dimension(40, 25)); this.add(label); textfield = new textfield(); textfield.setpreferredsize(new dimension(80, 25)); textfield.setmaximumsize(new dimension(80, 25)); this.add(textfield); button = new jbutton("submit"); button.addactionlistener(new actionlistener() { @override public void actionperformed(actionevent e) { system.out.println(textfield.gettext()); // <- here textfield.gettext() not return anything. } }); this.add(button);
i don't know components using, think have problem components declaration, should :
textfield = new jtextfield(); label = new jlabel("width:");
and not :
textfield = new textfield(); label = new label("width:"); jtextfield() , not textfield() //----^--------------------^---------------
Comments
Post a Comment