Scope and life of a $var

hello,
I dont understand ...many things :)
I am trying to get a picture and put it on a button
but when i try to compile i get this....
mohadib@ns2 /var/www/html/java--->javac space.java
space.java:25: cannot resolve symbol
symbol : variable pic
location: class space
JButton my_button = new JButton(pic);
^
1 error
any advice would be great. code below
Thanks,
jd
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.net.*;
public class space extends JApplet{
     public void init(){
          setContentPane(makeContentPane());
     public Container makeContentPane(){
          JPanel main_pane = new JPanel();
          JPanel main_panel = new JPanel();
          try{
               URL pic_url = new             URL("http://ns2.taproot.bz/java/prima_interface/thumbs/1.jpg");
               ImageIcon pic = new ImageIcon(pic_url);
          catch(MalformedURLException e){
               System.out.println(e);
          JButton my_button = new JButton(pic);
          main_panel.add(my_button);
          main_pane.add(main_panel);
          return main_pane;
}

You have no variable called pic in your program.
If you meant pic_url, you'll get a problem because the scope of a local variable is the block in which it is declared.
You need to take the pic_url definition outside of the try block for your program to work, ie
URL pic_url = null;
try{
  URL pic_url = new URL ("http://ns2.taproot.bz/java/prima_interface/thumbs/1.jpg");
  ImageIcon pic = new ImageIcon(pic_url);          
catch(MalformedURLException e)
   System.out.println(e);          
if ( pic_url != null )
   JButton my_button = new JButton(pic_url);

Similar Messages

  • Javascript discussion: Variable scopes and functions

    Hi,
    I'm wondering how people proceed regarding variable scope, and calling
    functions and things. For instance, it's finally sunk in that almost
    always a variable should be declared with var to keep it local.
    But along similar lines, how should one deal with functions? That is,
    should every function be completely self contained -- i.e. must any
    variables outside the scope of the function be passed to the function,
    and the function may not alter any variables but those that are local to
    it? Or is that not necessary to be so strict?
    Functions also seem to be limited in that they can only return a single
    variable. But what if I want to create a function that alters a bunch of
    variables?
    So I guess that's two questions:
    (1) Should all functions be self-contained?
    (2) What if the function needs to return a whole bunch of variables?
    Thanks,
    Ariel

    Ariel:
    (Incidentally, I couldn't find any way of  marking answers correct when I visited the web forums a few days ago, so I gave up.)
    It's there...as long as you're logged in at least, and are the poster of the thread.
    What I want is to write code that I can easily come back to a few months later
    and make changes/add features -- so it's only me that sees the code, but
    after long intervals it can almost be as though someone else has written
    it! So I was wondering if I would be doing myself a favour by being more
    strict about make functions independent etc. Also, I was noticing that
    in the sample scripts that accompany InDesign (written by Olav Kvern?)
    the functions seem always to require all variables to be passed to it.
    Where it is not impractical to do so, you should make functions independent and reusable. But there are plenty of cases where it is impractical, or at least very annoying to do so.
    The sample scripts for InDesign are written to be in parallel between three different languages, and have a certain lowest-common-denominator effect. They also make use of some practices I would consider Not Very Good. I would not recommend them as an example for how to learn to write a large Javascript project.
    I'm not 100% sure what you mean by persistent session. Most of my
    scripts are run once and then quit. However, some do create a modeless
    dialog (ie where you can interface with the UI while running it), which
    is the only time I need to use #targetengine.
    Any script that specifies a #targetengine other than "main" is in a persistent session. It means that variables (and functions) will persist from script invokation to invokation. If you have two scripts that run in #targetengine session, for instance, because of their user interfaces, they can have conficting global variables. (Some people will suggest you should give each script its own #targetengine. I am not convinced this is a good idea, but my reasons against it are mostly speculation about performance and memory issues, which are things I will later tell you to not worry about.)
    But I think you've answered one of my questions when you say that the
    thing to avoid is the "v1" scope. Although I don't really see what the
    problem is in the context of InDesign scripting (unless someone else is
    going to using your script as function in one of theirs). Probably in
    Web design it's more of an issue, because a web page could be running
    several scripts at the same time?
    It's more of an issue in web browsers, certainly (which I have ~no experience writing complex Javascript for, by the way), but it matters in ID, too. See above. It also complicates code reuse across projects.
    Regarding functions altering variables: for example, I have a catalog
    script. myMasterPage is a variable that keeps track of which masterpage
    is being used. A function addPage() will add a page, but will need to
    update myMasterPage because many other functions in the script refer to
    that. However, addPage() also needs to update the total page count
    variable, the database-line-number-index-variable and several others,
    which are all used in most other functions. It seems laborious and
    unnecessary to pass them all to each function, then have the function
    alter them and return an array that would then need to be deciphered and
    applied back to the main variables. So in such a case I let the function
    alter these "global" (though not v1) variables. You're saying that's okay.
    Yes, that is OK. It's not a good idea to call that scope "global," though, since you'll promote confusion. You could call it...outer function scope, maybe? Not sure; that assumes addPage() is nested within some other function whose scope is containing myMasterPage.
    It is definitely true that you should not individually pass them to the function and return them as an array and reassign them to the outer function's variables.
    I think it is OK for addPage() to change them, yes.
    Another approach would be something like:
    (function() {
      var MPstate = {
        totalPages: 0,
        dbline: -1
      function addPage(state) {
        state.totalPages++;
        state.dbline=0;
        return state;
      MPstate = addPage(MPstate);
    I don't think this is a particularly good approach, though. It is clunky and also doesn't permit an easy way for addPage() to return success or failure.
    Of course it could instead do something like:
        return { success: true, state: state };
      var returnVal = addPage(MPstate);
      if (returnVal.success) { MPstate = returnVal.state; }
    but that's not very comforting either. Letting addPage() access it's parent functions variables works much much better, as you surmised.
    However, the down-side is that intuitively I feel this makes the script
    more "messy" -- less legible and professional. (On the other hand, I
    recall reading that passing a lot of variables to functions comes with a
    performance penalty.)
    I think that as long as you sufficiently clearly comment your code it is fine.
    Remember this sort of thing is part-and-parcel for a language that has classes and method functions inside those classes (e.g. Java, Python, ActionScript3, C++, etc.). It's totally reasonable for a class to define a bunch of variables that are scoped to that class and then implement a bunch of methods to modify those class variables. You should not sweat it.
    Passing lots of variables to functions does not incur any meaningful performance penalty at the level you should be worrying about. Premature optimization is almost always a bad idea. On the other hand, you should avoid doing so for a different reason -- it is hard to read and confusing to remember when the number of arguments to something is more than three or so. For instance, compare:
    addPage("iv", 3, "The rain in spain", 4, loremIpsumText);
    addPage({ name: "iv", insertAfter: 3, headingText: "The rain in spain",
      numberColumns: 4, bodyText: loremIpsumText});
    The latter is more verbose, but immensely more readable. And the order of parameters no longer matters.
    You should, in general, use Objects in this way when the number of parameters exceeds about three.
    I knew a function could return an array. I'll have to read up on it
    returing an object. (I mean, I guess I intuitively knew that too -- I'm
    sure I've had functions return textFrames or what-have-you),
    Remember that in Javascript, when we say Object we mean something like an associative array or dictionary in other languages. An arbitrary set of name/value pairs. This is confusing because it also means other kinds of objects, like DOM objects (textFrames, etc.), which are technically Javascript Objects too, because everything inherits from Object.prototype. But...that's not what I mean.
    So yes, read up on Objects. They are incredibly handy.

  • Session scope and request scope

    Hi,
    I've a manage bean in session scope and within this bean I've a reference of another
    object (class person) . My question is, do i have to register this class in my faces-config-xml and if yes which scope should it have? session or request?
    Or it isn't necessary to register it?
    thanks
    class MymanageBean{
    private Person myPerson;
    }

    helllo,
    can someone tell me what the line in the preceding coed means?
    <meta http-equiv="refresh" content="<%= session.getMaxInactiveInterval() %>;url=login.jsp">
    -- session_expiry_test.jsp --
    <%@page contentType="text/html"%>
    <%@page pageEncoding="UTF-8"%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
       "http://www.w3.org/TR/html4/loose.dtd">
    <html>
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
            <title>JSP Page</title>
            <meta http-equiv="refresh" content="<%= session.getMaxInactiveInterval() %>;url=dummy_login.jsp">
        </head>
        <body>
        <h1>Welcome, dude with a session!</h1>
        Your session will expire in <%= session.getMaxInactiveInterval() %> seconds
        at which time your browser will be redirected to the login page and any
        and all unsaved changes will be lost.
        <br>
        Thank you for your cooperation!
        </body>
    </html>

  • N8 as remote control and life remote viewer for wi...

    I am going to buy wifi camera. I would like to use my N8 as remote control and life remote viewer.
    Is there any software for N8 Belle ?

    You need to contact the camera manufacturer and ask them if they are releasing an app for the N8 for that purpose. 

  • Does refreshing a report that includes Scope and Entity require elevated rights / permissions?

    This relates to the following thread:
    Why does refreshing a report in the EPM Add-In need to edit the Ownership Manager?
    Since I've received no responses on the above thread, I thought I might approach this from a different angle.
    If we have a report that includes both Scope and Entity, in SAP BPC 10 NW (801 SP03) / EPM Add-In 10.0 SP 16 Patch 1, does this require a user to have elevated permissions in order to refresh the report?  I ask because I have users who have rights to view reports, but they error out when they try to refresh a report's data, only where Scope and Entity are used in the report.  The tasks that error are:
    P0081
    Run Consolidation Tasks
    P0082
    View Ownership Manager
    P0083
    Edit Ownership Manager
    I do not understand why any of these should even be called by refreshing the report, as the user is simply "viewing" data that already exists in the environment.
    Can someone please shed some light on this or point me in the direction of how I can go about resolving this issue?
    Your help is greatly appreciated.
    Jeff

    Hi
    I am facing the same issue despiste the elevated app permission as per
    https://msdn.microsoft.com/en-us/library/office/jj822159.aspx?f=255&MSPPError=-2147217396
    I still had the error 401
    the solution for me was
    Under list settings -> advanced settings update the Create and Edit access settings from "Create and edit all items"
    the add the user the right to add only ( no edit , no delete) .
    Eric Caron

  • Scope and Objectives of making java swing scientific calculator

    I am going to write code for java swing scientific calculator..... can any body help me to write scope and objectives of this project.... please please :-(

    If this is for school work, then defining the scope is part of the problem. The only advice I will give you is that you only need to implement what the assignment specifies. It is probably intentionally vague so you can bite off way too much and not finish -- failure should teach you something too.
    I had just such an assignment in my software engineering class in college -- create a cross compiler from X to Y where X and Y where known instruction sets. That was the entire assignment -- plus the instruction sets for X and Y. My team looked at the allotted time and resources availabe and decided to do a minimal implementation.
    We where the only team to complete the assignment and all recieved A's because we accurately implemented the required solution and were able to evaluate the real problem--resource allotment--accurately.
    Each other team tried to add "extras" that would "guarantee" them an A grade. In actuallity it was just a lot more work than they could do though and it hurt them in the long run--No matter how good the work was to the point they had at the end of the semester, each student in the other teams only recieved a B or less grade in the class due to failure on that project. Resource allocation and planning--only you can do that for your team/project.

  • DHCP Scopes and Scope Options Import & Export

    I need to adjust lease times for over one hundred scopes spread across multiple servers (about half of them are on one server, though). There will be 2 or 3 different lease times used. What is the best way to do this?
    I know I can use netsh to change the option for each scope. But I would like to script the collection of the list of scopes, rather than typing the list manually. Is there a way to export a list that contains just scopes and descriptions?
    Thanks

    Hi,
    Actually, it can be exported as txt file.
    netsh dhcp server export c:\DHCP\myscopes.txt
    Export-DhcpServer
    And you can also manage it via powershell
    Use the PowerShell DHCP Module to Simplify DHCP Management
    http://blogs.technet.com/b/heyscriptingguy/archive/2011/02/14/use-the-powershell-dhcp-module-to-simplify-dhcp-management.aspx
    Hope this helps.

  • Security scopes and reporting

    Hello,
    I'm trying to plan a ConfigMgr 2012 site that will be used by multiple groups who do not interact with one another. I'd like to divide this site into managerial groups using security scopes and RBAC, ideally so members of one group cannot view or manage
    collections, applications, and updates belonging to the other group. In a lab I've created groups A and B with access to security scopes A and B, with access to collections A and B. So far this has worked out nicely in almost every area except for reporting.
    As a full administrator I can view and run reports just fine; however, users A and B (who are not full administrators, but are members of the "ConfigMgr Report Users" role in my SSRS instance) cannot view any reports from the console. Additionally when I
    click Create Report under the context of user A or B, I get the error "Could not find an installed Reporting Services point. Verify the site role is installed and accessible." To me it sounds like there is a permissions issue somewhere in SSRS or ConfigMgr
    but I haven't figured out what yet.
    Aside from that, I would like so members of group A cannot report on objects that belong to security scope B. To my knowledge this won't be inherently possible because the SSRS security model is different from the ConfigMgr RBAC model. Has anybody been able
    to come up with any workarounds to scope down the reporting capabilities of limited ConfigMgr users? Any advice or direction in this realm would be greatly appreciated.
    Thanks,
    Nick

    Yes, I know this is an old post, but I’m trying to clean them up. Did you solve this problem, if so what was the solution?
    This has been solve in CM12 R2, you can see it in the blog/video.
    http://www.enhansoft.com/blog/role-based-administration-rba-reporting-feature-in-sccm-2012-r2
    Garth Jones | My blogs: Enhansoft and
    Old Blog site | Twitter:
    @GarthMJ

  • Sound and Vibration Toolkit with NI-SCOPE AND NI-FGEN

    Hi,
    I would like to use the Sound and Vibration Toolkit with the NI-FGEN and NI-SCOPE,specifically the stepped sine analysis. The stepped sine VI's are compatible with only DAQmx and not NI-SCOPE and NI-FGEN,right?
    Any way around this?

    Hi there,
    Firstly I assume you mean Swept sine and not stepped!?
    This is the closest thing I could find:
    http://zone.ni.com/devzone/cda/epd/p/id/3347
    I had a look for you and there is nothing that works with a swept sine in FGEN or SCOPE natively that we supply.  However I do believe that a lot of the functionality could be programmed in FGEN and SCOPE vi's.
    You would however need to make copies of all the Swept Sine VI's and replace all DAQmx calls and property nodes with the appropriate SCOPE/FGEN vi's.
    Not a short answer I'm afraid and I can't guarantee that all the functionality is going to be there.
    Sorry its not a better answer.
    AdamB
    Applications Engineering Team Leader | National Instruments | UK & Ireland

  • Scope and Proposal preparation for SAP GRC AC Implementation.

    Hi ,
    I would like to know procedure how the RFP (Request for proposals) are prepared for SAP GRC AC Module implementation. and also how the scope and effort estimation are calculated.
    are there any guidelines and checklist are available to be followed.
    is there any generic approach followed during SAP GRC AC implementation for proposal as well as for effort estimation.
    Pelase clarify my doubts
    Regards,
    RK

    Hi,
    Use RTA on SAP BASIS 7.00 System for any system other than ECC which has ABAP and Basis Level 7.00 with Kernel 7.00
    I don't see any option for 7.20, may be it will be available later on.
    We have SRM connected to GRC so I can cofirm, yes it is possible to connect SRM to GRC and work with SRM rulebook. RTA and Post-RTA activites and JCO and RAR connectors are a must to get it work properly. In fact all configurations are required as it is in ECC system.
    No HR RTA is required ,as there is no HR module in SRM.
    Regards,
    Sabita

  • AddOn for a small Car and Life Insurance company, Policy management

    Hi Everybody,
    I am looking for an AddOn for a small Car and Life Insurance company.
    I am interested in policy management
    Do you know if there is any in the market?
    Thanks

    Hi,
    You need to search SAP Business One Partner Solutions (Add-ons) forum and posted it there if you find none.
    Thanks,
    Gordon

  • Difference Between BackingBean Scope and Request Scope in Manged Beans

    Hi,
    This is going to sound really silly, me asking this question after working for over 6 months in ADF, but could anybody please give me some differences between backing bean scope and request scope. I've looked at the official Oracle documentation, and I'd be really grateful if anybody could please dumb it down a bit for me.-:)
    Thanks,
    Debojit

    If you make a declarative component and put it on a page more than once.
    Just like you can put multiple instances of the af:inputText component on a page, you can put multiple instances of declarative components on a page.

  • MDM 5.5 Scope and growth

    Dear All,
    Could anyone let me  know the scope and growth of MDM . I am working as
    SAP XI Consultant for the past 2 years, i heard that with XI experience it is good
    to get into SAP MDM.
    As i went through couple of blogs  it made me intresting to learn MDM .
    I would Appreciate if anyone let me know the training centres or any materials to start up with MDM.
    Kind Regards,
    Vijay

    hi,
    MDM is emerging in 2008, you will have good scope as an XI consultant.
    you will find lot of documentation in help.sap.com, it is the bible for MDM.
    follow the links for further information:
    SAP Master Data Management (SAP MDM) - EIM - SAP Developer Network(This web-site gives introduction to MDM, Master Data Operations, Master Data Integration,Master Data Quality )
    http://help.sap.com/saphelp_mdm550/helpdata/en/43/D7AED5058201B4E10000000A11466F/frameset.htm
    /people/nitzan.levi/blog/2005/06/20/the-story-of-mdm55
    /people/sap.user72/blog/2005/06/14/worlds-fastest-and-shortest-introduction-to-netweaver-mdm-55
    /people/ravikumar.allampallam/blog/2005/09/06/mdm-client-content-manager--different-modes
    http://www.sapnetweavermagazine.com/archive/Volume_03_(2007)/Issue_02_(Spring)/v3i2a12.cfm?session=
    http://www.sap.com/platform/netweaver/pdf/BWP_SB_Data_Unification.pdf
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/9018dc62-23a8-2910-b7ae-9023670c3a53
    MDM on help.sap.com
    http://help.sap.com/saphelp_mdm550/helpdata/en/43/D7AED5058201B4E10000000A11466F/frameset.htm
    SAP mdm how to guides:
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/webcontent/uuid/5024a59a-4276-2910-7580-f52eb789194b [original link is broken]
    MDM elearning:
    https://admin.sdn.sap.com/irj/sdn/mdm-elearning
    Difference Between Central SLD & Local SLD
    https://www.sdn.sap.com/irj/sdn/docs?rid=/webcontent/uuid/bf0f8d87-0d01-0010-aa8b-f2c46a70557b [original link is broken] ( with screenshots)
    1)https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/60559952-ff62-2910-49a5-b4fb8e94f167
    2 ) http://help.sap.com/saphelp_nw04/helpdata/en/0a/5f723bc34bf17ee10000000a114084/content.htm
    3)http://help.sap.com/saphelp_mdm550/helpdata/en/43/D7AED5058201B4E10000000A11466F/frameset.htm
    http://www.google.de/search?hl=en&q=SAPMDMlive+implementation&btnG=Search .
    hope this may help you,
    Regards,
    Srinivas

  • Wht isifference btw content scope and valuation scope in oracle inventory

    hi to all
    what is differnce btween content scope and valuation scope in cycle count form . both have organization and sub inventory check box can any body tell difference btween the both . please help me...

    The content scope defines which item you will consider.
    If you select Subinventory, only those items that reside in that subinventory are considered.
    If you select organization, then all items in that org are considered.
    The valuation scope determines how should the selected items be ranked.
    If your Content scope is organization, then the valuation scope must be organization too.
    But if your content scope is subinventory, then the valuation scope can either be subinventory or organization.
    Assume you have following onhand
    item/onhand      Subinv       Entire org
    Item1            5               50
    Item2           10               30Assume your content scope = subinventory.
    If you select valuation = subinventory, then the items will be ranked according to the onhand of the items in THAT subinventory. So Item1 will get a lower ranking that item2.
    But if you you select valuation = organization, then the items in that subinventory will be ranked according to their onhand in the ENTIRE organization. So Item1 will get a higher ranking that item2.
    Hope this answers your question,
    Sandeep Gandhi

  • Scope and current market trend of SAP ISU

    Hi Experts,
    What is the scope and current market trend of SAP ISU?
    What all are the companies using SAP ISU?
    Regards,
    Dipin

    Not only for SD but for all modules, there is a boom in India and many IT companies are floating their requirement in market to grab the cream of consultants.
    thanks
    G. Lakshmipathi

Maybe you are looking for