60 736
Assignments Done
97,9%
Successfully Done
In April 2018

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!
Expert's answer
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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions