How to put images on buttons?

I am currently working a project and need to mount an image onto a button, so when the image is clicked on it makes the button event work?

set icons? , do i have to have the image in the same
folder as where the code is saved? I have not been
able to find any code showing how to apply images
onto buttons on a GUI.Did you atleast read reply 2 and 4?Have you ever read the JButton API?There's no necessity that the image has to be in the same folder.You use have to specify the absolute path of the image when you create an instance representing it.

Similar Messages

  • How to change a background to an image? and how to put a 'clear' button.

    Hi guys, im new here & i really newbie in java. Recently i found code for java applet that can draw a line. I want put image as a background and draw some lines over the image and provide a button to clear the lines. Is there any one can help me to solve my problem. Here is the code :
    import java.awt.*;
    import java.applet.*;
    public class DrawLines extends Applet {
        //Variables
        Point Start[] = new Point[20];   //X,Y info of start of lines
        Point End[] = new Point[20];     //X,Y info of end of lines
        Point current_start;
        Point current_point;
        int numlines= 0;
        Point boundary;   //to represent the boundary of the applet
        //Set background to yellow, register listeners
        // get boundary of applet
        public void init() {
          setBackground(Color.white);
          current_point = null;
          boundary = new Point(this.size().width,this.size().height);
        //Mouse Clicked Down...save in current_start
        public boolean mouseDown(Event e, int x, int y) {
           if(numlines < 20) {
              current_start = new Point(x,y);
              return true; }
           else
             { System.out.println("Can Not Take Any More Input Lines");
               return false; }
        //Mouse Drag....reset current_point to current position
        public boolean mouseDrag(Event e, int x, int y) {
            if(numlines <20) {
              current_point = new Point(x, y);
              repaint();  //will draw this current line
              return true;
            else
              return false;
        //Mouse Up ...save created line if can and call repaint
        //  to draw it.  Make sure the end point is inside the applet
        public boolean mouseUp(Event e, int x, int y) {
           if( (numlines < 20) && (x < boundary.x) &&
               (y < boundary.y) )
             {  Start[numlines] = current_start;
                End[numlines] = new Point(x, y);
                numlines++;
                //Reset current points to empty
                current_point = null;
                current_start = null;
                //repaint will draw all lines including this one
                // just created.
                repaint();
                return true;
           else
             return false;
        //Draw all of the lines stored in Start[], End[].
        //Draw the current line from current_start to current_point
        public void paint(Graphics g) {
             //set drawing color
             g.setColor(Color.red);
             //Draw stored lines
             for (int i=0; i<numlines; i++) {
                g.drawLine(Start.x, Start[i].y,
    End[i].x, End[i].y);
    //Draw current line if one exists
    g.setColor(Color.blue);
    if (current_point != null)
    g.drawLine(current_start.x, current_start.y,
    current_point.x, current_point.y);
    //Set numlines back to zero
    public void start() {
    numlines=0;
    //In case mouse exits the applet region...reset current points
    public boolean mouseExit(Event e, int x, int y) {
    current_point = null;
    return true; }
    and this is code in HTML
    <HTML>
    <HEAD>
    </HEAD>
    <BODY BGCOLOR="Grey">
    <CENTER>
    <APPLET
         code     = "DrawLines.class"
         width     = "500"
         height     = "500"
         >
    </APPLET>
    </CENTER>
    </BODY>
    </HTML>
    Thanks & appreciate for the help.

    Hey thanks, but i find another way by looking other ppl code for image back ground. And its working! but i still dont know how to create the button (im so very noob in java sigh)
    The link u gave to me is very good but its hard for very newbie like me to understand. I just change the code like this :
    Using offscreen image
    Image off, back;      //to represent background image
         Graphics offG;          //to represent offscreen image                          
        public void init() {
         off = createImage(getSize().width, getSize().height);      // create your offscreeen image
         offG = off.getGraphics();
         back = getImage(getDocumentBase(),"images/Area.jpg");     // load your background image
        current_point = null;
        boundary = new Point(this.size().width,this.size().height);
    // Draw all of the lines stored in Start[], End[].
        // Draw the current line from current_start to current_point
        public void paint(Graphics g) {
              offG.drawImage(back, 0, 0, this);      // draw everything to your off screen first
              g.drawImage(off, 0,0, this);          // copy your off screen to on screen now
            g.setColor(Color.red);                    // set drawing color
            //Draw stored lines
            for (int i=0; i<numlines; i++) {
                g.drawLine(Start.x, Start[i].y,
    End[i].x, End[i].y);
    //Draw current line if one exists
    g.setColor(Color.blue);
         if (current_point != null)
    g.drawLine(current_start.x, current_start.y,
    current_point.x, current_point.y);
    Now my problem is the 'clear' button, i really dun know how to make button which is can clear the lines. Any one have idea?

  • How could i put image in button bar

    import events.ToolbarEvent;
    import mx.events.FlexEvent;
    import mx.events.ItemClickEvent;
    import mx.events.SliderEvent;
    import mx.core.*;
    import spark.skins.spark.ImageSkin;
    import ui.presenters.MainPresentationModel;
                [Bindable]
                public var fileButtons:Array = [{label:"Open"},{label:"Save"}];
                [Bindable]
                public var navButtons:Array =
                    {label:"Adjust",state:MainPresentationModel.ADJUST_STATE},
                    {label:"Touchup",state:MainPresentationModel.TOUCHUP_STATE},
                    {label:"Effects",state:MainPresentationModel.EFFECT_STATE}
                [Bindable]
                public var historyButtons:Array = [{label:"Undo"},{label:"Redo"}];
                private function handleFileClick(e:ItemClickEvent):void
                    if (e.label == "Open")
                        dispatchEvent(new ToolbarEvent(ToolbarEvent.OPEN));
                    else if (e.label == "Save")
                        dispatchEvent(new ToolbarEvent(ToolbarEvent.SAVE));
                private function handleNavClick(e:ItemClickEvent):void
                    callLater(handleNavigation,[e.item.state]);
                private function handleNavigation(state:String):void
                    if (navBar.selectedIndex == -1)
                        dispatchEvent(new ToolbarEvent(ToolbarEvent.SHOW));
                    else
                        dispatchEvent(new ToolbarEvent(ToolbarEvent.SHOW,true,false,state));
                private function handleHistoryClick(e:ItemClickEvent):void
                    if (e.label == "Undo")
                        dispatchEvent(new ToolbarEvent(ToolbarEvent.UNDO));
                    else if (e.label == "Redo")
                        dispatchEvent(new ToolbarEvent(ToolbarEvent.REDO));
                private function handleZoomChange(e:SliderEvent):void
                    dispatchEvent(new ToolbarEvent(ToolbarEvent.ZOOM, true, false, null, e.value));
            ]]>
        </mx:Script>
        <mx:ButtonBar dataProvider="{fileButtons}" itemClick="handleFileClick(event)"   />
        <mx:ToggleButtonBar id="navBar" dataProvider="{navButtons}" toggleOnClick="true"
            creationComplete="event.target.selectedIndex=-1" itemClick="handleNavClick(event)"/>
        <mx:Button label="Show Source" click="dispatchEvent(new ToolbarEvent(ToolbarEvent.SRC))"  />
        <mx:Spacer width="100%" />
        <mx:ButtonBar dataProvider="{historyButtons}" itemClick="handleHistoryClick(event)"  />
        <mx:HSlider value="1.0" minimum="0.1" maximum="3.0" snapInterval="0.1" liveDragging="true" change="handleZoomChange(event)" />
    </mx:HBox>
    using this code what shoud i do to add image on button bar

    I would extend the button bar and in create children I will add the image.

  • How to set images as buttons?

    Hi,
    I am trying to create a GUI in which each frame/panel has few buttons.I am able to put an icon in the button.Now please can u tell me how one can set an image as button?I am using netbeans to do the above.
    Thanku..

    tara_730 wrote:
    I am able to put an icon in the button.
    can u tell me how one can set an image as button?Does not compute. An Icon is an image, so if you can put one on a button, you're done. What are you trying to do, and what have you managed to accomplish, in detail.

  • PUT IMAGE ON BUTTON BAR

    How could i put image on Buttonbar for all different buttons on it can u please help me thNK YOU

    answered in your other post...

  • How to put a back button

    hi all
    i'm using jdev 10g 10.1.3. i'm tring to put a back button in my pages that when i click on it will go back to the page from which it came but am getting lost how to go about it.
    I created a backing bean with the following code for the Action property:
    import javax.faces.context.FacesContext;
    public class BackButtonBean {
    private String url;
    public BackButtonBean() {
    public void setUrl(String url) {
    this.url = url;
    public String getUrl() {
    return url;
    public String backButton_action() {
    FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get(url);
    return url;
    Can someone help me out what to do next?
    thanks
    preeti

    Hi,
    if you use JSF then you can navigate back by setting the previous ViewId to the UIViewRoot you access from FacesContext.getViewRoot(). So all you really need to do is to track the ViewId of the previous page
    Frank

  • How to put a push button in the top of page of ALV

    Hi at all,
    I need to put a push button in TOP OF PAGE .
    My code is below and i'd like to put a push button to do something.
    FORM top_of_page USING r_ddoc TYPE REF TO cl_dd_document.
      DATA: text TYPE sdydo_text_element.
      DATA: text_table TYPE sdydo_text_table.
      CALL METHOD r_ddoc->initialize_document.
    Title
      text = text-301.
      CALL METHOD r_ddoc->add_text
        EXPORTING
          text          = text
          sap_style     = 'HEADING'.
      CLEAR text.
    endform.
    Thanks at all.
    ENDFORM.

    Hi Domenico,
    For pushbuttons on Dynamic Documents please refer to this link:
    http://help.sap.com/saphelp_nw70/helpdata/EN/b6/ab3a7503ac11d4a73f0000e83dd863/frameset.htm
    Regards
    Marcin

  • How to put images on graph?

    Hello,
    I want to put images on graph whereever I want.
    I have TDMS file like this.
    My "x Axis" is (km) and "y axis" is MKTY.  If MKTY is 3 I want to put image3 on graph places in the y-axis. If MKTY is 2 then I put "image2" on graph.
    I uploaded my TDR file.
    Yasemin Barutçu
    Electrical And Electronics Engineer
    Attachments:
    graph.zip ‏5 KB

    For me, not. But yes I have to do this. Maybe I manual have a table which includes the y axis coordinates. X axis is dicrete then when I get the value 2 I will look at its y axis and take the coordinates of the y-axis corresponds to the table
    Is it difficult? 
    Yasemin Barutçu
    Electrical And Electronics Engineer

  • How to put icon in buttons in 9ids

    pl let me know how i can make a button with icon in 9ids. i mean a push button with icon on it. thanks.

    pl let me know how i can make a button with icon in 9ids. i mean a push button with icon on it. thanks.

  • Please tell me how to put Image on MDI window

    Brothers i am new in swings please help me in this matter that i want to put image an image on JdesktopPane in swings please give me some code or guide me in this matter. thanks in advance.

    public class MDIDesktopPane extends JDesktopPane {
    private ImageIcon DesktopImage;
    public MDIDesktopPane() {
    DesktopImage=new ImageIcon(new java.net.URL("http://80.96.36.11:8080/hq/RBMS.jpg"));
    public void paint(java.awt.Graphics g)
    Rectangle r = g.getClipBounds();
    Color c = getBackground();
    if(c == null)
    c = Color.black;
    g.setColor(c);
    g.fillRect(r.x, r.y, r.width, r.height);
    g.drawImage(DesktopImage.getImage(),this.getWidth()/2-DesktopImage.getIconWidth()/2,this.getHeight()/2-DesktopImage.getIconHeight()/2,c,null);
    super.paint(g);

  • How to create image swap buttons

    I'm not sure where to post this question, but it involves
    images and was wondering if Fw is the place to start.
    I want to create a retro car radio navigation for a web site.
    Old push-button radios usually had an indicator that travelled
    behind the numbers on the dial when you turned the tuner knob.
    Then, you could set a button to go to a specific station on the
    dial. My web site navigation uses an image of the radio on an old
    dashboard. When the buttons are clicked, the click state shows the
    button pushed in and the indicator shows above the pushed button on
    the dial when the user is sent to that web page. The button remains
    in its "pushed" state until another button is pushed, at which
    click the previous button returns to its "out" state and the second
    button clicked goes to the new page and shows its "pushed" state.
    And so on.
    I supposed there are multiple options to do this, but I'd
    like your recommendations on the fastest. I don't know javascript
    but I used to use ImageReady to do this and ImageReady would create
    the script in the generated html. Will Fw do this? Or is there some
    better way?
    Thanks,
    Jack

    Yes, Fireworks will make menu bars, but there is a better
    way. It is much better to use Dreamweaver or another Web
    development tool, instead of a graphics application. Fireworks HTML
    is recommended for mockups and prototypes. The code it produces is
    fragile, very ugly and does not lend itself to future maintenance.
    Use Fireworks to create your images, then use Dreamweaver or
    similar to put together a robust and maintainable navigation menu.

  • How to put Images at runtime in Adobe form.

    Hi All,
    I have a simple query but got confused finding a note related to this, so need your suggestion to address this issue.
    We developed several Adobe Non interactive forms using ADLC 8.2.3 in CRM 7.0 ADS 7.0 Adobe reader 10.X.
    The forms have multiple master pages with embedded images, the form increases to multiple pages based on the data.
    The form is not heavy but to increase performance we thought of putting the images in MIME repository and fetch them at runtime.
    while searching for this we found SAP Note: 0001249492 which says due to improved security features dynamic images are not supported from Adobe Reader 8.1 on wards and the images are to be embeded at design time.
    This note is published in 2009 Can somebody confim me if this is still applicable and we sud go with design time images only.
    If we can still use runtime images please give me some steps or document how to acheive this.
    Thanks in Advice for your help,
    Regards,
    Sai Krishna.

    They'll help you over here.
    Microsoft C# ASP.Net forum
    Regards, Dave Patrick ....
    Microsoft Certified Professional
    Microsoft MVP [Windows]
    Disclaimer: This posting is provided "AS IS" with no warranties or guarantees , and confers no rights.

  • How to put image in table selection column in advanced table

    i need to put some image(not a picture, its just a traingalur shape image with different colour which indicates some messages to the user if suppose user adds a data which is duplicate with other row or he may copy existing row and dont change it.) can any one give me an idea of how to achieve this

    Are you looking for image in selection column or as a separate column?
    --Shiv                                                                                                                                                                               

  • How to put image files on fs directory instead of in DB?

    Hi,
    Currently I have logo image file (ie: logo.jpg) in DB. But I want to put it in file system directory for performance reason. So I
    1) put logo.jpg file in BOTH $ORALCE_HOME/apex/images AND $ORACLE_HOME/apex3.2/Apex3.2Download/apex/images (since I did an upgrade to 3.2 and unsure which ApEx location it's exactly).
    2) changed Shared Components -> Application Definition -> Logo -> FROM #WORKSPACE_IMAGES#logo.jpg TO /i/logo.jpg
    And yes, /i/ is defined as an image prefix.
    However, the logo does NOT show up.
    Any idea?
    Thanks much,
    Helen

    First, how are you accessing APEX? Via Embedded Gateway or HTTP Server?
    When put the logo file into the "images" directory, did you do this on the Database Server, or Application Server?
    - If Embedded Gateway, the only way that files are served is through the APEX interface, unless you explicitly path them from a different web server (same host is fine, but different port obviously). It's via Embedded Gateway in 11g db. Currently the image is loaded into database, but I want to change to filesystem.
    So I
    1) put logo.jpg file in BOTH $ORALCE_HOME/apex/images AND $ORACLE_HOME/apex3.2/Apex3.2Download/apex/images (since I did an upgrade to 3.2 and unsure which ApEx location it's exactly).
    2) changed Shared Components -> Application Definition -> Logo -> FROM #WORKSPACE_IMAGES#logo.jpg TO /i/logo.jpg
    And yes, /i/ is defined as an image prefix.
    However, the logo does NOT show up.
    Any suggestions/ideas?
    Thanks,
    Helen

  • How to put image in tooltip?

    I know that to create a tooltip I would put the following code into the HTML Form Element Attributes property of a page item.
    onmouseover="toolTip_enable(event,this,'my tooltip text');"
    But, how do I get an image in the tooltip?
    Thanks,
    Maggie

    Hi,
    What is your Apex version?
    Regards,
    Jari

Maybe you are looking for

  • HOW TO RESTORE A DISABLED PHONE

    i recently locked my iphone and forgot password. I have disabled my phone and am away from home and can only access itunes from a different computer. Does anyone know how to restore iphone 4 from a new computer? When i plug in it gives me error messa

  • Customozing Oracle Discoverer Security

    Hi, Please help me in following scenario. I am having security service as web service which maintain all tokens about users. When any user from a system try to connect to disoverer it should use this token id and send to discoverer. And the Discovere

  • Imp Changes are needed in Nokia Belle

    I am using Nokia E7 since last 10 months. Symbian Anna and Belle are released in between. I have seen lot of differences between Anna and Belle. The following differences are also compared with normal phones also. Here I have mainly focused on issues

  • Invisible Selection Screen(Low and High) accordingly through radio-button

    Dear Experts,                      Currently I've faced some problem regarding selection-screen.Our user want that when he click P1(say) radio-button, then selection-screen "s1-high " is invisible and when he click P2(say) radio-button that time "s1-

  • How do transfer from iPad one to iPad three

    Was wanting to know how u transfer from iPad one to iPad three