JLabel icon position question

I want to have a JLabel with text and an icon. I want the text to be positioned on the left and I want the icon on the right. My question is: Is this possible and if so how?

RTFM
http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JLabel.html#setHorizontalTextPosition(int)

Similar Messages

  • JLabel Icon Update Question

    Hi. I have created a jLabel that get's it's Icon updated via a value derived from a MYSQL query. The Icon1 value is a URL. My question is, if I do the MYSQL query and the URL doesn't change from the existing value, does the jLabel still go out and pull the image over? Or does it recognize that the URL is still the same and doesn't make an attempt at pulling the image over? Basically, I am asking this because I'm trying to determine the load on my webserver. Thank you for your help!
    image1.setIcon(icon1);

    Hi Daryl. Here is what I'm doing:
    protected static ImageIcon createImageIcon(String URL,
                                                   String description) {
            //java.net.URL imgURL = LabelDemo.class.getResource(URL);
            java.net.URL imgURL = null;
        try {
          imgURL = new java.net.URL(URL);
        } catch (Exception e) {
          //Logger.getLogger(LabelDemo.class.getName()).log(Level.SEVERE, null, ex);
            if (imgURL != null) {
                return new ImageIcon(imgURL, description);
            } else {
                System.err.println("Couldn't find file: " + URL);
                return null;
    ImageIcon icon1 = createImageIcon("https://www.website.com/images/" + dateVal + "/thumbs/" + image2Val + "",
                       image1.setIcon(icon1);

  • JLabel Icon Updates

    I am running a MYSQL query and assigning the values to Jlabels. Like this:
    jLabel2.setText ( nameVal );I want to be able to assign the icons of the jLabels as well. Is this possible?

    Same result. Here is the whole thing right from the tutorials:
    //package components;
    import java.awt.GridLayout;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JFrame;
    import javax.swing.ImageIcon;
    import javax.swing.UIManager;
    import javax.swing.SwingUtilities;
    * LabelDemo.java needs one other file:
    *   images/middle.gif
    public class LabelDemo extends JPanel {
        public LabelDemo() {
            super(new GridLayout(3,1));  //3 rows, 1 column
            JLabel label1, label2, label3;
            ImageIcon icon = createImageIcon("http://duke.kenai.com/iconSized/duke4.gif",
                                             "a pretty but meaningless splat");
            //Create the first label.
            label1 = new JLabel("Image and Text",
                                icon,
                                JLabel.CENTER);
            //Set the position of its text, relative to its icon:
            label1.setVerticalTextPosition(JLabel.BOTTOM);
            label1.setHorizontalTextPosition(JLabel.CENTER);
            //Create the other labels.
            label2 = new JLabel("Text-Only Label");
            label3 = new JLabel(icon);
            //Create tool tips, for the heck of it.
            label1.setToolTipText("A label containing both image and text");
            label2.setToolTipText("A label containing only text");
            label3.setToolTipText("A label containing only an image");
            //Add the labels.
            add(label1);
            add(label2);
            add(label3);
        /** Returns an ImageIcon, or null if the path was invalid. */
        protected static ImageIcon createImageIcon(String URL,
                                                   String description) {
            java.net.URL imgURL = LabelDemo.class.getResource(URL);
            if (imgURL != null) {
                return new ImageIcon(imgURL, description);
            } else {
                System.err.println("Couldn't find file: " + URL);
                return null;
         * Create the GUI and show it.  For thread safety,
         * this method should be invoked from the
         * event dispatch thread.
        private static void createAndShowGUI() {
            //Create and set up the window.
            JFrame frame = new JFrame("LabelDemo");
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            //Add content to the window.
            frame.add(new LabelDemo());
            //Display the window.
            frame.pack();
            frame.setVisible(true);
        public static void main(String[] args) {
            //Schedule a job for the event dispatch thread:
            //creating and showing this application's GUI.
            SwingUtilities.invokeLater(new Runnable() {
                public void run() {
              //Turn off metal's use of bold fonts
                 UIManager.put("swing.boldMetal", Boolean.FALSE);
              createAndShowGUI();
    }

  • Blue icon with question mark instead of image in email

    Sometimes I get a blue icon with question mark instead of image in email, when viewing in Apple Mail Program.
    Does anyone know why?????

    I'm asking your thread get redirected to the proper forum. Please read this tip on how to post on Discussions for future threads:
    http://discussions.apple.com/thread.jspa?threadID=1574700
    Is this issue with Tiger or Leopard? Your profile indicates you have a machine with Tiger, yet your signature of your post says you have Leopard.
    Also, there is no such thing as a Powerbook Pro. Read the text under the screen to tell us exactly which model you have. MacBook Pro is the name given to Macs that are for the pro lineup of notebooks once Apple shifted to the Intel CPU.
    Message was edited by: a brody

  • Hi . i have Intel based iMac. i erased whole hard disk. now it flashes folder icon with question mark... i have no internet or orginal dvd.... i want to clean install any mac osx..friend got mac book pro and osx in dmg format . what are my options?

    hi . i have Intel based iMac. i erased whole hard disk. now it flashes folder icon with question mark... i have no internet or orginal dvd.... i want to clean install any mac osx..friend got mac book pro and osx in dmg format . what are my options?

    On your friend's computer with an internet connection, log into the Mac App Store with your ID and download Yosemite from the Purchases section of the Mac App Store. The make a bootable USB install media using
    http://liondiskmaker.com/
    Then boot from that on your computer and install
    You need an internet connection to install via Recovery mode

  • Desktop icons position not kept

    Hi. I'm using 10.6.2 and sometimes (not all) when I start my machine, the desktop icons (which I have arranged by snap to grid) are not where they used to be the last time I was with the cmputer on but they all show up aligned on the right of the screen, next to the hard drive icons in columns. I did not yet find a patteen like "this only happens if I have the computer turned of more than X x or y hours". Sometimes I leave for a couple of days and the icons are good when I come back. Sometimes just a few hours with the computer turned off and the icons position is not kept. Other time is the other way around.
    Any ideas? Someone with the same issue?
    Thanks.

    I had this problem, too, and brought it up with a "Genius" this morning. His solution -- which seems to have worked -- was first to show hidden files (using a utility or Terminal, as described elsewhere) and then delete the .DS_Store file which now appears on the desktop. The file rebuilt itself, and the icons now stay where I put them after a restart or relaunch of the Finder. You should rehide the hidden files once you've done this.
    I had previously tried resetting the PRAM and deleting a couple of plist files from the Preferences Library, which other people had recommended, but those solutions didn't work. This did. Thanks, Geniuses in Emeryville.
    Rick

  • White screen with flashing file icon with question mark mean

    What does this mean.   We are getting a white screen with flashing file icon with question mark inside the file. 

    It almost certainly means it can't find a bootable volume (one with OS X on it).
    Which means most likely you will have to find your original system installation DVD and install it. Then you should figure out what caused the problem.
    Read this to diagnose it before resorting to reinstalling the OS:
    http://support.apple.com/kb/TS1440
    Excerpt:
    Additional steps
    If your Mac still starts to a flashing question mark, follow the steps below. If any step resolves the issue, you don't need to continue to the next one.
    Select your Mac OS X startup disk with Startup Manager by restarting and holding the Option key. After your Mac starts up, restart again to verify that the flashing question mark does not appear.
    If the issue persists, insert your Mac OS X installation disc. Be sure to either use the disc that came with your Mac, or, if you installed a later Mac OS X version from disc, use the newer disc.
    MacBook Air note: On a MacBook Air, there are two options for starting up from Mac OS X media: Either connect a MacBook Air SuperDrive to the MacBook Air via the USB port and restart the computer, holding down the C key during startup, or use Remote Install Mac OS X to startup from a system software DVD that's located on a partner computer. Once started up from Mac OS X media, skip to step 3.
    Restart the computer, then hold the C key during startup.
    From the Utilities menu, choose Disk Utility. Don't click Continue.
    Select your Mac OS X disk (named "Macintosh HD" by default) in the left side of the Disk Utility window.
    Click the First Aid tab.
    Click Repair Disk to verify and repair any issues with your Mac OS X startup disk.
    After repairing the disk, try to start up normally.
    Important: If Disk Utility finds issues it cannot repair, you may need to back up as much of your data as possible (or use Time Machine to back up to a different disk), then erase the disk and reinstall Mac OS X. You should back up important files and data before erasing a drive. Erasing deletes everything on the hard disk (including things on your desktop). Also, you can install Mac OS X onto an external disk, start from the external disk, and use Migration Assistant to transfer items from your usual internal Mac OS X startup disk to the external disk, then erase the internal disk and reinstall Mac OS X.
    If the issue persists, and Disk Utility didn't find any irreparable issues, quit Disk Utility, quit the Installer, select your disk when prompted, and restart.
    If the issue continues, reset PRAM. Note: After resetting PRAM, if the computer starts up normally, reselect the startup disk in the Startup Disk preferences.
    If none of these steps resolve the issue, start up from the Mac OS X Installation disc and reinstall Mac OS X.

  • Blinking Folder Icon with Question Mark at startup - Is my HD dead?

    I was uploading a .Mov file to my idisk when I got an error message - not sure what it said. But the screen dimmed, and then froze. I held down the power to power down - which it did.
    When I fired it back up, I heard the startup sound - then the screen went white. A gray folder icon appears with a question mark over it - and it blinks.
    I tried powering down again and unplugging, and also powering on with all peripherals unplugged. Again I get the white screen, folder icon and question mark.
    That .Mov was being uploaded as a freelance project for Google due tomorrow morning. Great timing! Am I screwed?
    Thanks!
    Gordon

    I booted from the Mac OS X Install disk and opened the Disk Utility.
    The options for disks to repair are
    1. The Mac OS X Install Disk 1
    2. A drive that's simply labeled "Media."
    Is this "Media" disk my HD? I'm not getting any options to repair the disk.
    Disk Description: Media
    Connection Bus: Serial ATA 2
    Connection Type: Internal
    Total Capacity: 0 Bytes - that doesn't sound good.
    Write Status: Read/Write
    Again, thanks for your help.
    G

  • Icon view, icon position not kept

    Most of my files are displayed in icon view. I have group them in positions easy to remember.
    Since upgrading to SL every now and then a folder (or two) will have the icons ordered by name and positioned in a grid even if I haven't give that command.
    Since this is annoying is there a solution to avoid that finder behavior?

    ok, that may be the reason for not keeping the icon positions but who except the finder will be responsible for a corrupt .DS_store file?
    There are other Finder problems not only on my MacBook Pro but also on the MacBooks running in our household since we upgraded to SL. These problems usually result in a spinning ball of death and one has to press the ON switch to restart the Mac.
    I haven't seen such issues in all previous upgrades from Mac OS X onwards. This is really disappointing since the SL upgrade was announced as a minor one but now it turns out as a nightmare to me.

  • Flashing folder icons with question mark

    After reading through the forums I've found a few discussions and users that have similar problems as me but haven't seen anything that deals directly with my issues.
    After upgrading to Leopard last night, it ran sluggishly for about 15 minutes. I got impatient and decided to restart. While trying to restart it froze, so I just shut my powerbook down. When I tried to boot back up I got the "flashing folder icons with question mark", I've since found out that it isn't finding any type of drive to boot off of. I reset the pram, tried to reboot with the same result. Tried to boot up using cmd-s but still got nothing but flashing folders. Booted up from the Leopard install disc to try and do an archive and install and it said it couldn't upgrade because it couldn't find tiger on my machine. So I booted from the Tiger install discs to try and re-install tiger again. Tiger cant find my HD to install on; I'm thinking this may be due to Leopards install. I ran disk utility and it couldn't complete the verifying process. I got this "Error: The underlying task reported failure on exit."
    After work I'm going to try to boot up in target mode to pull any data i can and try erase my HD and install from there.
    To me it seems like a HD issue. Anyone have any thoughts?
    Thanks in advanced.
    -Chance

    Chank wrote:
    After reading through the forums I've found a few discussions and users that have similar problems as me but haven't seen anything that deals directly with my issues.
    After upgrading to Leopard last night, it ran sluggishly for about 15 minutes. I got impatient and decided to restart.
    The "sluggishness" is perfectly normal. It's well-known and it is not an issue.
    You should have waited for spotlight to finish indexing.
    You may have broken some links by forcing a shutdown while things were still being setup.
    Which install method did you use, upgrade, archive or erase?

  • I have one problem with my iphone 4s i c"ant  make facetime calls with other iphons. olso when i make calls on the facetime icon is question sign! can any oane hellp me! wath my be the problem because it is all new iphone!

    i have one problem with my iphone 4s i c"ant  make facetime calls with other iphons. olso when i make calls on the facetime icon is question sign! can any oane hellp me! wath my be the problem because it is all new iphone!

    First question where ae you located?  If you're in the Middle East or UAE, factime has been restricted by the government.
    If your not from there look here:
    http://support.apple.com/kb/TS3367

  • Dock icons now question marks

    I just got the new iMac today and transfered my data from my old imac to this one via Firewire. Now all my dock icons are question marks. How do I update them?

    I just tried something. I printed a page from my printer; printer icon showed up in dock.  I quickly right clicked on the icon and selected Options/Keep in Dock.  Now my icons are back.

  • JLabel (icon Image) without picture?

    I am make applet containing JLabel (Icon Image). When I run this applet from server and used image-file "middle.gif" (from tutorial) - there was all Ok. After this I changed color of image on MS Photo Editor and now I get JLabel without icon and there is no errors. I don't understand what happens? Anybody know what is it?

    Of course. In directory "Images" I have follow files:
    green.gif
    middle.gif
    red.gif
    Files green.gif and red.gif are middle.gif but pictures on them have respective colors. This colors I get using MS Photo Editor.
    import javax.swing.*;
    import java.awt.*;
    import java.net.*;
    public class tLabImage extends JApplet{
    public void init () {
    JFrame f=new JFrame();
    URL url=null;
    try {
    // url=new URL("http://10.1.1.6/Images/middle-1.gif");
    url=new URL("http://10.1.1.6/Images/green.gif");
    catch (MalformedURLException e) {System.out.println (e.getMessage());}
    Image image=getImage(url);
    ImageIcon icon=new ImageIcon(image);
    JLabel l=new JLabel ("text", icon, JLabel.LEFT);
    f.setLocation(200,300);
    f.getContentPane().setLayout(new GridLayout(0,2));
    f.getContentPane().add(l);
    f.pack();
    f.setVisible(true);
    When I run this programm I get JLabel without icon (only text). Why? Who can answer?

  • Snow Leopard Finder Icons Position

    Hi!
    Sometimes, when i restart the OS the system arrange the icons positions on the left side of the screen...
    I have a lot of icons (using two monitors) and this thing is very, very unpleasant!
    Anyone solved this problem?
    The genius tech's don't have a clue...
    Regards

    Hi!
    The problem isn't in the menu/option, it seems that when you connect external discs (USB or Firewire) and restart the machine, the icons on the desktop are rearranged by the system itself losing the initial position used by the owner of the account.
    If tried some tips found in the web but didn't solve the problem.
    Regards

  • I'd like to install itunes on new laptop but I don't want to lose actual icon position on my iphone

    I'd like to install itunes on a new laptop. Last year I did this operation and when I syncronized my iphone I lost the icon position and custom app folder. I didn't lose the personal data. How can I do?

    Copy everything from your old computer, or your backup copy of your old computer, to the new one.

Maybe you are looking for

  • How do i put text in the picture

    how do i put text in the picture ?

  • Start up slow on iMac

    My iMac is SLOW, SLOW, SLOW... Any insights? EtreCheck below. Many thanks! Hardware Information:     iMac (27-inch, Mid 2011)     iMac - model: iMac12,2     1 3.1 GHz Intel Core i5 CPU: 4 cores     16 GB RAM Video Information:     AMD Radeon HD 6970M

  • XML Gateway Seeded Function/Map for PO Creation

    Hi. I am trying to determine if existing EBS XML Gateway functions/maps exist for inserting, changing and cancelling POs into EBS. If not, I would assume then that I could build these XML Gateway components myself. Thanks.

  • Serial Number in Subcontracting Scenario: ECC 5.0

    Hello Experts, System Landscape: ECC 5.0 Company code=1000, Plant 1000 Company code=2000, Plant 2000 Sending material for rework (component and material is same) At Plant 1000: Scenario: Subcontracting of serialized material- A subcontracting purchas

  • Dynamic List in WPC didn't work

    Hi Experts I've created a new site in WPC and a few wpc-articles which a stored in a shared folder in KM. I've done the configuration for the dynamic List WPC-iView like sorting, number of articles etc. The start-folder is /documents/news BUT at runt