java - how to use setLocation to move componets -
i'm trying set components of application set location using setlocation far haven't been able move components. there more code calling , setting code part. ideas?
import javax.swing.*; public class hangmanpanel extends jpanel { private static final long serialversionuid = -5793357804828609325l; public hangmanpanel(){ jlabel heading = new jlabel("welcome hangman app"); jbutton button = new jbutton("ok"); //button.addactionlistener(); jlabel tflable = new jlabel("please enter letter"); jtextfield text = new jtextfield(10); string input = text.gettext(); heading.setlocation(50, 20); tflable.setlocation(20, 100); text.setlocation(320, 50); button.setlocation(230, 100); this.add(heading); this.add(tflable); this.add(text); this.add(button); } }
you should not use setlocation()
layout swing components, better use layout. please have @ these layout tutorials.
Comments
Post a Comment