Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You don't need the complication of two panels; you can just add components to the one which is painting the background.</p> <p>Also, you need to install a LayoutManager (setLayout()) to layout your components.</p> <p>EDIT (for comment): Yes, you have a setLayout(null), but that removes the layout manager. When you add your label to cmp, it has no layout manager so that component is unsized and unlocated (it bounds are probably 0,0,0,0), and therefore not visible.</p> <p>I say again, you need to research how to use layout managers and use them - follow the Swing tutorial on layout - it's the <em>best</em> way to construct a UI (manual layout is absolutely not the way to go).</p> <p>Sun Tutorials: <a href="http://java.sun.com/developer/onlineTraining/" rel="nofollow noreferrer">Main Tutorial Page</a> - <a href="http://java.sun.com/docs/books/tutorial/uiswing/index.html" rel="nofollow noreferrer">Creating a GUI With Swing</a> - <a href="http://java.sun.com/docs/books/tutorial/uiswing/layout/index.html" rel="nofollow noreferrer">Layout Tutorial</a></p> <p>BTW, pack didn't work because it asks the layout manager to size the components and there is none in your case.</p> <p><strong>Lastly, look into a good table-based layout manager - there are several available for free on the Web. They make container layout <em>much</em> easier than using just the layouts built into Java. I have one which is completely free, called <a href="http://www.softwaremonkey.org/Code/MatrixLayout" rel="nofollow noreferrer">MatrixLayout</a>.</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload