I am trying too make small app that takes pics from directory and show images on JLabel when user click on next button.but i dont know why it doesn't work properly.actually when i click on Next it show image but i need to resize frame every time.Please look on that and let me know where i am wrong. sorry for silly English ;)
By default components have a size of (0, 0). So when you add a component to a frame there is nothing to paint. In order to give a component a size you need to invoke the layout manager. When you resize a frame the layout manager is automatically invoked so your component is give a size and location.
You can manually invoke the layout manager by using code like:
However, a better approach is the add the label to the GUI when you create the GUI. Then when you want to change the image of the label you just use:
label.setIcon( .... );
Now the label will invoke the layout manager automatically and the label will repaint itself.