Saturday, 15 February 2014

java - Adding image to borderlayout CENTER -


I have a class background that extends to JPNL. The point of this class is that an image is displayed in it. is.

I have a class GraphTest that increases JFrame (this program is the main window). In this frame, I have a menu with the "new" option when I press New, I should get a File Checker window where I can select a file. When I select a file, I want to create a background object that has a lot of file to display the image, and add the background object to the GraphTest's borderout center.

How should I do this?

I am thinking of writing the background class so that the constructor gets string for it, which is the image files.

So when the listener is pressed into the graphite for the "New" button, it opens a file-chooser which gives the filename of the selected image and the constructor for the background "background bg = new background (file chooser. Filename.Storage) "(I know how it is not, write it, but you get this idea) and then adds that object to the GraphTest border layout center.

Is this a good solution? Or would there be better ways to do this?

Here's my class. I want to choose to pass in the image to be used as a background But there is no reason that you can not go into the filename and then create an image. The option to pass the image directly or in the filename makes the classroom more convenient.


No comments:

Post a Comment