-1

I am trying to display an image in a jlabel, which is in the default jFrame created by Netbeans. I know how to display an image in a new Jframe, but I dont know how to acces the default Jframe since I cant customize the code and create a variable name for it. Any work arounds?

The application is supposed to display pictures from a directory, so when u press next, next image, and if you press previous the previous image will be shown. What will be the best data structure to do this efficiently so that I can keep track of the index as well?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
user1019083
  • 381
  • 2
  • 8
  • 19
  • 1
    *"Any work arounds?"* Learn how to use Netbeans or learn Java. Not sure which applies here, an expert user of Netbeans & Java can easily create a frame with a label with icon that changes according to user selection. There is no 'work around' to understanding both (if using Netbeans). – Andrew Thompson Jun 29 '12 at 08:22

2 Answers2

1

Instead of letting the GUI designer manage your frame, let it manage the content, as suggested in this example.

Addendum: There's an example of flipping through images here.

Community
  • 1
  • 1
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
0

Regarding displaying the images, you can number the images in the directory as 1,2,3...and so on. If you do this, you can use a simple counter variable (increment with the next button and decrement with the previous button ) to scan through the images. You can use this counter variable for your image name with the format.

Aakash Anuj
  • 3,773
  • 7
  • 35
  • 47