Can someone point me in the right direction?

I have a java program created in netbeans that has several tabs that contains various text fields, boxes and such. Over top of these I have a jlable that displays a jpg, or other graphic file that is used for a background image. Since the tabs cover the majority of the screen, the graphic files used must be of large size to cover the area. Most graphic programs have a function that has a pattern fill that takes a small image say an 80x80 pixel file and does a pattern fill of an enclosed area. I am looking for the same thing to fill the entire jlable area with this pattern and still allow the information behind it to show thru.

temp_text = "C:\\Photos\\System\\"+FILE_NAME;
        MAIN_BACKGROUND_IMAGE.setIcon(new ImageIcon(temp_text));

I would like to replace the (temp_text) with a function call to say (PAINT_BACKGROUND(temp_text)) or something simular.

Obviously I am not looking for someone to write the code for me (although that would be glorious), but give suggestions or point me in the right direction on how to build the function call.

thanks in advance..... Mike.

You could override paintComponent to paint the background yourself, then draw the tile repeatedly in a nested x,y double loop to tile it across/down the whole area.
You could optimise that by doing it once to a new full-size image if necessary, but it probably won't be necessary.

Hey James, thanks for the push in the right direction. I got the code working to create the background image. I am posting the code in case it will help anyone else:

    @Override
    public void paint(Graphics g){
        try {
            File f = new File("C:\\Photos\\System\\Wooden Floor 4x4.png");
            BufferedImage image = ImageIO.read(f);
            int height = image.getHeight();
            int width = image.getWidth();
            System.out.println("tile width ="+width);
            System.out.println("tile height ="+height);
            int x; int y;
            for (x=0; x < 1600/width; x++) {
                    for (y=0; y < 1600/height; y++)  {
                            System.out.println(x + " =x    "+ y +" = y");    
                            g.drawImage(image, x*width, y*height, this); } }
        } catch (IOException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);}
}

This code works great with any size tile image. The println statements are there to confirm size if the image and starting position during each interation of the for loops. These may be commented our or removed entirely if desired.

my only problem is that this background is shown over the entire screen and the info underneath it is not visible until you click on it. I need to apply this to jLable as an image icon as this jlable will be placed over top of jlayered pane so the information on that frame will show thru the background image. Suggestions? thanks.

override paintComponent, not paint. Explanation here

1.)

File f = new File("C:\\Photos\\System\\Wooden Floor 4x4.png");

don't load anything, nor FileIO inside paint / paintComponent / paintChildren, prepare this Object as local variable, because

a) paintComponent is called internally when JComponent required repaint()
b) each of mouse and keyboard events to invoked paintComponent

2.)

int height = image.getHeight();
int width = image.getWidth();

override getPreferredSize for parent (JPanel), then image should be resiziable with container

3.)

for (x=0; x < 1600/width; x++) {
for (y=0; y < 1600/height; y++) {
System.out.println(x + " =x "+ y +" = y");
g.drawImage(image, x*width, y*height, this); } }

better could be to put this logics to the Array and inside paintComponent only to pickup desired Object

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.