Help please with a Static Initializer for ImageIcons inside Jar Files

At the moment I'm playing around displaying XML using A JTree
I am subclassing DefaultMutableTreeNode, and want it to have some default Icons set up....
Sort of like this:
public class XNode extends DefaultMutableTreeNode
    public static final ImageIcon icon;
   public static ImageIcon getIcon()
        return XNode.icon;
}The only thing is that for the life of me after trying various things and searching these forums and google:
I can't work out how to write the static Initializer for the ImageIcon.
The ImageIcon will need to be created using a URL, cos it will be inside my jar file.....
the usual...
           URL url = this.getClass().getResource("/images/Exit16.gif");
           ImageIcon Icon = new ImageIcon( url );but I wanted these Icons to be class members..............
Could someone help?
}

DrClap " I don't understand why you put Class.forName in there either"
A: Because I don't really know what I'm doing.
I will try that suggestion.
At present I have this:
     static ImageIcon loadIcon;
     static
          try
            loadIcon = new ImageIcon( Class.forName("cis.editor.xml.nodes.AlNode").getResource("/images/Exit16.gif"));
          catch( ClassNotFoundException cnfe )
               System.out.println("ClassNotFound: " + cnfe.getMessage() );
     public static final ImageIcon defaultIcon = loadIcon;
     static
          try
            loadIcon = new ImageIcon( Class.forName("cis.editor.xml.nodes.AlNode").getResource("/images/tree_folder_major.gif"));
          catch( ClassNotFoundException cnfe )
               System.out.println("ClassNotFound: " + cnfe.getMessage() );
     public static final ImageIcon commentIcon = loadIcon;
//.......... ANd so OnWhy? Because do far it was the only way I could get it to compile.
And It works..
However it's a real abortion.. codewise.
I need to load about 16 Icons that the various subclasses can 'use'
DefaultTreeCellRenderer - must do somethng similar because it has a bunch of Icons to "Pick from",
Only How is that done 'properly' ?

Similar Messages

  • Help please with 2006 Macbook 13inch, for tv hook up.

    Help please with 2006 Macbook 13inch, to hook up to tv for streaming. The display works through VGA but the audio isn't working. Got a plug that goes into headphone jack on computer and connects into the audio jack on the back of tv but no sound. I'm not quite sure what the issue is, whether its the wrong plug, the tv, or the computer. Best Buy says this is the right plug and it seems that it would be, but who knows. If anyone has any experience in this, I would appreciate the help!

    Make sure those audio plugs are matched with the VGA plug. With your MacBook running something with audio switch between your sources on the TV Component, Composite and such. See if the sound is coming from another source. If so then you've got your audio plugs in the wrong jacks.
    Also could you post the make and model number of your TV.

  • Help please with capture / sequence settings for DVCAM PAL 16:9

    Simple question but I'm baffled by choices for capture/sequence using FCP6 to capture 16:9 PAL DVCAM. Have tried esay set up (not enough options) and also sequence and capture settings manually too many options ) and always seem to end up with borders top and bottom, not full viewer / canvas at correct aspect ratio. Can someone tell me correct settings. I'm baffled by inclusion of 5:4 aspect ratio and whether in the compression box under advanced settings in the sequence settings bow I should select 4:3 or 16:9 and in the seq. settings box itself whether I should check anamorphic 16:9.In audio/video settings (summary tab) there's also a question about playback settings which is set to '(missing) apple firewire pal 720x568'. What's that about. Any assistance much appreciated.

    Don't over think it. There's no reason why you should have to modify a capture preset in your situation. Use the easy setup for DV PAL 48 KHz Anamorphic (assuming your footage is anamorphic and not letterboxed). If you're seeing gray bars at the top and bottom of the canvas, hit ctrl-U to have the windows automatically adjusted to the right size. If you're seeing black bars, then your footage is probably letterboxed. You should use the regular DV PAL easy setup to capture that. If the Video Playback device is set to (missing) it's because your deck or camera is not turned on, or isn't connected to the computer.

  • Help Please with searching Hard Drive for MP3's etc

    Right I installed ITunes and in the install it said do you want ITunes to search your harddrives for MP3s to add to the library. Which I said Yes. I have all mu music on a 200gb External Hard Drive.
    WHen it finished the search I had 5 files in my library that were on my desktop.
    How do I ask ITunes to search my external harddrive for the rest of my music without importing individually??
    Many Thanks in Advance

    Just use the Add to Library command (under the File menu) and select the folder(s) on your external drive in which your music is stored.

  • Little help please with forwarding traffic to proxy server!

    hi all, little help please with this error message
    i got this when i ran my code and requested only the home page of the google at my client side !!
    GET / HTTP/1.1
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*
    Accept-Language: en-us
    UA-CPU: x86
    Accept-Encoding: gzip, deflate
    User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; InfoPath.2; .NET CLR 2.0.50727)
    Host: www.google.com
    Connection: Keep-Alive
    Cookie: PREF=ID=a21457942a93fc67:TB=2:TM=1212883502:LM=1213187620:GM=1:S=H1BYeDQt9622ONKF
    HTTP/1.0 200 OK
    Cache-Control: private, max-age=0
    Date: Fri, 20 Jun 2008 22:43:15 GMT
    Expires: -1
    Content-Type: text/html; charset=UTF-8
    Content-Encoding: gzip
    Server: gws
    Content-Length: 2649
    X-Cache: MISS from linux-e6p8
    X-Cache-Lookup: MISS from linux-e6p8:3128
    Via: 1.0
    Connection: keep-alive
    GET /8SE/11?MI=32d919696b43409cb90ec369fe7aab75&LV=3.1.0.146&AG=T14050&IS=0000&TE=1&TV=tmen-us%7Cts20080620224324%7Crf0%7Csq38%7Cwi133526%7Ceuhttp%3A%2F%2Fwww.google.com%2F HTTP/1.1
    User-Agent: MSN_SL/3.1 Microsoft-Windows/5.1
    Host: g.ceipmsn.com
    HTTP/1.0 403 Forbidden
    Server: squid/2.6.STABLE5
    Date: Sat, 21 Jun 2008 01:46:26 GMT
    Content-Type: text/html
    Content-Length: 1066
    Expires: Sat, 21 Jun 2008 01:46:26 GMT
    X-Squid-Error: ERR_ACCESS_DENIED 0
    X-Cache: MISS from linux-e6p8
    X-Cache-Lookup: NONE from linux-e6p8:3128
    Via: 1.0
    Connection: close
    java.net.SocketException: Broken pipe // this is the error message
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:92)
    at java.net.SocketOutputStream.write(SocketOutputStream.java:115)
    at java.io.DataOutputStream.writeBytes(DataOutputStream.java:259)
    at SimpleHttpHandler.run(Test77.java:61)
    at java.lang.Thread.run(Thread.java:595)
    at Test77.main(Test77.java:13)

    please could just tell me what is wrong with my code ! this is the last idea in my G.p and am havin difficulties with that cuz this is the first time dealin with java :( the purpose of my code to forward the http traffic from client to Squid server ( proxy server ) then forward the response from squid server to the clients !
    thanx a lot,
    this is my code :
    import java.io.*;
    import java.net.*;
    public class Test7 {
    public static void main(String[] args) {
    try {
    ServerSocket serverSocket = new ServerSocket(1416);
    while(true){
    System.out.println("Waiting for request");
    Socket socket = serverSocket.accept();
    new Thread(new SimpleHttpHandler(socket)).run();
    socket.close();
    catch (Exception e) {
    e.printStackTrace();
    class SimpleHttpHandler implements Runnable{
    private final static String CLRF = "\r\n";
    private Socket client;
    private DataOutputStream writer;
    private DataOutputStream writer2;
    private BufferedReader reader;
    private BufferedReader reader2;
    public SimpleHttpHandler(Socket client){
    this.client = client;
    public void run(){
    try{
    this.reader = new BufferedReader(
    new InputStreamReader(
    this.client.getInputStream()
    InetAddress ipp=InetAddress.getByName("192.168.6.29"); \\ my squid server
    System.out.println(ipp);
    StringBuffer buffer = new StringBuffer();
    Socket ss=new Socket(ipp,3128);
    this.writer= new DataOutputStream(ss.getOutputStream());
    writer.writeBytes(this.read());
    this.reader2 = new BufferedReader(
    new InputStreamReader(
    ss.getInputStream()
    this.writer2= new DataOutputStream(this.client.getOutputStream());
    writer2.writeBytes(this.read2());
    this.writer2.close();
    this.writer.close();
    this.reader.close();
    this.reader2.close();
    this.client.close();
    catch(Exception e){
    e.printStackTrace();
    private String read() throws IOException{
    String in = "";
    StringBuffer buffer = new StringBuffer();
    while(!(in = this.reader.readLine()).trim().equals("")){
    buffer.append(in + "\n");
    buffer.append(in + "\n");
    System.out.println(buffer.toString());
    return buffer.toString();
    private String read2() throws IOException{
    String in = "";
    StringBuffer buffer = new StringBuffer();
    while(!(in = this.reader2.readLine()).trim().equals("")){
    buffer.append(in + "\n");
    System.out.println(buffer.toString());
    return buffer.toString();
    Edited by: Tareq85 on Jun 20, 2008 5:22 PM

  • Hi! Can someone help me with repair service address for Palm TX?

    Hi! Can someone help me with repair service address for Palm TX?
    This question was solved.
    View Solution.

    Good luck, and please let us know here how it works out for you.  We love knowing of current resources who can help solve people's problems with these older devices.
    smkranz
    I am a volunteer, and not an HP employee.
    Palm OS ∙ webOS ∙ Android

  • Help Please with Driver

    I need to install the ADB Interface for the X2 onto my computer. Does any one know how or where I can get this driver?

    <Duplicate post.  Please see Help Please with Driver  for any replies.  This post will be closed.>

  • Help please with FaceTime. The built in app seems to have disappeared from my iPad2. Bought it in Australia

    Help please with FaceTime. My built in app seems to have disappeared.

    If K Penguin's suggestion doesnt work, you will have to go to you iTunes and do a reset, that is if you do not have it in your back up library.

  • Can anyone help me with changing email address for resetting password notification

    Can anyone help me with changing email address for resetting password notification?

    If you know the answers to your security questions, you can change your rescue email address as shown in step 6 in this article: http://support.apple.com/kb/HT5312.
    If you don't kow the answers to your security questions or need other assistance doing this, either contact Apple for assistance by going to https://expresslane.apple.com, then click More Products and Services>Apple ID>Other Apple ID Topics>Lost or forgotten Apple ID password, or contact the Apple account security team: http://support.apple.com/kb/HT5699.

  • Can anyone help please with my Time Machine, I have been getting the following message The backup disk image "/Volumes/Mac Backup/Stephen Smith's iMac.sparsebundle" is already in use.

    Can anyone help please with my Time Machine, I have been getting the following message The backup disk image “/Volumes/Mac Backup/Stephen Smith’s iMac.sparsebundle” is already in use.

    See > http://pondini.org/TM/C12.html

  • Please help me with the proper query for the below problem

    Hi,
    I have a table RATE which have two columns RT_DATE (date) and RATES(number).
    This table have following data.
    RT_DATE
    RATES
    1-JAN-2007
    7
    2-MAR-2008
    7.25
    5-JAN-2009
    8
    8-NOV-2009
    8.5
    9-JUN-2010
    9
    I wanted to get the rate of interest on 8-DEC-2009.
    Output will be 8.5 as this given date is in between 8-NOV-2009 and 9-JUN-2010. Could you please help me with proper query?
    Regards,
    Aparna S

    Hi,
    That sounds like a job for the LAST function:
    SELECT  MIN (rates) KEEP (DENSE_RANK LAST ORDER BY rt_date) AS eff_rate
    FROM    rate
    WHERE   rt_date < 1 + DATE '2009-12-08'
    MIN above means that, in case of a tie (that is, 2 or more rows with the exact same latest rt_date) the lowest rates from that latest rt_date will be returned.  In rt_date is unique, then it doesn't matter if you use MIN or MAX, but syntax demands that you use some aggregate function there.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for your sample data, and also post the results you want from that data.
    Point out where the statement above is getting the wrong results, and explain, using specific examples, how you get the right results from the given data in those places.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002#9362002

  • Need help please with a recent line repair

    to cut a very long story i lost my phone line completely 8 days ago i reported it to my ISP and after 5 days i got it back... now they had to replace the cable running from the telegraph pole to my house for some reason thats where the fault was i thought great well done... couldnt wait to get home and get back on the net .... but to my horror it was so slow taking about 1-2 mins for a page to open and its still pritty poor now takes about 30 secs to 1 minute for a web page to open...been intouch with my ISP im having no joy telling me its all fine nothing wrong i done tests and this and that with them and they seem happy with my connection and speed ...but im telling them that before the repair i was getting between 2.8 and 3.2 MB now im lucky to be getting 1 MB ...one guy even said he couldnt understand why im not happy with the service ...now there telling my its my profile through the line has been changed and ill have to wait for 10 days and checking and testing and doing things over and over again and segesting its my computer and set up ect ...
    i have been at this for a week now what can i do ??? please someone help is it the new line or is it my ISP ??
    but i keep telling them it was all fine before and theres nothing wrong with my set up or my computer because the lap top is the same with the Ethernet cable plugged in so they both cant be the problem ..i have had them both checked at a cost of £65 with a computer tech guy at the shop he said they are clean and healthy systems ! 

    Hi Tony,
    There is a peice of equipment within the exchange which 'optimises' the speed of the broadband based on what the line is capable of. When you have had the recent fault on the line it is likely this equipment picked up the fact that the line wasnt capable of the speeds you were getting and has 'restricted' the speed to give you a stable connection.
    The equipment is there to try and offer you a stable connection for your Broadband (better to have a slowwer speed all the time than a super fast speed for 5 minutes of the day).
    Unfortunalty this can be 'confused' when you have a fault on the line and reduce your speed to compensate for the bad line. It should automatically 'optomise' the speed over a 10 day period and the problem should sort it self out.
    You can request your ISP to check this and make sure your line is set up corrcetly after the recent fault, but to be honest it can easier to wait the 10 days (as it is likely the people you speak to are not fully aware of this part of the line/Broadband or willing to help)
    It is also possible that the repair has had a negative affect on what the line can suppport (this can happen but unlikely to decrease your speed by something which you would notice) and the only soultion for this is to speak to your isp (if they are happy with the speed you are now getting you might not have much luck).
    It sounds like your ISP aren'y very helpful and have 'fobbed you off' for the ten days with out just telling you why, if it was me at this point I would consider an alternative ISP.
    Hope that atleast explains why they told you to wait ten days. :-)

  • Need Help Please with Flash Professional - No Cursor Change on Buttons/Links in Mac OS

    Hi Folks, I am relatively new to Flash Professional but I recently built a very nice flash website with very little problems.  I noticed after I uploaded my site to my server, that my mouse cursor did not change from an arrow to a finger on any of my buttons.  It did change on the hyperlinks, but not on the buttons.  Everything still worked fine but there was no indication to the user that an object was in fact an interactive button.  I found this code:  button1.buttonMode = true; button1.useHandCursor = true; and inserted it for all my buttons and that seemed to fix everything, I tested the site on firefox, ie, and safari.  I am using a PC with windows 7.  When I went to check the website on a Mac powerbook, the cursor did not change on any of the buttons and it does not change on any of my hyperlinks either.  I have searched all over trying to find a solution and have had no luck.  Can anyone please help me with this problem or point me in the right direction?  Any advice would be very much appreciated.  Thanks so much!!!

    Thank you so much for replying!  I did in fact let flash professional create the HTML page for the site and have not altered it at all.  Would you have any other suggestions as to why it's not displaying my links/buttons on a Mac?  I checked out the browsers Firefox, ie, and safari on my pc, but looking thru safari on the Mac, the cursor does not change on any of my links or buttons.  Thanks again so much for the reply, nice to hear from a human instead of reading thousands of posts!  Very much appreciated!!!!!

  • Help please with my navigation buttons

    Can anyone please help me with my vertical navigation buttons. I'm trying to set up my nav bar so that all the buttons have a background image (button.jpg) behind them at all times and the only thing that changes when touched or the mouse rolls over them is that the colour of the text changes, except when the sub buttons appear, because the name of some of the sub buttons are so long i have created another button image that is longer (button2.jpg), i only want this to appear on sub buttons otherwise the buttons will end up taking most of the pages space. I'm having great difficulties getting the sub buttons to appear with the correct image (button2.jpg) and am getting increasingly frustrated with it, can anyone please help!!!
    www.milesfunerals.com/index2.html

    index2.html is a broken link for sure. The main index page looks like it's working fine.
    A little styling critique if it's okay... Personally I'd have gone with a CSS or Javascript multi-level menu across the bottom of the header. Saves visitors from having to scroll all the way down the page to see every menu item. And I'd rethink the color of the "Miles & Daughters" in the header image. It kinda gets lost in the roses.
    If you have a link to the "broken" page please put it up so we can analyze it.

  • Help please :) with do not disconnect.

    I disconnected my ipod and I still get that "Do not disconnect message" And it doesnt even flash.
    Can somone please help me with this

    Try Resetting your iPod. Hold down the MENU and SELECT (centre) buttons for five or ten seconds until you see the Apple logo appear then the menu button to go to the normal display. Have a look at this link as well:
    iPod won't turn on
    iPod stops responding or will not waken from sleep

Maybe you are looking for