Question about making an image as a background

I am trying to make an image(picture) as the background of my application. I got a code from this forum. This code was written by paternostro, which is in reply to: Images as a background Oct 26, 2000 1:08 PM
import java.awt.*;
import java.awt.event.*;
import com.sun.java.swing.*;
public class Background {
public static void main(String args[]) {
new BackgroundFrame();
class BackgroundFrame extends JFrame {
Image im;
JButton ok = new JButton("OK");
JBackgroundPanel jbp;
BackgroundFrame() {
super();
/* Get image */
im = Toolkit.getDefaultToolkit().getImage("test.gif");
/* Components should be added to the container's content pane
Container cp = getContentPane();
/* Add the window listener */
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
dispose(); System.exit(0);}});
jbp = new JBackgroundPanel(im);
jbp.add(ok);
cp.add(jbp);
/* Size the frame */
setSize(200,200);
/* Center the frame */
Dimension screenDim =
Toolkit.getDefaultToolkit().getScreenSize();
Rectangle frameDim = getBounds();
setLocation((screenDim.width - frameDim.width) /
2,(screenDim.height - frameDim.height) / 2);
/* Show the frame */
setVisible(true);
class JBackgroundPanel extends JPanel
Image im;
JBackgroundPanel(Image im)
super();
this.im = im;
public void paintComponent(Graphics g)
g.drawImage(im,0,0,this);
Then I have a question. I was trying to make a layout manager (new GridLayout(3,0)) on jbp, then add some buttons up. But it make the program never show the background(picture) again. What should I do such that I can make the components on the frame ordered and also can see the background? Please help me, thank you very much!

Woops! So jbp is the background Panel. Create a new
panel, set the desired layout and add the required
components to this. Set this panel to opaque(false),
add it to jbp and add jbp to cp.
Haven't tried it but it sounds like it would work.
Thanks for helping, but I don't think it really works. Here is the code after adding jbp.opague(false)
======================================================
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Background {
public static void main(String args[]) {
new BackgroundFrame();
class BackgroundFrame extends JFrame {
Image im;
JButton ok = new JButton("OK");
JPanel jp = new JPanel();
JBackgroundPanel jbp;
BackgroundFrame() {
super();
/* Get image */
im = Toolkit.getDefaultToolkit().getImage("test.gif");
/* Components should be added to the container's content pane
Container cp = getContentPane();
/* Add the window listener */
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent evt) {
dispose(); System.exit(0);}});
jbp = new JBackgroundPanel(im);
jbp.setLayout(new GridLayout(3,0));
jp.add(ok);
jbp.setOpaque(false);
jbp.add(jp);
cp.add(jbp);
/* Size the frame */
setSize(200,200);
/* Center the frame */
Dimension screenDim =
Toolkit.getDefaultToolkit().getScreenSize();
Rectangle frameDim = getBounds();
setLocation((screenDim.width - frameDim.width) /
2,(screenDim.height - frameDim.height) / 2);
/* Show the frame */
setVisible(true);
class JBackgroundPanel extends JPanel
Image im;
JBackgroundPanel(Image im)
super();
this.im = im;
public void paintComponent(Graphics g)
g.drawImage(im,0,0,this);

Similar Messages

  • Question about adjusting an image to compensate for an alpha black overlay

    I don't know how accurate that title/question is but please hear me out and I'l explain it as best I can.
    There is a touchscreen monitor in my car.
    It allows custom background wallpapers to be loaded via USB.
    The touchscreen automatically adds what would appear to be about a 25% alpha black layer in FRONT of the image so the touchscreen controls and icons are clearly visible.
    The problem is, I don't know what values I'm supposed to adjust on my image in order to get it to look the same way it does on my computer screen.
    Would you adjust the brightness?  Contrast?  Tint?  A combination of all of them?
    Or is this simply not possible because the ~25% alpha black tint is placed OVER the wallpaper?
    I'd really appreciate some advice.  I don't mind tinkering with the values and using trial and error but I don't want to waste my time if this simply isn't possible.

    Just so it's clear, you're not going to be able to "brighten it up" so it looks just like the original - at least not completely so.  An image can only be as bright as bright white.  If that has been reduced by an overlay, you're not going to be able to make the original image "brighter than white" so as to compensate.  Maybe someday, when HDR image formats are common...
    The car is darkening the image on purpose in order to make the locations of the controls more obvious.  I can't imagine why you'd want such a busy image as a background, since it makes the actual controls difficult to find.
    I read an article today that says that testing has shown that automotive touch screens distract drivers as much as a 0.08 blood alcohol level.  And you're wanting to make it more difficult to find those controls.
    Whatever you do, please be careful.
    -Noel

  • Question about ZEN 4 imaging

    We are using ZENWorks 4 imaging (with IR5) and have been using the documents about automating the imaging process. The question that I have is when the workstation it reimaged and reboots, ZENWorks agent comes up with the windows that indicates that it is making changes to the computer and states not to log in till the machine reboots. I believe it is taking the ZIS information and putting this information back into the workstation. (workstation name etc). On windows 2000 the machine reboots without any problems when this process is complete. With Windows XP the machine does not seem to reboot. If the workstation is manually rebooted everything works fine. I have found that if the workstation is left for about 10 minutes, it will actually reboot on its own. Is there a way to have this reboot occur more quickly?

    Didn't know that this could be done. Where do I make those changes.
    Thanks.
    Brian
    >>> Marcus Breiden<[email protected]> 03-Aug-05 8:30:24 AM >>>
    On Wed, 03 Aug 2005 10:53:30 GMT, Brian wrote:
    > Is there a way to have this reboot occur more quickly?
    yes... you could disable the feature that you are directly able to login
    without pressing ctrl-alt-del
    on the other side I just had wks this week who rebooted itself without this
    directly...
    Marcus Breiden
    Please change -- to - to mail me.
    The content of this mail is my private and personal opinion.
    http://www.edu-magic.net

  • Quick question about making system calls

    hello all
    i have a simple quick question regarding making system calls. Basically I want to mimic the command "system" for perl. I am not quite sure how to do this for java.
    any feedback would be appreciated.

    look at:
    java.lang.RunTime

  • IMovie 10.0.2 question about making images rotate gently.

    I have been looking for hours, but cannot find how to make an image gently "spin" or "twist" in iMovie 10.0.2. I remember that the Ken Burns effect in iMovie 9 had this option which always made still images more interesting. Does anyone know how its done?

    jimemmons wrote:
    I remember that the Ken Burns effect in iMovie 9 had this option which always made still images more interesting.
    I don't think any version of iMovie had the ability to rotate as a feature of the Ken Burns effect.
    Photo to Movie will do it.
    http://www.lqgraphics.com/software/phototomovie.php
    Matt

  • Question about changing ID3 images

    Hey everyone. I recently changed my podcast artwork. I use Powerpress, so changing the MAIN artwork was quite easy. So for this question, I am referencing only the individual art that is displayed with each individual episode.
    I know that for iTunes to recognize a change in episode artwork, that it cannot have the same name as the previous. The new artwork embedded does have a new name but is it the artwork that needs a different name, or the entire mp3 that needs a new name? Once artwork becomes embedded as ID3 I'm not sure if it loses its name altogether. So I need to know specifically what needs a new name for iTunes to update my episode art? Pic name or mp3 name?
    Thanks for your time!

    Thanks for the response Roger.
    So just to be clear, I have changed the images embedded in my MP3s. I then re-uploaded them to Libsyn using the replace function. So I now have MP3s with the exact same name as before, but with a new image embedded. Are you saying iTunes will see the image change in each episode even though the name of my MP3 is exactly the same?
    So far, iTunes has immediately updated my main podcast image but all my individual episodes still have the old image.
    You can probably see what I'm talking about by searching iTunes for Netflix Junkies. You'll see that 'episodes' has different artwork than 'podcasts' in the search results. Do I just need to wait it out? Or rename my mp3s?
    Keep in mind, there is another podcast with the same name no artwork. This is not my podcast but someone else's.
    Thanks again!

  • Question about printing an image/control Using Report Generator

    The attached VI is an example of creating a report from a control or image. My problem is that when the control (xy graph) gets too large in the vertical direction it clips the image but, the horizontal is scaled to the width of the report. 
    First question is why does it scale in the horizontal and not the vertical? See the Test.pdf for what I am talking about. 
    Second, is it possible to control this behavior (edit/create an alternate for the Append Control Image to report or the Report VI's)?
    I have found many work around but ultimately it comes back to; why automatically scale one direction but not the other?
    For this application I don't mind that the graph is scaled down in the horizontal I just wish it would do the same thing in the vertical axis (I don't even want it to be a 1 to 1 zoom ratio, just fill the avalible report space).
    Thoughts?
    Attachments:
    Print XY Graph TEST.vi ‏55 KB
    Test.pdf ‏217 KB

    I agree all of the workarounds have limitations. One workaround, that I'm not sure if you have tried yet is change the numeric constant from 50 to 20 (I attached a picture showing which constant I am talking about). This seems to fix the issue just because the image never becomes larger than the report page itself.
    Let me know if that option creates any problems for you as well.
    Kevin S
    Applications Engineer
    National Instruments
    Attachments:
    Block Diagram.PNG ‏29 KB

  • Simple question about .PNG/transparent images

    I had to do a bit of work on a transparent image that will sit on a black background. I noticed that once I put the image on it's background a bit some layer mask editing I did are showing up...this is where I didn't quite mask everything correctly. My question- is there a way to check my image with-in PhotoShop on a black background before I Save As a PNG?
    Thanks

    If you use File...Save for Web and choose the "PNG-8" option, you can select the matte colour to use:
    Ken

  • Question about CSS BG image

    I was having a hard time making my BG image show up on browser.
    It was a .png file located in the image folder. My paths were correct, but the image didn't load.  In a fit of frustration, I put the image in the same folder as the CSS file and modified the path accordingly.
    No more problem!
    Why did that happen?

    Let's see the page in question.

  • Question about animated GIF image

    I am working on a new site. My client (using Safari 1.x with
    OS10.3x) tells
    me that this ani GIF doesn't load properly. I see it fine in
    10.4x, with
    both Safari 2x and FF1.5x, and on the PC. Whazzup wit dat?
    http://www.murraytestsite.com/nni/n_default.shtml
    Murray --- ICQ 71997575
    Adobe Community Expert
    (If you *MUST* email me, don't LAUGH when you do so!)
    ==================
    http://www.dreamweavermx-templates.com
    - Template Triage!
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    ==================

    Could this be a problem?
    2 different background images defined for the same container?
    #wrapper #topContent {
    background-image: url(Images/Anim.gif);
    and...
    #topContent {
    background-repeat: no-repeat;
    background-image: url(../images/Index.jpg);
    height: 208px;
    Just a thought..........
    John Malone
    ==============
    "Murray *ACE*" <[email protected]> wrote
    in message
    news:[email protected]...
    | That's it, John. Thanks.... It makes sense now that Joe
    pointed out to
    me
    | the background image-ness of that! I had just copied and
    pasted from a
    page
    | that I didn't create....
    |
    | --
    | Murray --- ICQ 71997575
    | Adobe Community Expert
    | (If you *MUST* email me, don't LAUGH when you do so!)
    | ==================
    |
    http://www.dreamweavermx-templates.com
    - Template Triage!
    |
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    |
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    |
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    | ==================
    |
    |
    | "John Malone" <[email protected]> wrote in
    message
    | news:[email protected]...
    | > Container not big enough....
    | >
    | > #wrapper #topContent {
    | > height: 167px;}
    | >
    | > Change to
    | >
    | > #wrapper #topContent {
    | > height: 208px;}
    | >
    | > That will do it I think...
    | > --
    | > John Malone
    | > ==============
    | > "Murray *ACE*" <[email protected]>
    wrote in message
    | > news:[email protected]...
    | > | John:
    | > |
    | > | Thanks. You are right - I had missed that. Why would
    that be? Any
    | > idea?
    | > |
    | > | --
    | > | Murray --- ICQ 71997575
    | > | Adobe Community Expert
    | > | (If you *MUST* email me, don't LAUGH when you do
    so!)
    | > | ==================
    | > |
    http://www.dreamweavermx-templates.com
    - Template Triage!
    | > |
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    | > |
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    | > |
    http://www.macromedia.com/support/search/
    - Macromedia (MM) Technotes
    | > | ==================
    | > |
    | > |
    | > | "John Malone" <[email protected]> wrote in
    message
    | > | news:[email protected]...
    | > | > Murray,
    | > | > The ani is cool BUT using FF & IE6 The ani
    does not show the last
    | > frame.
    | > | > Loaded and reloaded in both but still no last
    frame..
    | > | > (the one that has the saying "Where Ideas...."
    on the bottom).
    | > | > Just wanted you to know
    | > | > --
    | > | > John Malone
    | > | > ==============
    | > | > "Murray *ACE*"
    <[email protected]> wrote in message
    | > | > news:[email protected]...
    | > | > |I am working on a new site. My client (using
    Safari 1.x with
    | > OS10.3x)
    | > | > tells
    | > | > | me that this ani GIF doesn't load properly. I
    see it fine in
    10.4x,
    | > | > with
    | > | > | both Safari 2x and FF1.5x, and on the PC.
    Whazzup wit dat?
    | > | > |
    | > | > |
    http://www.murraytestsite.com/nni/n_default.shtml
    | > | > |
    | > | > |
    | > | > | --
    | > | > | Murray --- ICQ 71997575
    | > | > | Adobe Community Expert
    | > | > | (If you *MUST* email me, don't LAUGH when you
    do so!)
    | > | > | ==================
    | > | > |
    http://www.dreamweavermx-templates.com
    - Template Triage!
    | > | > |
    http://www.projectseven.com/go
    - DW FAQs, Tutorials & Resources
    | > | > |
    http://www.dwfaq.com - DW FAQs,
    Tutorials & Resources
    | > | > |
    http://www.macromedia.com/support/search/
    - Macromedia (MM)
    | > Technotes
    | > | > | ==================
    | > | > |
    | > | > |
    | > | > |
    | > | >
    | > | >
    | > |
    | > |
    | >
    | >
    |
    |

  • (pic included) Quick question about making a rendered logo

    Here is what my artboard looks like. What I'm trying to do is just get the black shapes as one solid logo without the white showing. For example, if I were to place this in another Illustrator project, it would still have the white rectangles with full transperency. I tried a tut online, but when I place the AI file into another project, the WHOLE image is invisible.
    If I were to open this AI file in Photoshop, I could use the Magic Wand to delete the white parts and leave just the black shape. I want to be able to resize the black shape and use it on banners, avatars, ect. Any help out there please?!
    I ALSO HAVE TEAM VIEWER!
    Background notes:
    I am using this for my gaming website and I would like to be able to use this for my logo. (Crossfire)
    Thanks all!

    C2,
    I don't see unite under pathfinder.
    In earlier versions Unite was called Add to shape area. You may need to press Alt/Option to get a simple path (again depending on versions).
    Apart from that, there is an Effect>Pathfinder which you should avoid and use the View>Pathfinder palette (bundled with the Transform palette).

  • Question about displaying an image among columns in a report

    Hi folks,
    I've looked at examples that I've come across, but I guess I'm missing something. I have a PL/SQL procedure which returns a sql statement for a report. I want to display an image between two of the columns. I already have the images stored in APEX. Can someone please point me at what I'm doing wrong here?
    SELECT id INTO file_id FROM APEX_APPLICATION_FILES
    WHERE filename = 'Blue box.jpg';
    q:=' select ';
    q:=q||'current_status_cd,';
    q:=q||'APEX_UTIL.GET_FILE(p_file_id => file_id,p_mime_type => ''image/jpeg'',p_inline => ''YES'') M,';
    q:=q||'userid,';
    q:=q||'usernum,';
    q:=q||'lastname,';
    q:=q||'firstname';
    q:=q||' from some_table ';
    return q;
    Thanks very much,
    -Adam
    Edited by: avonnieda on Nov 11, 2008 12:28 PM

    Hi Varad, thanks for your reply.
    Since posting I tried that too, here is the code I'm using. It always results in a
    failed to parse SQL query:
    ORA-00936: missing expression
    whenever I run the page. Any ideas? Here's the current code. If I remove the line that we're talking about, it runs fine.
    q:=' select ';
    q:=q||'current_status_cd,';
    q:=q||'<img src="#APP_IMAGES#Bluebox.jpg"> image,';
    q:=q||'userid,';
    q:=q||'usernum,';
    q:=q||'lastname,';
    q:=q||'firstname';
    q:=q||' from some_table ';
    Thanks very much,
    -Adam

  • Question about css referenced images with spry

    Using the Dreamweaver templae downloads design #1 and design #2, I pasted the spry assets and images from design #2 (accordion) into my website which is a copy of design #1.  In addition to the accordion images, This gives me the SpryAccordion.css and SpryAccordion.js which reference the accordion images as ../accordion_255_tab_normal.gif, etc., but in Dreamweaver designer and at runtime the accordion images to not appear.  Can someone please advise me where my issue might be? 
    Thanks,
    Jay

    Hi Jay,
    accordions? You could have a look about the possibilities of (translated from my German DW) Insert > jQuery UI. And for example these out of providers great number:
    http://jqueryui.com/accordion/
    http://users.tpg.com.au/j_birch/plugins/superfish/
    http://www.egrappler.com/a-stylo-modern-jquery-accordion-akordeon/
    http://www.dynamicdrive.com/dynamicindex1/indexb.html
    http://css3menu.com/?gclid=CI2FuNjPurYCFQpZ3godciQAAA
    aso (Google could be your friend).
    Hans-Günter
    P.S.
    Naturally you can remain at "good old" Spry, but some of the modern hardware will get their difficulties, so my hint is a preventative one. BUT in this case you really should load up your website, no matter how it looks like.

  • Question about making tables in Pages :-)

    Hello! I can't resize tables in Pages. I can drag them downwards but not horizontally! Anyone know why or what I can do about it? Thanks!

    HI promises,
    Do you men you can increase the size of a table vertically, but not horizontally?
    Tables are inserted as inline objects. Inline objects are treated like text, and are bound by the text margins set for the document (or for a layout within the document). When inserted, their width defaults to the maximum allowed.
    In the image, you can see the margin stops at 1 and 7.5 inches (indicated by blue arrows). You can't make the inline table any wider, but you can make it narrower.
    Click away from the table to deselect any cells that may be selected, then click once on the table to select the whole table. Use the mouse to grab the handle at the center of the right edge of the selected table, and drag left to decrease the width of the table. All columns will narrow proportionally:
    Move the smaller table left or right using the Text formatting tools avilable—the alignment buttons or a tab character and a tab stop.
    Regards,
    Barry

  • Question about dynamically changing image source

    hi, this might be a stupid question that i've simply never
    seen, but i have a picture on a page that, when the user clicks a
    link below, needs to change to an altered picture. probably very
    simple, i just need code that will change the image source of a
    named image by clicking a link. thanks for any help you can give
    me.

    You can use a remote rollover technique that uses css
    (nesting one or more elements inside an anchor link) and absolute
    positioning, or JavaScript.
    Here is a quick JavaScript to achieve this effect:
    xhtml code
    <head>
    <script src="external.js" language = "javascript" type =
    "text/javascript"></script>
    </head>
    <body>
    <p><a href="new_page.html" id="arrow"> New
    Page</a></p>
    <img src="images/image1_off.gif" width="100" height="20"
    id="arrowImg" alt="arrow" />
    </body>
    external JavaScript file
    window.onLoad = rolloverInit;
    function rolloverInit() {
    for (var i=0; i<document.links.length; i++)
    var linkObj = document.links
    if (linkObj.id) {
    var imgObj = document.getElementById(linkObj.id + "Img");
    if (imgObj) {
    setupRollover(linkObj, imgObj);
    function setupRollover(thisLink, thisImage) [
    this.Link.imgToChange = thisImage;
    this.Link.onmouseout = rollOut;
    this.Link.onmouseover = rollOver;
    thisLink.outImage = new Image();
    this.Link.outImage.src = this.Image.src;
    thisLink.overImage = new Image();
    thisLink.overImage.src = "images/" + thisLink.id +
    "_on.gif";
    function rollOver() {
    this.imgToChange.src = this.overImage.src;
    function rollOut() {
    this.imageToChange.src = this.outImage.src;
    There is a lot going on here but if you know a little
    JavaScript it will be failry easy to work it out. The important
    thing is to note the file layout, naming conventions and image
    constructs. Make sure the ids, etc are matched in the functions and
    html code.
    This technique shows the user what the image will become if
    they click the text when they mouse over the text link. This is
    handy for showing a preview of an image. You can alter the script
    to change the image without a preview if you don't want that
    effect.
    regards
    Nick Barling
    www.barkingweb.com

Maybe you are looking for

  • Regarding  vendor no for bapi..

    hi        iam using bapi in Fi report for opening and closing balance and another bapi for debit and credit.but iam not having full vendor ranges in bsik &bsak tables . so where can i fetch vendor no and posting date for bapi input values.. regards v

  • Panic problems, unexplained beep, and flash player keeps quitting

    I just bought my first mac computer 3 months ago and was given a new one a couple weeks ago because there were some issues with the first mac but those issues were nothing compared to what's happening with this second computer. First of all, I like t

  • Restored phone and get error

    I just restored my iphone b/c of apps crashing. Now it is just finished being restored and needs to be activated but now iTunes displays "iTunes could not connect to the iPhone "iPhone" because of an unknown error (0xE8000001)". What can i do to reso

  • Photoshop CS5 quits on exit

    Anyone any ideas of how to fix this? It has only recently started happening and it is driving me nuts. Thanks for any help.

  • Thumbnail previews have transparent backgrounds-NO!!!!!!

    In our workflow with Photoshop cc we need to save images as EPS files, all thumbnail previews have transparent backgrounds and the image is distorted. any way to get a thumbnail preview like you do when saved as a tiff???