My code does not work:
JFrame frame = new JFrame(\"mull\");
mull panel = new mull();
// add panel to the center of window
frame.getContentPane().add(\"Cent
Well, you are using both frame.setSize()
and frame.pack()
.
You should use one of them at one time.
Using setSize()
you can give the size of frame you want but if you use pack()
, it will automatically change the size of the frames according to the size of components in it. It will not consider the size you have mentioned earlier.
Try removing frame.pack()
from your code or putting it before setting size and then run it.