Answer to Question #25482 in Java | JSP | JSF for Joakim

Question #25482
How can I use setLocation() from javax.swing.JFrame on a customized JButton? I have tried to use setLayout(null); but then the button disappears!
1
Expert's answer
2013-03-05T09:20:03-0500
1.Set both prefered size and size for JFrame
2. Set both prefered size to JPanel and jbutton you add
3. frame.setLayout(null)
4. panel.setLayout(null)
panel.add(myButton)
frame.add(panel)


frame.setLayout(null);
panel.setLayout(null);

>I have tried to use setLayout(null); but then the button disappears!
This stuff happens when some element has no size set. If the element has no
size, no location or even no text SWING can easily decide to not draw it at all
for better optimization, seriously, no one needs sizeless empty button

Hope it will help

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS