Code behind JFrame.setIconImage(Image img)

I'm looking for some code that will allow me to use a gif/png as an icon for native components. In other words, I want to transform a gif/png to some format (propably ico/bmp) that I can use as Icon data in native code.
When you change the icon of a JFrame, you can use the setIconImage() method. The code behind this method should just about do what I need, but I can't find any sources for it. Does anybody know where to get information about this code, or does anyone have a better idea?
Thanks!
ps. Another option would be to use the JAI package, but that contains WAY more than I need and I don't want a 5MB library to go with my 75KB program.

You can use gif or jpg to load images with java. So if you have an icon as a gif image, you just load that image and apply it to setIconImage. You can use new ImageIcon("filename.gif").getImage().
I don't know is png is supported by 1.4 or if it will be supported later. ico is not supported (I don't know about JAI).
The setIconImage is in java.awt.Frame, and doesnt do much other than keeping a reference to the icon image. I guess there is some native code that will call getIconImage to paint that icon on the title bar.
Anyway, the easiest way is to use a gif or jpg image for an icon.
PS. The source code for the java and javax classes is in a file called src.jar (shipped with jdk). You can unpack it with jar or winzip.

Similar Messages

  • How do I add an image next to a hyperlink in code behind?

    I am trying to dynamically display hyperlinks in a div, and I am also trying to add an image to appear right next to each hyperlink. My code is able to add the hyperlinks to the div's but I can't figure out how to add an image to appear next to each hyperlink.
    I am not pretty good at doing this in the code behind, which is what the requirements demand. Can anyone please point me in the right direction? I am basically trying to add an image right next to each hyperlink as they are dynamically created. Here is what
    my code looks like...
    using (SPSite site = new SPSite(siteUrl))
    List<string> output = new List<string>();
    SPWeb web = site.RootWeb;
    SPList list = web.Lists["Applications"];
    SPQuery testQuery = new SPQuery();
    testQuery.Query = "<Where><Eq><FieldRef Name='Title'/><Value Type='Text'>" + MyEditorPartChoice + "</Value></Eq></Where>";
    foreach (SPListItem item in list.GetItems(testQuery))
    DynLink = new HyperLink();
    dynDiv = new HtmlGenericControl("DIV");
    lbl = new Label();
    environment = Convert.ToString(item["Environment"]);
    appUrl = Convert.ToString(item["App URL"]);
    lbl.Text = "<br>";
    dynDiv.ID = "dynDivCode";
    dynDiv.Style.Add(HtmlTextWriterStyle.Height, "40px");
    dynDiv.Style.Add(HtmlTextWriterStyle.Width, "100%");
    dynDiv.InnerHtml = environment;
    DynLink.NavigateUrl = appUrl;
    DynLink.Text = dynDiv.InnerHtml;
    DynLink.Visible = true;
    Controls.Add(DynLink);
    Controls.Add(lbl);
    I really appreciate the help

    I figured it out...just did this.
    Image img = new Image();
    img.ImageUrl = ;//ImgUrl;
    img.Style.Add("Position", "absolute");
    Hope that helps someone else who is wanting to do this for the first time.

  • JFrame background image

    Hi all , i need to put a background image into a JFrame, currently i am seeting a label with an icon and adding it to the jframe but it pusshes all my other components across. how do i get it to be displayed behind the other components?
    final JFrame frame = new JFrame("Bank Accounts");
             frame.setSize(425,203);
             final Container container = frame.getContentPane();
         a = new javax.swing.JLabel();
         a.setIcon(new javax.swing.ImageIcon("spacePic.jpg"));
      frame.add(a);
    a.setOpaque(true);
             GridBagLayout gblMain = new GridBagLayout(); // Create the layout
             container.setLayout(gblMain);// Set layout on container
              GridBagLayout gblRight = new GridBagLayout();
                  JPanel aPanel2 = new JPanel(gblRight);

    sorry here is a better display if the code
    final JFrame frame = new JFrame("Bank Accounts");
             frame.setSize(425,203);
             final Container container = frame.getContentPane();
         a = new javax.swing.JLabel();
         a.setIcon(new javax.swing.ImageIcon("spacePic.jpg"));
            frame.add(a);
           a.setOpaque(true);
             GridBagLayout gblMain = new GridBagLayout(); // Create the layout
             container.setLayout(gblMain);// Set layout on container
         GridBagLayout gblRight = new GridBagLayout();
             JPanel aPanel2 = new JPanel(gblRight);

  • Embedding code behind a site created in muse to trigger a desired effect

    I built another great site using Muse but the client wants to use a third party processing application that requires I:
    1.) embed script (not a url) in the body section of the html (not the head),
    Instead of placing the code in the <body><body> section (which I do not know how to access in muse), I tried placing the code in the head section available via the "Page Properties" metadata field -- and it does work. However. now I need to create a custom button to trigger this effect.
    2.) I want to use a custom button but the client wants the button to blink between to colors. The third party vendor provided a code that would trigger the action of the first code but I need to find a way to make this all work.
    First, I created the blinking effect by using a blank slideshow and placed a .png version of a button I created in ai in the fist position followed by a button also created in .png with the alternate color on top. I Then set the "Fade" speed to the minimum of .06 seconds. This method did provide the desired effect, but now how do I make it clickable?
    I tried using the "Rectangle Tool" to place an empty, sans stroke div over the blinking button that I created with the idea that I would copy the designated action code into the html by way of the "Object" > "Insert HTML" but instead of placing the code behind the empty rectangle div, it creates it's own link with a "?" mark image. As a test I placed the unwanted "?" on top of the blinking button and previewed the page in the browser and it works causing the intended trigger effect when clicked. Also note that placing the element over the rotating slideshow did not obstruct the blinking effect.
    The only problem is that I don't want to show this "?" that the "Insert HTML" path created, I need to show the blinking "Order Now" button that the client asked for.
    Can anyone help?

    Hi,
    take a look o this thread, Can I use a php script in muse?
    if you still have any question, please let us know

  • Can't export in code behind

    Post Author: glauzier
    CA Forum: Exporting
    Hi,
    I have a web application in VB.NET that generates reports and export them in pdf or excel in code-behind...
    The application runs well and someday, I get this error:
    ParameterFieldCurrentValueException was unhandled by user code
    "Exception de HRESULT : 0x8004101A"
    On the line, reportdocument.Export()
    <code>
    With RemplirDataSet() 'Function rturning an object of type report document
    .ExportOptions.ExportDestinationType = _
    CrystalDecisions.Shared.ExportDestinationType.DiskFile
    .ExportOptions.ExportFormatType = _
    CrystalDecisions.Shared.ExportFormatType.PortableDocFormat
    .ExportOptions.DestinationOptions = dfdoCustomers
    .Export()
    .Close()
    .Dispose()
    End With
    </code>
    I am sure that all parameters are filled correctly.
    I run with :
    VisualStudio 2005
    Crystal Report for Visual Studio 2005 10.2.3600.0
    Do I need to install a service pack? which one? others suggestions?
    Thanks

    Holy cow, I got the export to work -- I have no idea what I did or if this works for anyone, but retracing my steps....
    -I deleted all photos that were in the trash both in iPhoto and in the Finder
    -Just for the heck of it, I tried some of the other exporting options to see how they work. (I'm a relatively infrequent user of iPhoo, hence my still working with version 2.0.1) I exported a few photos to see how the quicktime slideshow works...then I exported for web viewing. Both worked fine. Then I exported the photos...fullsize images...original format...use filename...use extention....and it worked!
    It was almost as if doing the other exports somehow fixed the issue in the finder where I kept getting the duplicate photo message which forced me to try the drag and drop method which also didn't work (see above posts).
    One downside: The export does not preserve the original dates fo import from my camera....bummer....I really like the chronological way iPhoto lets me view my photos...without that, in my newly created "iPhoto export" folder I have to do lots of guessing as to when particular pictures were taken.
    Again, *your mileage may vary* -- I have no idea what (if any) effect the above had for me. But maybe this will help someone...somewhere.
      Mac OS X (10.3.9)  

  • AdvancedDataGrid ItemRenderer Issue using code behind method

    I have been trying to get an itemrenderer to correctly work in an advanveddatagrid. I've used several itemrenderers in the past so this is pretty basic. I haven't however tried to attach to a grid that is inside a page using the code behind method. My issue is that the grid breaks if I try to put more than one visual component on the renderer. See the images below:
    Here is an example with a plain canvas itemrenderer:
    As you can see the scroll bar appears and everything looks normal.
    Here is the behavior if I add a label inside this component:
    The scroll bar disappears and I'm unable to close the itemrenderer correctly.
    Has anyone come across this issue before? Thanks for any help on this one!

    I can't post all of the code since it's on a much larger page but hopefully this gives you an idea:
    <custom:ClientPlans xmlns:mx="http://www.adobe.com/2006/mxml" width="920" height="550" xmlns:flexlib="http://code.google.com/p/flexlib/"
            fontFamily="HelveticaNeue Condensed" fontSize="11"
            xmlns:components="components.*"
            disabledColor="#FFFFFF"
            themeColor="#FFFFFF"
            horizontalScrollPolicy="off"
            verticalScrollPolicy="off" 
            backgroundColor="#ffffff"
            cornerRadius="10"
            borderStyle="solid"
            borderThickness="0"
            horizontalCenter="0" verticalCenter="0" color="#808080">
    <mx:AdvancedDataGrid id="adgPlans" width="100%" height="497" selectionMode="singleRow" editable="false"
                            color="#000000" fontSize="14" selectable="true"
                            liveScrolling="false"
                            showHeaders="false" variableRowHeight="true"
                            disclosureOpenIcon="@Embed(source='/images/gridMinus.png')"
                            disclosureClosedIcon="@Embed(source='/images/gridPlus.png')"
                            folderOpenIcon="@Embed(source='/images/folderOpenIcon.png')"
                            folderClosedIcon="@Embed(source='/images/folderclosedIcon.png')" borderThickness="1" borderStyle="solid">
                              <mx:dataProvider>
                                     <mx:GroupingCollection id="gcGroup">
                                            <mx:grouping>
                                                <mx:Grouping>
                                                    <mx:GroupingField name="ClientName"/>
                                                </mx:Grouping>
                                            </mx:grouping>
                                     </mx:GroupingCollection>
                              </mx:dataProvider>       
                            <mx:columns>
                                <mx:AdvancedDataGridColumn id="clientNameColumn" dataField="clientName" headerText="Client" sortable="true" width="200" />
                            </mx:columns>
                            <mx:rendererProviders>
                                <mx:AdvancedDataGridRendererProvider
                                    column="{clientNameColumn}"
                                    columnSpan="0"
                                    depth="2"
                                    renderer="components.subcomponents.clientRenderer3"/>
                            </mx:rendererProviders>
                        </mx:AdvancedDataGrid>
    </custom:ClientPlans>
    Code-Behind:
    // ActionScript file
    package com.name
            import mx.controls.AdvancedDataGrid;
        public class ClientPlans extends Canvas
            public var adgPlans:AdvancedDataGrid;
         public function ClientPlans ()
                super();
                this.addEventListener(FlexEvent.CREATION_COMPLETE, creationCompleteHandler);
            private function creationCompleteHandler (event:FlexEvent):void
                  trace("cc");
    Item Renderer:
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
        width="100%" height="150" borderStyle="solid" borderThickness="2" borderColor="#56ACD1" cornerRadius="8"
        fontFamily="HelveticaNeue Condensed" color="#000000" backgroundColor="#FFFFFF" backgroundAlpha="1.0">
        <mx:Label text="Hello!?"/>
    </mx:Canvas>

  • DW CS5 -wrong path shown in code after using'Insert/Image'.

    Normal site management as follows:
    Site Name is set up, eg. - abcd.
    Local Folder is set as root - c:/abcd
    Logo image is in c:/abcd/images
    Using ‘Insert/ Image’ Dreamweaver enters the correct image in the correct div, but the source code reads:
    <div id="logo"><img src="../../../../abcd/images/logo.jpg" width="248" height="78" alt="abcd" /></div>
    instead of:     <div id="logo"><img src="/images/logo.jpg" alt="abcd" /></div>
    So the path for the image seems to be defaulting incorrectly and I can see the url in the ‘select image source’ window is automatically showing a longer path: ../../../../abcd/images/
    Ideas tried so far: 
    Replaced the url manually to the local path (works fine), but it defaults again next time to the longer path.
    Tried recreating the site cache and FAQ corrupt cache fix.
    Removed the site and set it all up again.
    Manually change the path in the code and DW no longer finds the image.
    I’m a newbie who has only created a handful of sites so any ideas are very much appreciated – thanks, Shelly J

    Hi Murray,
    Thanks very much for the reply - as a first time forum user it is great to see there are friendly people out there.
    Site name abcd and Local Site Folder showed  C:\abcd\  as per normal (not using root relative) and in advanced settings links are relative to document, not site root, but you gave me a great lead and the problem seems to be resolved now, thanks. With my workflow I manually transfer the completed files to another drive (rather than the DW remote function) where a developer then adds value and ftp's them up and it seems that there was some glitch between the server and my PC. I had already tried resetting my PC earlier, but he has reset his end now and my DW is no longer confused. So thanks again. (perhaps simply hardware but I suspect the 'include' that was added to my last site's code - who knows ha ha..) Cheers, Shelly.   

  • Slide Show using code behind

    Hi,
    How can i get pictures list from some library using web part code behind?
    Lazar
    Zarla

    The default picture web part only supportes the picture size that are
    stored in the library. You need to write your own custom web part to embed the images in a larger size. You might do some tricks using CSS or Javascript to strech the
    images but then your images will look blurry.
    http://social.technet.microsoft.com/Forums/sharepoint/en-US/537501eb-0c39-440a-b26b-78fb48092e5f/sharepoint-foundation-2010-picture-library-slideshow-webpart-fit-to-webpart?forum=sharepointgeneralprevious

  • How to set the icon for the entire application with JFrame.setIconImage

    I set the icon on the main frame using JFrame.setIconImage(). The icon is shown properly in the main frame.
    If more JFrames are opened from the main frame, the newly opened JFrames also show the icon.
    However if JDialogs are opended, in some cases the icon set on the main frame is shown and in other cases the coffee cup.
    What is JFrame.setIconImage() expected to do? Setting the icon for a single JFrame or the entire application?
    How can I set the icon for the entire application?
    How can I set the icon for JDialogs?
    Thank you

    In order for your dialogs to use the same icon as the frame, you must parent the dialogs to the frame which has the custom icon.
    See the following thread for more information: http://forum.java.sun.com/thread.jsp?forum=57&thread=362542
    cheers,
    Greg

  • How to call a Web Api from from a Visual webpart code behind?

    Hi,
    I am trying to create a visual web part in sharepoint 2013 with data received from another Web API.
    I followed the below steps.
    1. Created a Visual Web part.
    2. In the code behind(.cs) file I wrote the following code.
     async private void GetResult()
                using (var client = new HttpClient())
                    client.BaseAddress = new Uri("http://localhost:8080/");
                    client.DefaultRequestHeaders.Accept.Clear();
                    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                    var response = await client.GetAsync("api/Tfs/OpenEnquiriesCount");
                    var content = response.Content;
    3. When I run the application, I get security exception in the line await
    client.GetAsync()
    What is the way to achieve this? How to call a web api from share point visual web part?
    Thank you in advance.

    Hi,
    Thanks for your sharing.
    Cheers,
    Jason
    Jason Guo
    TechNet Community Support

  • Customize Access Requried page with code behind attached to it in sharepoint 2010

    Hi,
    I have modified default AccessDenied page to my custom accessdenied.aspx page and put Request Access button on it and javascript client side redirection to my requestaccess (reqestaccess.aspx, reqestaccess.aspx.cs) application page.
    Here the problem is whenever i try to redirect to custom requesaccess page in _layouts it again shows me accessdenied page since user is not having access.
    I changed requrestaccess to my custom requestaccess through Powershell command (UpdateMapping - 5). I can only modify the UI part of requestaccess.aspx and can not bind code behind where i want user to select combination of what access is required
    on the site, there are lots of controls on requestaccess page e.g. dropdown that fetches data from list\external list and so on.
    I tried many things to attach code behind to requestaccess page e.g. <%@ Page Inherits="codebehind.cs" /> and all.
    Q - How can i redirect user to custom request access page (includes both aspx, aspx.cs) and allow user to interact with custom page? Is there any way OR WORKAROUND to do this in Sharepoint 2010?
    OR
    Can we overide with ElevetedPermissions in UI\CodeBehind and show the application page to user?
    OR
    Can user access application page even though they donot have rights to access site? Anything will do.
    OR
    In short, I need to redirect a user to some .aspx\.aspx.cs page from AccessDenied page, irrespective of user having access or not. 
    I hope question is clear enough to understand the issue. :)
    Regards,
    Rahul

    Hi,
    According to your post, my understanding is that you had an issue about the custom Access Required page.
    Microsoft supported using code behind, but for these pages it seemed some difference.
    However, as a workaround, we can put all the functionality to the aspx page directly.
    http://umbraes-tower.blogspot.com/2011/10/custom-request-access-page-in.html
    More reference:
    http://onlinecoder.blogspot.com/2011/05/how-to-customize-requestaccess.html
    http://oszakiewski.net/eric/customizing-the-access-request-page-in-sharepoint-2010
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • How to find out the code behind a button

    Hi,
    What technique should I use to find out what java code is invoked when I click on a button in the portal?
    More concrete: I want to know the code behind the button I'm talking about <a href="https://forums.sdn.sap.com/thread.jspa?threadID=188251">here</a>.
    T h a n k s !
    Jeroen

    I would suggest you use HTTPWatch in your browser to see what is happening behind you button click.
    You can get it here
    <a href="http://www.simtec.ltd.uk/">http://www.simtec.ltd.uk/</a>

  • Custom Master Page with Code behind in SharePoint 2013

    Hi All,
    I want to create the Custom Master Page in Sharepoint 2013 with Code file in it.
    Is it possible to create? if YES the how i can achieve it??
    PD

    To add something to Amit's reply, you can refer to the following link on how to create master page with code behind if you are new to ASP.net.
    Walkthrough: Creating and Using ASP.NET Master Pages in Visual Web Developer
    http://msdn.microsoft.com/en-us/library/ehszf8ax(v=vs.90).aspx
    Miles LI TechNet Community Support

  • Location for login.aspx code behind?

    I added a Login.aspx.cs file in the Server Project with some code in
    Page_Load() I need to implement, and edited the first line of login.aspx this way:
    <%@ Page Language="C#" CodeBehind="Login.aspx.cs" Inherits="Microsoft.LightSwitch.Security.ServerGenerated.Implementation.LogInPageBase" %>
    What I added, exactly, are the Language and CodeBehind
    properties.
    But when I deploy and run the application, I get this error:
    The type 'Microsoft.LightSwitch.Security.ServerGenerated.Implementation.LogInPageBase' is ambiguous: it could come from assembly 'C:\testing\Sandbox\bin\Microsoft.LightSwitch.Server.DLL' or from assembly 'C:\testing\Sandbox\bin\Application.Server.DLL'.
    Please specify the assembly explicitly in the type name.
    I understand this is because Login.aspx.cs already exists in some assembly.
    Is there any way to Access Login.aspx code behind?
    If not, how can I add my own login page to an HTML Client App without losing the already configured Forms security, roles, permissions, etc.?
    thanks.
    Nicolás.
    Nicolás Lope de Barrios
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to
    "Mark as Answer". This will help other people find answers to their problems more quickly.

    Josh:I tried your suggestion, edited Login.aspx like you said, and the code for Login.aspx.cs converted from vb is this:
    using System;
    using System.Collections.Generic;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.Security;
    using Microsoft.LightSwitch;
    using LightSwitchApplication;
    using LightSwitchApplication.Helpers;
    namespace LightSwitchApplication
    public partial class Login : Microsoft.LightSwitch.Security.ServerGenerated.Implementation.LogInPageBase
    protected void Page_Load(object sender, EventArgs e)
    AuditHelper.CreateAuditTrailForLogin();
    public Login()
    Load += Page_Load;
    As you can see, all I want to do is call AuditHelper.CreateAuditTrailForLogin()
    on Page_Load()
    But I'm getting this exception, wich is obvious what it means, but I don't know how to fix. Does it mean we're overriding Server generated Page_Load() so I have to write all the code that handles authentication?:
    The method or operation is not implemented.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.             
    Exception Details: System.NotImplementedException: The method or operation is not implemented.
    Source Error:
    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.                  
    Stack Trace:
    [NotImplementedException: The method or operation is not implemented.]
    LightSwitchApplication.Login.Page_Load(Object sender, EventArgs e) +36
    Microsoft.LightSwitch.Security.ServerGenerated.Implementation.LogInPageBase.OnLoad(EventArgs e) +90
    System.Web.UI.Control.LoadRecursive() +71
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3178
    Any help appreciated.
    Nicolás Lope de Barrios
    If you found this post helpful, please "Vote as Helpful". If it actually answered your question, please remember to
    "Mark as Answer". This will help other people find answers to their problems more quickly.

  • "Object Required" error when using the script block from the code behind

    I try to use the following script block on the code behind page
    <script defer='true' id='NavID' type='text/javascript'>Nav();</script>
    and the function Nav() is on the .aspx page. It gives me the "Object Required" error message. BUT if I add an alert("hello!!!") line inside of the Nav() function, it works fine after the user closes the alert box. Has anyone experienced a similar problem? Please help. Thanks.

    There is no way to troubleshoot this by looking at a picture of the diagram. LabVIEW 6 is almost prehistory and many things have changed, especially the file IO all looks different so it is impossible to tell what you are doing.
    Error 7 is file not found, so most likely your string operations are not correct. What are the full strings? What is the final file name (maybe you are missing a "\" or maybe you are on a different OS type). Put an indicator at the path wire to see what's happening!
    Is this a datalog file?
    (Overall, the code is a bit suspect. Nobody needs a seven frame flat sequence. ) Why do a control and an indicator have the same label?)
    LabVIEW Champion . Do more with less code and in less time .

Maybe you are looking for

  • How can I find and correct corrupt Catalog files on Elements 9?

    I was trying to create a simple slideshow with sound when first my computer warned of low memory (something that doesn't seem plausible), and then Photoshop Elements 9 and the associated organizer crashed. When I brought it back, several photos were

  • Smartview refreshes whole sheet instead of just the grid selected.

    Hello All, Is it possible to refresh just selected rows in a sheet with different member combinations instead of the whole sheet? In other words I have                    Member3  Member4 Member1           A             C Member2           B         

  • Any landscape recommendations for 2004s BI & SEM-BCS 6.0 ?

    Hi, in addition to our ERP 2005 we plan to set up a separate central BI 7.0 for following integrated NW2004s scenarios: - Enterprise wide central reporting, query and analysis. - BI Integrated Planning (successor of SEM-BPS). - SEM-BCS 6.0. <u>Questi

  • I can't use American Greetings Create and Print with Firefox 4

    When I try to use American Greetings Card Create & Print it calls for installing a plug in from Mozilla, but when I try to instal that plug in I get a window saying it is not compatible with Mozilla or Firefox 4. How can I keep Firefox and also use A

  • How Do i Make Graphs and Plots in Java

    Hi, I am a newbie to Java, and definitely brand new to the gaphics world. I have a data file, which happens to be huge ( A text file size of 10 MB). This file contains some collected data. The data is divided into the very familiar two variable forma