java - Why isn't there a JTextField being displayed here? -
public class wasd extends jframe{ ellipse2d.double ball; int ballx = 100; int bally = 100; static jtextfield typingarea; public static void main(string[] args){ javax.swing.swingutilities.invokelater(new runnable() { public void run() { createandshowgui(); } }); } private static void createandshowgui(){ wasd frame = new wasd("frame"); frame.setdefaultcloseoperation(exit_on_close); frame.addcomponentstopane(); frame.pack(); frame.setvisible(true); } private void addcomponentstopane(){ typingarea = new jtextfield(20); //typingarea.addkeylistener(this); } public wasd(string name){ super(name); } }
when run program empty window. jtextfield doesn't show up. thanks!
(apparently post has code, i'm adding make let me submit. ignore sentence , previous one.)
the jtextfield
needs added frame after created.
private void addcomponentstopane(){ typingarea = new jtextfield(20); frame.add(typingarea); }
Comments
Post a Comment