OSDev.org

The Place to Start for Operating System Developers
It is currently Fri Apr 19, 2024 2:19 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: question
PostPosted: Thu Nov 21, 2002 3:53 pm 
hi
can someone tell me how to put an image in the backgorund of a swing applet ...


Top
  
 
 Post subject: Re:question
PostPosted: Thu Nov 21, 2002 5:20 pm 
This might be what you are asking....


public void paint(Graphics g)
{
// lay out the background image if any
if (withBGImage)
{
for (int y = 0; y < height - 1; y += hh)
for (int x = 0; x < width - 1; x += ww)
g.drawImage(image, x, y, this);
}

int w1 = (g.getFontMetrics()).stringWidth(title);
int h1 = (g.getFontMetrics()).getHeight();
int d1 = (g.getFontMetrics()).getDescent();

// draw the bounding box
g.setColor(white2);
g.drawRect(5, h1 / 2 + 1, width - 10, height - h1 - d1 - 5);
g.setColor(black2);
g.drawRect(4, h1 / 2, width - 10, height - h1 - d1 - 5);

// erase the extra lines
g.setColor(getBackground());
g.drawLine(12, h1 / 2, 12 + w1 + 3, h1 / 2);
g.drawLine(12, h1 / 2 + 1, 12 + w1 + 3, h1 / 2 + 1);

// draw the title string
g.setColor(white2);
g.drawString(title, 16, h1);
g.setColor(black2);
g.drawString(title, 15, h1 - 1);
}


Top
  
 
 Post subject: Re:question
PostPosted: Thu Nov 21, 2002 8:20 pm 
well i have not tested ur code yet but i was just wondering that after putting this code in the background will i be able to put some more stuff on it by the usual way or not?
e.g
now if i add a jbutton .. is it gonna appear on the image or behind the image?


Top
  
 
 Post subject: Re:question
PostPosted: Fri Nov 22, 2002 5:48 am 
It SHOULD appear on top of the image...depending on which way you set the coodinates to be...On top of on bottom of image...but i may be wrong...notlikely though


Top
  
 
 Post subject: Re:question
PostPosted: Sun Nov 24, 2002 12:28 pm 
WELL? DID IT HELP YOU?!?!?!?


Top
  
 
 Post subject: Re:question
PostPosted: Sun Nov 24, 2002 2:46 pm 
Well...what kind of code is that smartguy240?

Here is old DOS FritzOS code that does all the box painting code.:

#include <go32.h>
#include <sys/farptr.h>

// INIT GRAPHICS
// YOU should DO this in your BOOTSECTOR, like this
// BUT without the C comments:
// mov ax, 13h
// int 10h

// Now, put a pixel on the screen:
void putpixel_13h(int x, int y, int color)
{
_farpokeb(_dos_ds, 0xA0000+y*320+x, color);
}

// Call This to draw boxes:
void Box( int clr, int start_x, int start_y, int end_x, int end_y )
{
int i, y;
for ( i = start_x; i < end_x; i++ )
for ( y = start_y; y < end_y; y++ )
// NOTE: THIS IS SERVERLY NOT OPTIMIZED
putpixel_13h( i, y, clr )


void start()
{
// Test PutPixel, put a red pixel in the top
putpixel_13h( 12, 12, 4 );

// test box drawing: make a blue box
Box( 1, 90, 90, 199, 199 );
}

#ifndef __DJGPP__
#error I NEED DJGPP!
#endif
// THIS HAS BEEN MODIFIED FOR DGJPP


Top
  
 
 Post subject: Re:question
PostPosted: Sun Nov 24, 2002 4:53 pm 
Tom...that is how to put an image in the backgorund of a swing applet ...

ughhh


Top
  
 
 Post subject: Re:question
PostPosted: Sun Nov 24, 2002 5:39 pm 
Tom, it's a Java question and you posted arcane C code. :)


Top
  
 
 Post subject: Re:question
PostPosted: Sun Nov 24, 2002 6:28 pm 
NOP
this code doesnt works the way i want

i just want to put an image in the backgorund of this swing applet and then do the rest of the work normally in the init() method so that everything i make .. just appears on the image like the way it appears on the normal backgorund of the applet ..

this code doesnt puts the image nowhere?

what i was thinking that there might be a predefined method or class which just takes the image and put it in the backgorund of the applet ..

so wat do u think guys . plz help me out


Top
  
 
 Post subject: Re:question
PostPosted: Sun Nov 24, 2002 7:19 pm 
Oh WOW i didnt know THAT is what you wnated to do...sheesh....i have no idea sorry :-\


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 109 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group