Help centering image on jlabel

hi,
is there any way to center an image on a jlabel, aside from doing it in the constructor. i want to allow the user at anytime to set text or an image on a jlabel, allowing them to change it anytime. i'm able to get the text set and then remove it and place an image there instead, but the the problem is i want the image to be centered on the jlabel. any ideas on how to do this?
Thanks.

You need to make a ImageIcon to put on the JLabel.
JLabel label = new JLabel("Hello World");
label.setIcon(new ImageIcon("image.jpg"));I'm not sure how to do that in JBuilder 5, unless you can code that.

Similar Messages

  • I need help Centering a div box to a background image using dreamweaver cs5.5.

    I need help Centering a div box to a background image using dreamweaver cs5.5. Everything shift left when viewing on different size monitors?  See what I mean at
    www.woodlandhospice.com

    Have you looked at your page with images disabled?
    I urge you to re-think this approach to web design because images of text are not indexed by search engines, screen readers or translators.  Given the demographic group your site is targeting, you really need to ensure maximum web accessibility for all users.
    Navigation, headings and descriptions all need to be in real text -- not images of text.
    Ken is right.  Absolute positioning is pure poison for such a simple layout.  My advice is to start over with one of the pre-built Starter Pages in DW.  Go to File > New > Blank page > HTML.  Select a layout from the 3rd column and hit CREATE button.
    Nancy O.

  • Help with images.....pliiiizzzzzz

    Im new to java and need help inserting images on a GUI! Does anyone have any programs or snippets of code that've done this successfully - preferrably using the GridBagLayout as well as in swing? If you have anything that works well, feel free to send me the entire java file ([email protected]) or just post it!

    Just create a JLabel with an image icon and you are able to display any JPEG and GIF image. You might take a look at the following:
    http://java.sun.com/docs/books/tutorial/uiswing/components/label.html
    Hope this helps,
    Pierre

  • Displaying Image using JLabel in swings

    I am not understanding how to display a image in swing using JLabel Component.
    I am writing in the following manner:
    // importing necessary packages
    in init() method
    public void init()
    Container cp= getContentPane()
    JLabel jl=new JLabel("Image",new ImageIcon("<image>.gif"),JLabel.CENTER);
    cp.add(jl);
    applet is running and only label msg is displaying but not the image.
    Please help me so that i can solve this problem.where the image is to be placed??and how it has to be included?
    Please provide me the solution.

    cp.add(new JLabel("Image",new ImageIcon(new java.net.URL (getCodeBase(),"Test.gif")),JLabel.CENTER));

  • Images in jlabel

    hi,
    I found a problem in bringing out images in jlabel.
    thanks for peio for your sample code.
    I found an error "cannot resolve symbol"
    for frame.getContentPane().I extended JFrame in the
    class I implemented this init() method.
    getContentPane is working correctly when called simply.
    Being a UG student undertaking a training in java
    swings I have a little maturity in java bugs.
    please guide me.
    yours friendly,
    mohan raj

    ImageIcon caches the previously loaded images and won't reload an image from the same source. Unfortunately, this is not documented in the public API but only in the source of ImageIcon.java.public class ImageIcon implements Icon, Serializable, Accessible {
        /* Keep references to the filename and location so that
         * alternate persistence schemes have the option to archive
         * images symbolically rather than including the image data
         * in the archive.
         */Use ImageIO#read to return an Image and the constructor of ImageIcon that takes an Image as parameter and you'll be set.
    db
    edit Next itme, no help. I dislike cross posters.
    [http://forums.sun.com/thread.jspa?threadID=5340651]
    Edited by: Darryl.Burke

  • Images in jlabel -further query to peio1 and evert1234

    hi,
    I found a problem in bringing out images in jlabel.
    thanks for evert1234 for your reply.
    thanks for peio for your sample code.
    I found an error "cannot resolve symbol"
    for frame.getContentPane().I extended JFrame in the
    class I implemented this init() method.
    getContentPane is working correctly when called simply.
    Being a UG student undertaking a training in java
    swings I have a little maturity in java bugs.
    please guide me.
    yours friendly,
    mohan raj

    Hello ,
    try to no rewritte a new topic for a same problem. You have only to do a reply..
    For your problem try the further source.. I think it will help you
    // ImageLabelExample.java
    // Variations on a text & icon label.
    import javax.swing.*;
    import java.awt.*;
    public class ImageLabelExample {
    // put your address ICON
    private static Icon icon = new ImageIcon("images/smile.gif");
    public static void main(String[] args) {
    JLabel l;
    // create JLabel
         l=makeLabel(JLabel.TOP,JLabel.LEFT);
    // Add the labels to a frame and display it
    JFrame frame = new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    Container c = frame.getContentPane();
    c.setLayout(new FlowLayout(FlowLayout.CENTER, 3, 3));
    c.add(l);
    frame.setSize(350,150);
    frame.setVisible(true);
    protected static JLabel makeLabel(int vert, int horiz) {
    JLabel l = new JLabel("Smile", icon, SwingConstants.CENTER);
    l.setVerticalTextPosition(vert);
    l.setHorizontalTextPosition(horiz);
    l.setBorder(BorderFactory.createLineBorder(Color.black));
    return l;
    Do not forget to give the Duke Dollars ;)
    Thanks
    Best regards

  • ReportBuilder. Centering image in Report

    Hello everybody,
    I need help in centering image in Report.
    Thanks
    http://firebird-vbnet.blogspot.com/

    Hi giovannigiorgio,
    According to your description that you want to know how to centering an image in ReportBuilder, right?
    Before centering the image, we should be clear about some of the position related properties, only after we have done the proper setting of them can we be able to make the image to display in the center of the page.
    For physical page renderers, it's important to keep in mind the concept of Usable Area.  The Usable Area is the amount of space left on a page for your report to be drawn after reserving space for margins, headers and footers, and column spacing (for
    multi-column reports).
    Horizontal usable area:
    X = Page.Width - (Left Margin + Right Margin)
    Vertical usable area:
    Y = Page.Height - (Top Margin + Bottom Margin + Header Height + Footer Height)
    I suppose there is only image in the page. Please following the steps below to check all the related properties of size and center the image.
    Right click on Report area and select the Report Properties
    Make a note of the values for Page width(8.5), Page Height(11in), Left margin(1in), Right margin(1in),Top margin(1in),Bottom margin(1in)
    Close and go back to the design surface and in the Properties window, select Body
    Click the + symbol to expand the Size node and  do setting as below:
    Body Width  <=Page width- Left margin -Right margin(Body Width <=6.5)
    Body Height  <=Page Height- Top margin -Bottom margin-Header Height-FooterHeight(Body Height <=11-1-1-1-1=7)
    Right click the body area to insert an image and in the Image properties window select the size and check the “fit to size”
    the image will fit the size of the image item, we can set the position(Location and size) properties to determine the display of the image now
    In the Image properties, Set the value for position(Location and size) (according to the best Resolution of image to set the values of the location):
    Location left = (Body Width – Width of Image) /2    (Location left =(6.5-4.5)/2)
    Location Top =(Body Height – Height of Image) /2  (Location Top =(7-5) /2)
    If the page both include the image and the table, we should also consider the size of the table(Column Spacing in the width and Row Spacing in the height).
    Article about  the Pagination in Reporting Services for your reference:
    http://msdn.microsoft.com/en-us/library/dd255278.aspx
    If your problem still exists, please feel free to ask
    Regards
    Vicky Liu

  • Problem in displaying images using JLabel in Netbeans

    hi all,
    i am trying to display an image on JLabel in Netbeans.The image is visible in the design view but not displayed in the runtime.Can anyone help me out with suggestions???

    Duplicate - answer here http://forum.java.sun.com/thread.jspa?threadID=5153605&messageID=9578626#9578626

  • Changing images in JLabels

    I am creating a program which needs to display a grid of 7 by 7 images, as i am new to swing and fairly new to java i decided to use JLabels to show these images.
    I also need to be able to change these images, when buttons are clicked, i have set up the listeners for the buttons and the initial grid is correct however i cannot get the images to change?
    The JLabels are done as an array so each JLabel can be identified seperately.
    I have tried changing the labels eg Images=new JLabel("newimage.gif");
    and also I have tried creating other JLabels and doing things like
    Images[i]=newLabel //newLabel has the icon i want to use.
    I have repainting the screen and if i use the setText method on the JLabels then the text is displayed, however new images aren't
    do i need to not use JLabels, if so what can i use to do this?

    i tried using the setIcon function on my screen capture program and was unable to get it to update the image as long as the old image file was the same filename as the new image file. however if you change the image file name i got it to work fine......you just can't refresh an image of the same name if you've changed the content......

  • Centering images on fluid site

    Rebuilding a very antiquated site to meet the upcoming Google deadline, I'm having problems centering images. I defined a class of "center" but it's not working;
    http://www.aptcoweb.com/dev/aptcoFluid/office/label.htm
    Sometimes I want to center a single image, other times a group of images. What's wrong with my css?
    Also, what's the best way to center the iframe video?

    larrycfc wrote:
    Still don't know how to center the video. wrapping the iframe in a div made it disappear.
    Add some inline css styling to the iframe:
    <iframe width="640" style="display: block; margin: 0 auto;" height="480" src="https://www.youtube.com/embed/RWgpByd3UrI?rel=0" frameborder="0" allowfullscreen></iframe>

  • TS1314 Need help tranfering images to iphone...

    I need help tranfering images from my computer to my iphone. I've synced the images but they don't appear on my iphone, also on the file that contains the images, there's a file that says IPOD PHOTO CACHE. I don't know what to do. Please Help...

    Hope these help, do you not find them at all in the photos app?:
    iOS and iPod: Syncing photos using iTunes
    http://support.apple.com/kb/HT4236
    iPhoto '11: View photos or slideshows on iPod, iPhone, iPad, or Apple TV
    http://support.apple.com/kb/PH2437
    iTunes: Understanding the iPod Photo Cache folder
    http://support.apple.com/kb/TS1314
    ============================
    - Oz

  • Help centering a box in a jpanel

    hi every1,
    I need some help centering a box in a jpanel both
    horizontally and vertically.
    which layout is the correct one?
    could you post a scrap of code please?
    thanxalot
    stefano

    With the GridBagLayout you basically can do everything. Are there more components in the panel or just this box. If it's just the box, change the Layout of the panel to GridBagLayout and the anchor of the box to center. That should beeverything to do.
    Cheers
    Jonas

  • Help with image ready on ps3 extended

    I am pretty new to photo shop and have cs3 extended.
    I have a Yorkie website where I cut out my Yorkies and paste them to differnet backgrounds.... a lady that does the ANIMATED pictures  HAS DID A COUPLE FOR ME ....BUT I NEED TO LEARN TO DO THIS MYSELF.  She will not tell folks how to do:)
    The problem is once you work with a pic that is animated already then try to  add a dog.....by pasting....it removes the animation in the background pic.... and the picture no longer moves once the dog is added ?....She said she puts thru IMAGE READY...which I do not see anywhere on CS3 extended.  I will try to insert a pic she did for me and any help would be greatly appreciated....as I can do but then the picture is no longer animated once altered in my photoshop but she is doing somehow.....so has to be poss ?  If I were to do this pic it would stop moving once the dogs were added....plus not as good as her but practicing........could it be the fact she is doing in layers and I am doing copy and paste...I do know she puts thru Image ready and I do not know where this is located on cs3 extended or how to do?
    am

    well...........l when I try to open Gif with the import and chose the video frames to layers...am getting a message saying I need Quicktime 7.1 to be able to do??? and when selecting import that is the only option I have to open my animated picture?...YOU HAVE BEEN SO MUCH HELP!   THANK YOU SO MUCH...! 
       BLUE MONDAY EXCLUSIVES   
    Date: Sat, 17 Apr 2010 20:23:27 -0600
    From: [email protected]
    To: [email protected]
    Subject: Re: Help with image ready on ps3 extended
    I'm not sure anyone mentioned this but if not to open GIFs using the import you have to enter the GIF name as GIF isn't listed as one of the options.
    It sounds like you are viewing the images in a maximized screen mode. To view more than one document, press F to cycle through the screen modes. FYI, only the contents of the currently selected document can be viewed in the layers palette.
    I'll just talk about copy/paste so as not to confuse...
    If you are going to copy/paste, click the frame around the dog document to target it. Your layers palette will now contain the contents of the dog document. Click on the layer in the layers palette with the selected dog over transparency. With that layer highlighted in your layers palette, press Ctrl A; then Ctrl C. (Select<Select All; Edit<copy if you prefer using the menu.) This will copy that layer into your clipboard.
    Next, click the frame of the document containing the animation. Click the topmost layer in the layers palette because we want you dog to be in the top layer. Press Ctrl + V. (Edit<Paste if you prefer using the menu).
    Your dog is most likely going to be too big. Use Edit<Free Transform to size and move the dog to the desired location.
    At this point, your dog should be showing in each frame in the animation palette.
    Example:
    http://forums.adobe.com/servlet/JiveServlet/downloadImage/25315/with-palettes-open.jpg
    I'm using the older Image Ready me method. The highlighted place in the palette is where you switch methods between the old method and the new timeline. Notice, I have the layers and animation palette both in the workspace...and I'm not in a maximized mode. The red arrow shows the correlation between the frame and the layer represented by it in the layers palette.
    Image:second-image.jpg
    Here I have a second image to slip into my animation. I have the creature selected and on it's own layer with transparency around it. Notice that the the layer with the isolated creature is highlighted. At this stage, I'll press Ctrl + A; then Ctrl + C to select and save this image to my clipboard.
    Image:creature-added.jpg
    Here, I've pasted (Ctrl + V or Edit<Paste) in my creature and resized it (Ctrl + T or Edit<free transform) so he can be jumped. I also added a shadow under my creature which I added to a layer under my creature. Notice that when Frame on is selected in the animation palette that the eye is on both the creature and the shadow. If I click the eye to turn them (creature and shadow layer) off, they disappear from the entire animation. I can make them appear at any frame by clicking the desired frame in the animation then turning on the eye icon for the creature and shadow layer in the layers palette. I can also adjust opacity if desired.
    You could even more than the one image if you want the dog to appear to move. Use the eyeball visibility to determine which pose will be used for that frame.
    Example:
    Image:jump-creature-gif.gif
    Here, I used transform warp to adjust the pose of the creature for a few frames as he's jumping the creature...just for fun.
    >

  • Help my image library is now showing errors

    I have Lightroom 5 and have just upgrade with the latest updates. Now all the unkeyworded images have an error notice on them. How do I restore them to were there were yesterday? it looks like they are now only thumbnails as they are very pixelated. There is now image metadata showing at the side of the image either.
    Any suggestions please?

    Hi Keith,
    if I view the library in the grid there is an ! mark next to every photo that I haven't given keywords to yet but if i view them in the Loupe window it has a label above which says There was an error working with the photo. There is no metadata showing next to it. The only thing I have done in the last few days to the computer is to run updates on my operating system. Actually Lightroom isn't then only thing not working, my accounting programme won't work at all now!
    I am new to lightroom so not 100% sure what I am doing, any insight would be welcome.
    Thanks
    Date: Thu, 24 Oct 2013 04:06:21 -0700
    From: [email protected]
    To: [email protected]
    Subject: Help my image library is now showing errors
        Re: Help my image library is now showing errors
        created by Keith_Reeder in Photoshop Lightroom - View the full discussion
    What do you mean by "error notice"?
         Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5784643#5784643
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5784643#5784643
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5784643#5784643. In the Actions box on the right, click the Stop Email Notifications link.
               Start a new discussion in Photoshop Lightroom at Adobe Community
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • How to display help based on the Jlabel description

    Hi all,
    I try to display help based on the Jlabel description. When a user click on the help button, I want to use the label description to match correct help topic and display on the screen. I have following code as Field-level help but it returns error. Looks like I cannot use jLabel1.gettext() dynamically. Please let me know if you have any idea!
                String st = jLabel1.getText();
                URL url = HelpSet.findHelpSet(null,"preferences.hs");
              hs = new HelpSet(null,url);
               hb = hs.createHelpBroker();                      
               hb.enableHelp( jLabel1, jLabel1.gettext(), hs );Thanks,
    NY

    You did notice that this is the Forms Forum right???
    If not then click [url http://forums.oracle.com/forums/forum.jspa?forumID=84]Here
    Tony

Maybe you are looking for

  • How can I create different headers in Pages 09?

    I hope someone can explain to me how to solve this issue: I'm creating a simple training manual and I want the different chapters to appear in the header of the page - Chapter 1, Chapter 2, etc. Left and right pages are different because the margin h

  • Capacity bar does not show detail in itunes

    Capacity bar does not show detail in itunes 10 when iphone is connected via wifi when I connect via cable it corrects itself running os 5.01

  • FIREFIIGHTER Back Ground Job !

    I am on FF 3.0 CC 4.0 On I run the FF Log, I am told that the File is not genereated as the Back Ground Job is not scheduled. Which is th e back ground Job needed to get these reports ? Thanks

  • Option to Right click?

    Option to Right click? I'm trying to take the tutorials for Shake. There a some instances where I need to load info into the "parameters2" tab. I'm supposed to right click the viewer script button. But, I am using an apple mouse w/ one button. I've t

  • Access a DVD via the shell without knowing it's name

    I'm trying to write a simple shell script that will access a folder on the current DVD, without knowing the name of the DVD. I would like to access via /Volumes/DVD, but that doesn't exist. Instead, when a DVD is inserted, it is mounted with it's nam