java - Swing applet componets are invisable untill interacted with -


i trying make applet simple login screen, if use normal components works fine if use swing components object wont show until clicked on. use regular components need masked password field (if there non swing version please let me know).

i trying vertical placement in top left corner.

public class rdpapplet extends japplet {    jbutton connect;    jtextfield username;    jpasswordfield password;    jlabel usernamelabel;    jlabel passwordlabel;     //(snip)     public void paint(graphics g){    }    public void start(){    }    public void stop(){    }    public void init(){        swingutilities.invokelater(new runnable() {         public void run() {            jpanel panel = new jpanel (new gridbaglayout());            gridbagconstraints gbc = new gridbagconstraints();            gbc.insets = new insets(2,5,1,1);            gbc.weightx = 1.0;            gbc.anchor = gridbagconstraints.west;            gbc.gridwidth = gridbagconstraints.remainder;             usernamelabel = new jlabel("username:");            panel.add(usernamelabel,gbc);             username = new jtextfield(15);            panel.add(username,gbc);             passwordlabel = new jlabel("password:");            panel.add(passwordlabel,gbc);             password = new jpasswordfield(15);            panel.add(password,gbc);             connect = new jbutton("connect");            panel.add(connect,gbc);            gbc.weighty = 1.0;            gbc.anchor = gbc.northwest;             setlayout(new flowlayout(flowlayout.left));            add(panel);            validate();            panel.validate();        }});    }     //(snip) } 

if use jbutton , jtextfield , jlabel items not show until interact them(click on text field, mouse on button, cant label show up) , if use normal versions ugly gray backgrounds around labels.

can show me doing wrong working properly.

edit: changing applet japplet did not solve problem.

edit2: added other methods.

edit3: cursor starts in user name box still invisible until interacted with. updated code of latest suggestions.

you overwriting paint method without doing in there. causes descendants of applet not drawn @ all.

in swing, should never overwrite paint() method, paintcomponent() method (and there call super.paintcomponent(...) somewhere.)

in applet looks don't need paint method @ all, delete it.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

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

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