Images inside of buttons

I know that I can put a small image in a JButton with: new ImageIcon("imageName.fig"), but is there a way to put an entire image inside a button. I want an image that I have to be a button and the button to be formed to the size of that image. Is this possible?

This should work. You'll need an image called test.jpg.
import java.awt.*;
import javax.swing.*;
public class TestApp extends JFrame
     public static void main(String[] args)
          new TestApp().setVisible(true);
     private TestApp()
          setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          ImageIcon im = new ImageIcon("test.jpg");
          JButton b = new JButton(im);
          getContentPane().add(b);
          pack();
}

Similar Messages

  • Problems putting Images inside large buttons

    The problem below is using the Fireworks program to create a
    Button with an Image inside.
    Ok I have created a generic button , This button is not a
    fireworks button it was made from scratch, the size is roughly
    90x90 , what I want to do is place and Image inside this button and
    then to be able to move the image into the correct place, If I
    paste the image into the button it simply places the image where it
    wants I cannot move the image , I tried creating a Layer and Frame
    and using the marque tool but it pastes the image top left hand
    corner and the image cannot be moved.
    Where am I going wrong.?.
    SPECCY.

    do this in an image editor. It would be much simpler/easier
    and more
    reliable that using html.
    If you still want to do it in html, put the button image as a
    background.
    > Where am I going wrong.?.

  • Rotate Button (Or maybe use an image inside button?)

    In the sake of a good user inteface,
    I'm trying to make this: http://farm5.static.flickr.com/4071/5154426822_93ffd02f55_o.jpg
    look like this: http://farm2.static.flickr.com/1114/5153818257_cf7bd3cee0_o.jpg
    h3. Two ways I can think of:
    * rotate the button component - I have no idea on how to do that. If anyone can give me an example i'll aprreciate it.. (I know JSF, myfaces and richfaces. Not much about javascript)
    * put an image on the button. (Can you actually put an image on a command button?)
    Any other suggestions would also be great.
    Tnx!

    user8863870 wrote:
    In the sake of a good user inteface,
    I'm trying to make this: http://farm5.static.flickr.com/4071/5154426822_93ffd02f55_o.jpg
    look like this: http://farm2.static.flickr.com/1114/5153818257_cf7bd3cee0_o.jpg
    h3. Two ways I can think of:
    * rotate the button component - I have no idea on how to do that. Who says that it is possible? It is possible with a client side embedded framework like Flash, Silverlight or JavaFX. But certainly not with vanilla javascript/css/html.
    * put an image on the button. (Can you actually put an image on a command button?)You can put an image on a commandLink. But that image will be square and contain lots of empty space that will still be clickable.
    >
    Any other suggestions would also be great.
    Tnx!You could get somewhere with a HTML image map, but I have no experience trying to make that work with JSF. I haven't seen a component yet that links image map functionality to a JSF component. Is it an option to work with a regular link in stead of a commandButton/commandLink?

  • Image inside of PDF file?

    I am creating a .bmp file in Photoshop and inserting it into a word document. I then save that image as a .pdf. When viewing pdf and hovering your cursor over the image inside the .pdf, the name of the image file appears(like a text tool tip). Is there a way to prevent this from happening?
    Thanks

    PDF Optimizer - Perhaps not available in Standard.
    Look for it under the 'Advanced' menu drop-down.
    When Acrobat supported file formats are brought into PDF with Acrobat (PDFMaker) many have configuration options associated with their "Convert to PDF".
    A supported graphics file format, by itself or if in an authoring file (FM, DOC, etc.) will be 'touched' by these.
    Open Acrobat's Preferences. Select the Category "Convert To PDF".  Scroll down the center pane's listing of  file formats. Locate and select PNG. Click the 'Edit' button. Some configuration options for compression and color management are provided. You could play with these.
    HOWEVER -
    The Word to PDF process would have to be via PDFMaker (Convert... from the Acrobat Bar) and *not* via Save As PDF-XPS.  The MS Office routine does not provide the functionality described above for Acrobat. The Office process is completely separate from anything "Adobe" or "Acrobat".
    Also, something described often by Bill@VT -- Word, particular 2007, 2010 seems to do some 'odd' things to graphics in a Word file that is going to anything other than a piece of paper.
    Some folks seem to get satisfactory behavior by use of EPS.
    Also, it may be worth playing with a JPEG of the logo.
    About the PDF.
    From what you describe it seems that you have a web link, in the PDF, to the stand alone PNG. This would permit separate download of the PNG.
    I suspect that Acrobat Standard 9.x does not provide the tool set available in Pro or Pro Extended. So, you'd not be able to edit/delete the web link (or link) in the PDF.
    Perhaps, back in Word you have a 'Hyperlink' present that can be edited/removed?
    Also, in Word, try an "import" - browse to file - select - make it an integral part of the Word file. Then produce the PDF.
    Fundamentally, the PDF reflects the content mastered in the Word file. The Office Save As PDF-XPS or the Adobe PDFMaker merely process this out with whatever configuration option settings each provides.
    Be well...

  • Threshold image inside loop

    I am trying to threshold an image inside a while loop so the user can fine tune their threshold values.  The threshold values are being iterated correctly but when the image passes through its 2nd iteration the image goes black or disappears.  Any suggestions?  Thanks.
    Alex

    ladouceuraj a écrit :
    We are currently using shift registers but its not working.  The value is changed correctly but the image does not change.  In fact the image either completely disappears or it is thresholded entirely black.  I have attached a ss of the loop.
    According to the diagram, this behaviour is normal : once the image has been thresholded, the original data are replaced with the new [0, 1] values. Nothing left for another run.
    Define a second image and wire it to the "destination image" input of the threshold function.
    BTW, a shift register is completely useless when working with images, since the wire contains a reference  to the image structure, not the data itself.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • Load html page (google image) inside panel?

    Is it possible to create a button  or some way to load a webpage (like google images) inside a panel?

    You can only implement this with HTML Widget.

  • Image inside font

    This tutorial shows how to place image inside font using layer mask http://www.photoshopessentials.com/basics/clipping-masks-and-type/
    Can someone suggest how to place  different image inside each letter?

    One way is to place each image on separate layer like normal then select a character and make it a selection, then apply that selection as a mask for that image layer.
    Another way is to select a character , make it a selection and then choose Edit>Paste into.
    To make a selection -
    Type out your text
    hold down ctrl or cmd key and click on the T icon in the text layer - this will make a selection for all the characters.
    hold down the alt or opt key and drag a negative selection around the characters you don't want
    You now have a selection for a single character, once you apply the above repeat these steps to select another character.
    Or
    You can use the text mask selection tools hidden in the text fly out. Using these tools will allow you to type out characters of a selection instead of live text.
    So you can type all to once and do all the steps above, or simply do one character at a time and save a bunch of repetitive wasted time.
    To access the hidden text tools move your mouse over the text tool in the left tool bar then press your mouse button down and wait a few seconds and the fly out will appear or if you happen to have a two button mouse you can simply right click on the tool for it to instantly appear.
    To recap the simplest method -
    Place your images
    Select one of the image layers
    Using the text mask tool type the first character
    Click the move tool (lowercase v) to get out the text tool and leave you with just a selection
    Layer>Layer Mask>Reveal selection or {click the icon at the bottom of the layers panel that looks like a circle inside of a square} This will convert the selection to a mask.
    Repeat for the rest of the characters.

  • How do i get a placed image to appear as image inside a layer?

    There is a long winded reason why I want this, but in essence I am trying to replicate another artwork that has been supplied to me.
    When I place a Photoshop image (TIFF / PSD etc) how can I get it so that it simply appears as <image> inside the relevant layer (screen shot attached)
    I am finding that when I place an image I do not get this

    That's what I had assumed. It just doesn't seem to be working for me. You don't think there is a Preference setting that might disable it?

  • Can't get rid of background image of toolbar buttons

    I am just a front-end developer and responsible for the front-end look of an ADF application that we are creating: We are using jDeveloper 11.1.1.4.0 (and we cannot upgrade due to being told no...so I cannot USE the skin editor which when I tried to use, migrates the files).
    I have created the necessary directories and files per tutorials I have been reading up on...
    skins directory - (new directory)
    skin.css (new file)
    Web-Inf -
    trinidad-skins.xml (new file and correctly configured)
    trinidad-config.xml (existing file but updated to use the new skin)
    Within the trinidad-skins.xml file I have the the new skin specified and is extending the "fusionFx-v1.desktop" default theme being used.
    Now the problem... I cannot get the background images to be overwritten or disabled for af|toolbar::item within the .css file
    I have looked up information about how to overwrite this and I tried to use the
    -tr-inhibit: background-image; within the .css declaration like this
    <code>
    af|toolbar::item {
    -tr-inhibit: background-image;
    </code>
    That was unsuccessful. I even just tried standard background {none;} and that was a no go as wel.
    What am I doing wrong here? This is driving me nuts... they made this skinning stuff way too complicated IMO. I don't see why I can't just add a class to the component within the property inspector of that component and then be able to reference it via normal css conventions... but nope BREAKS grrr... And I'm advanced level CSS coder! This stuff has me absolutely clueless and ready to just quit!
    Any suggestions or help is appreciated! And again... I cannot use the skin editor! Everytime I tried to, it prompted me to migrate the application and I cannot do this since there are about 5 other developers working on this application (we use clearcase for version control).
    Thanks,
    Michael

    I can't use the stand alone skin editor since it will want me to migrate the project files (developed in 11.1.1.4) and all files are source controlled via ClearCase.
    I have been experimenting...This is the code on the .jspx page
    <code>
    <af:panelGroupLayout id="header" styleClass="headerParent">
    <af:panelGroupLayout id="topLinkBar" layout="horizontal" styleClass="topLinkBar AFStretchWidth">
    <af:outputLabel value="#{customeradminportalviewcontrollerBundle.CUSTOMER_ACCOUNT}" styleClass="customerLabel"/>
    <af:outputText value="outputText2012" styleClass="customerOutput"/>
    <af:toolbox id="topLinkToolBox" styleClass="topLinkToolBox">
    <af:toolbar id="topLinkToolBar" styleClass="topLinkToolBar">
    <af:commandToolbarButton text="#{customeradminportalviewcontrollerBundle.HELP}" id="ctb2"/>
    <af:commandToolbarButton text="#{customeradminportalviewcontrollerBundle.POWER_INVOICE}" id="ctb1"/>
    <af:commandToolbarButton text="#{customeradminportalviewcontrollerBundle.CONTRACT}" id="ctb3"/>
    <af:commandToolbarButton text="#{customeradminportalviewcontrollerBundle.SIGNOUT}" id="ctb4"/>
    </af:toolbar>
    </af:toolbox>
    </af:panelGroupLayout>
    </af:panelGroupLayout>
    </code>
    Here is the CSS code
    <code>
    #topLinkToolBar af|commandToolbarButton {
    background-image: none;
    background-color: transparent;
    border: 0;
    </code>
    That WILL NOT get rid of the background images on the buttons! However if I do the !important hack within the CSS like this:
    <code>
    #topLinkToolBar af|commandToolbarButton {
    background-image: none!important;
    background-color: transparent!important;
    border: 0!important;
    </code>
    Then BOOM it works... I do NOT want to use the !important hack since that will cause problems in CSS inheritance and cascading...
    What am I doing wrong?
    Also how do I (if possible) target a specific ID used? For example the af:toolbar has an ID of "topLinkToolBar" how can I target that within the CSS? I know I can target it via class attribute like this:
    <code>
    af:toolbar.topLinkToolBar
    </code>
    but how would I do the same if I wanted to only apply to a component with a particular ID?
    Thank you everyone for all your patience, suggestions and help with this... I'm totally new to this type of environment and it's been a slow and frustrating learning experience!
    Michael

  • How to link an image to a button in Flash Builder 4

    I am new to Flash Builder 4 and have trouble to link an image to a button in Flash Builder 4.
    For example, I want an image of a round green button to replace the default retangle button in Flash Builder 4.
    Can anyone help me up?
    Thanks

    You could also use the mx:Image control and just add a click event handler:
    function(){return A.apply(null,[this].concat($A(arguments)))}
    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
            xmlns:s="library://ns.adobe.com/flex/spark"
            xmlns:mx="library://ns.adobe.com/flex/mx"
            width="500" height="400">
        <fx:Script>
            <![CDATA[
                import mx.controls.Alert;
                protected function image1_clickHandler(evt:MouseEvent):void {
                    Alert.show("You clicked the image");
            ]]>
        </fx:Script>
        <mx:Image source="http://helpexamples.com/flash/images/image1.jpg"
                click="image1_clickHandler(event);" />
    </s:Application>

  • Anchored images outside of button frame

    Hi Experts
    I am trying to find a way of getting an image to become visible on rollover on a button I've created, without having the image positioned within the button frame. The images are large & I have several small buttons on the page, each linked to text frames with anchored text objects (the images.) Anchoring the images outside the text frame is no problem, but visibility is limited to the button frame.How do I link large images to small buttons that only activate on rollover? Any ideas? PLEASE help!

    Convert that image you want to appear to separate button, and attach show/hide buttons action to your real button. Use rollover as trigger for showing your image, and rollout for hiding it again....

  • t:inputcalendar i want an image instead of button?

    Hi
    i am using tomhawak inputdate and inputcalendar in my appliation. i want to use an image insated of button.
    Please some one let me know how can we do that
    thansk in advnace
    sreedevi.

    Hi,
    i have tried the following tag image is displaying on the button.
    <t:inputCalendar id="dtTo" value="#{selectPlan.timeFrame.endingDate}" renderAsPopup="true" size="14" popupDateFormat="yyyy Week w" readonly="true" required="true" onclick="validateTimeFrameDate()" renderPopupButtonAsImage="true" popupButtonImageUrl="images/calendar.gif" />
    Thanks,
    N.Kishore

  • Is there a way to add images , text and button in the individual marquee of a carousel

    Is there a way to add images , text and button in the individual marquee of a carousel ?

    Write a custom carousel.  Usually carousel components are just ULs that use something like jQuery to rotate through the LIs.  The foundation carousel component is really just designed for some specific use cases.  Generally I would just recommend rolling your own.

  • Images inside pop-ups not displaying correctly

    I am generating a CHM using RoboHelp 10. I have certain pop-ups in some topics. These pop-ups contain screen shots. After generating the CHM, when I click the pop-ups to view the screen shots, they are not displayed correctly. That is, half of the image does not appear and there are no horizontal scroll bars either to scroll. This happens for pop-ups that are appear on the left side of a topic.The images inside pop-ups that appear to the right side of a topic appear fine when clicked.

    Hi Rick,
    Thank you for the response. Alas, updating the DHTML effects doesn't help. In the project that am working, I have used hyperlinks that are marked to be displayed as auto-sizing pop-ups.
    I also tried editing the eHlpDhtm.js file as mentioned in the thread here, https://forums.adobe.com/thread/1297423#expires_in=86399993&token_type=bearer&access_token =eyJhbGciOiJSUzI1NiIsIng1dSI6I…. But that was of no avail either.
    Do you have any other insights here?
    Regards,
    Anamika
    P.S. Am using RH 10.0.1.292.

  • Images inside pop-ups in CHM not displaying correctly

    I am generating a CHM using RoboHelp 10 on a Windows XP machine.
    I have a few pop-ups in some topics. These pop-ups contain screen shots. After generating the CHM, when I click the pop-ups to view the screen shots, they are not displayed correctly. That is, half of the image does not appear and there are no horizontal scroll bars either to scroll. This happens for pop-ups that appear on the left side of a topic. The images inside pop-ups that appear to the right side of a topic appear fine when clicked.
    The help file was originally created using RH 7. I upgraded the source files to RH 10 successfully and there were no errors during the upgradation.
    I even tried generating the CHM on other systems with RH10 and the same system configuration as mine but ended up with the same results. I assume there is some compatibility issue maybe between RH 7 and RH10.
    Looking forward to any helpful insights here as this is pretty urgent at the moment for me to resolve the aforementioned issue at the earliest.

    Hi Rick,
    Thank you for the response. Alas, updating the DHTML effects doesn't help. In the project that am working, I have used hyperlinks that are marked to be displayed as auto-sizing pop-ups.
    I also tried editing the eHlpDhtm.js file as mentioned in the thread here, https://forums.adobe.com/thread/1297423#expires_in=86399993&token_type=bearer&access_token =eyJhbGciOiJSUzI1NiIsIng1dSI6I…. But that was of no avail either.
    Do you have any other insights here?
    Regards,
    Anamika
    P.S. Am using RH 10.0.1.292.

Maybe you are looking for

  • Index on Key

    Hi There, I'm trying to add an index using a KeyExtractor which is use in a filter. It appears to be complaining that there is no method on the entry. A filter using the and EqualsFilter(KeyExtractor()) works fine. I'm guessing it's complaining becau

  • How do I change screen name for AppStore??

    I'm really confused. I have disabled ping on my iPod, and when I try editing my account under iTunes/AppStore it won't let me change my nickname, only my email. This is my 2nd account, and when I try posting a review It just says "This nickname is ta

  • How to catch XML Publisher bursted file from Workflow

    Hello, I have to catch xml publisher bursted file in oracle workflow and send it as the content of mail (not like attachment). Does anyone know if this is possible and how can I do it? Any help is appreciated, thanks in advance! Regards Ive

  • Unable to install the Netbeans 4.1 Mobility Pack

    Hi, I have Netbeans 4.1 installed on my machine and I have just installed Java Studio Enterprise 8 so that I can compare them. I have been trying to install the Netbeans 4.1 Mobility Pack into the Java Studio Enterprise 8 IDE as described on the webs

  • BADI user exit at me51n or me21n

    Hi, i need badis or user exit while creating Purchase order requisition(me51n) or purchase order purchase order(me21n). What i am trying to do is that the cost center should be provided while the user enters other data. And the cost center will be co