Using a variable while creating an object

I have 8 buttons called b0 to b8
Button b0 = new Button (frame, 10, 10, 50, 50,"",'0');
Button b1 = new Button (frame, 70, 10, 50, 50,"",'1');
Button b2 = new Button (frame, 130, 10, 50, 50,"",'2');
Button b3 = new Button (frame, 10, 70, 50, 50,"",'3');
Button b4 = new Button (frame, 70, 70, 50, 50,"",'4');
Button b5 = new Button (frame, 130, 70, 50, 50,"",'5');
Button b6 = new Button (frame, 10, 130, 50, 50,"",'6');
Button b7 = new Button (frame, 70, 130, 50, 50,"",'7');
Button b8 = new Button (frame, 130, 130, 50, 50,"",'8');Rather then create them seperately a for loop would make more sense I think. Something like
for (int i = 0; i < 9; i++) {
                int x = (i % 3) * 60 + 10;
                int y = (i / 3) * 60 + 10;
                Button "b"+i = new Button (frame, x, y, 50, 50,"",i);
            }But I cant make this work, what am I doing wrong.
Thanks

Variable names don't mean much in Java. Certainly you can't do operations on them like
    Button "b"+iBut your buttons do form a sort of group or unit - they are geometrically related for one thing. What you need to do is create an object that represents this group.
Try using an array.
Declare an array of 9 buttons. Then you can use a for loop much like you have. But instead of talking about "b"+i, you would talk about b.
Anything you were doing before with b2 you can still do - by referring to that Button as b[2].

Similar Messages

  • Error while creating Temse Object (W2 form in PU19)

    Team,
    When i try to create the w2 in PU19, i am getting the error statingthat ERROR WHILE CREATING TEMSE OBJECT HRLUS01A100900109026.Please advise me in this.(We are maintaining the HRSP-42).It is veryurgent,Expecting your valuable Guidance.Points sure for the answers.
    Regards
    Priya.K

    Hi
    let me know weather r u using any reference object which contain the routinee.
    regards,
    chandra.

  • Error while creating PDF object

    We are using Adobe Interactive Forms with Guided Procedures.  Netweaver 7.0 SP14 (Dual stack Java & Abap).  All was working well it appears until we configured SSL for ADS - don't know for sure if this caused the problem but it is the only change we can identify around the time that our problems began.
    When we attempt to Create an Impersonalized Form we receive the following error -
    Cannot retrieve template structure: Execution ended in an unrecognized state
    When we attempt to test a callable object associated with an interactive form we receive -
    Error while creating PDF object: PDF object could not be created; object returned from ADS is null.
    In both cases the entries in the default trace log are the same -
    Service XMLFormService: Native process (PID=0) /usr/sap/UFD/DVEBMGS02/j2ee/os_libs/adssap/XMLFormService/bin/XMLForm.exe terminated abnormally with error code 134
    PDF object could not be created; object returned from ADS is null
    com.sap.caf.eu.gp.base.exception.EngineException: PDF object could not be created; object returned from ADS is null
    at com.sap.caf.eu.gp.model.iforms.adapter.pdf.AdobePDFAdapter.createInstanceDocument(AdobePDFAdapter.java:542)
    at com.sap.caf.eu.gp.model.iforms.preproc.FormPreprocessor.execute(FormPreprocessor.java:507)
    Like I mentioned earlier this functionality was working successfully in our environment at one time.
    Any guidance in this matter would be greatly appreciated.
    Thanks,
    Joe

    Joe,
    If you originally configured ADS without SSL, I would recommend going back through the ADS Configuration Guide for your NetWeaver stack and make sure all the necessary changes for SSL were made.  I've seen another case where a step was missed in SSL configuration for ADS which caused a form to error.
    If everything looks good based on your SSL configuration, I would recommend creating an OSS Note.
    -Matt

  • What are the naming conventions we should follow while creating an object

    hi
    what are the naming conventions we should follow while creating an object in ABAP dictionary, i.e while creating zee table.

    Hi,
    Namespaces and Naming Conventions
    SAP has reserved name ranges for customer objects and SAP objects. Use these customer name ranges to make sure that your objects are not overwritten by SAP objects during the import of corrections or an upgrade.
    This documentation lists the customer name ranges for the different system objects.
    Only use the customer name ranges. If you do not keep to the name ranges for customer objects you may lose your development objects.
    SAP delivers a few system objects with names that fall within the customer name range. These objects already existed when the customer name range was extended from YY/ZZ to Y/Z. These objects are listed in table TDKZ.
    Regards

  • What kind of  inforobject can be used for compounding while creating charac

    Hi all :
         what kind of standard inforobject can be used for compounding while creating characteristic ?
        I found that some could be , but some couldn't ,  like 0RESP_PERS.
    THE ERROR :
    1      Characteristic 0RESP_PERS was included in the compounding for COS09 (-> Long Text)      QLong text exists
    2              0RESP_PERS is just an attribute and is not allowed in the compounding No long text exists
    0RESP_PERS is an object, why  can't be  used for compouning? 
    Could you please tell me why ?
       Thank you very much!
    Edited by: jingying Sony on May 10, 2009 7:05 AM

    Hi Jingying Sony,
    One can mark an infoobject as an Attribute Only in the General tab.
    This means that the infoobject will only act as an attribute and cannot be used as a characteristic in infocubes. Neither can it be used as a navigational attribute and I guess it may not be available for compounding then(since in compounding - it implicitly becomes a characteristic).
    For your ref
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/e3/e60138fede083de10000009b38f8cf/frameset.htm
    If you uncheck this checkbox, then may be it will allow you to compound this characteristic..
    You may try with a (self created) ZRESP_PERS reference chararacteristic of 0RESP_PERS, to confirm this.
    One more link for your reference
    http://jgtang82.javaeye.com/blog/191795
    Hope this helps,
    Best regards,
    Sunmit.

  • Error while creating info object

    error while creating info object a character
    Info object may be a maximum of  000060 digits...... what would be the error?
    Thanks ALL

    Hi,
    The maximum length supported by one CHAR type infoobject is 60. Check whether you have assigned more.
    If you have to load more length ( more than 60) split the total thing into different infoobjects. Create different infoobjects and split the total thing into them - like 1st 60 char in 1st infoobject, char 61-120 in 2nd infoobject and so on. Then you can again concatenate them.
    Thanks,
    Indrashis

  • Linker Error while creating shared object.

    While creating shared object we got "file processing error".
    Below is our compilation line and the error out put.
    ==================
    /net/icom3/opt//SUNWspro/SC5.0/bin/CC -o fn_ctx_onc_fn_files.so.1 -G -h fn_ctx_onc_fn_files.so.1 -z text -z defs -z combreloc -norunpath -nolib -Qo
    ption ld -R/usr/lib/fn pics/FNSP_filesOrgContext_default.o pics/FNSP_filesFlatContext_default.o pics/fnsp_internal_common.o pics/FNSP_nisAddress.o
    pics/FNSP_nisOrgContext_default.o pics/FNSP_nisFlatContext_default.o pics/FNSP_hash_function.o pics/FNSP_filesHierContext.o pics/FNSP_filesDotC
    ontext.o pics/FNSP_filesFlatContext.o pics/FNSP_filesHUContext.o pics/FNSP_filesWeakSlashContext.o pics/FNSP_filesPrinternameContext.o pics/FNSP_
    filesPrinterObject.o pics/FNSP_filesOrgContext.o pics/FNSP_filesImpl.o pics/fnsp_files_internal.o pics/onc_fn_files.o -lnsl -lc -L/user/vts/X
    FN_CHECK/jnk/usr/lib/fn -lxfn -lfn_spf -lfnsp -lfn_p
    ld: fatal: File processing errors. No output written to fn_ctx_onc_fn_files.so.1
    ==================================
    Thanks in advance.
    -Lokesh MS

    Hi,
    The maximum length supported by one CHAR type infoobject is 60. Check whether you have assigned more.
    If you have to load more length ( more than 60) split the total thing into different infoobjects. Create different infoobjects and split the total thing into them - like 1st 60 char in 1st infoobject, char 61-120 in 2nd infoobject and so on. Then you can again concatenate them.
    Thanks,
    Indrashis

  • Hi All, which is better while creating an object

    Hi All, which is better while creating an object,
    for ex:
    public class Joe {
    public void disp() {
    System.out.println("Joe.disp");
    (1) Joe j = new Joe();
    j.disp();
    (2) new Joe().disp();
    of course, both are equal, which is better in performance perspective

    I suggest you just write code and when the assignment is done, AND you have a performance issue, only then try to improve things. The question you're asking now is likely of no relevance to the performance of you application.
    You can run your application through a profiler to see what specific part of it is consuming (too) much memory.

  • Using a string variable to create an object

    Hi, I just have a quick question. It is probably very simple but I can not seem to find an asnwer anywhere.
    I have a class called Receive, from this class I derrive 12 difference other classes.
    I also have a hashtable with a bunch of Object objects. At run time I get one of these objects according to some hastable key. So once I have this object I need to cast it to the right type (one of the above mentioned 12).
    So I know I can find out which type this object is by doing this: object.getClass()
    This returns a Class object. I then need to somehow use this class object to perform the cast. I tried everything and it doesnt seem to work. Then I thought well I can get the string name of the class : object.getClass().getName()
    So I'm wandering if there is a way to use this string to cast my object. Or maybe there is another way.
    I did see the cast() method in the Class api but I can't figure out the point of it since is returns an Object class object and not my class's object.

    I took your advice and re factored the Receive class so it had all the functionality I needed except two methods which would then be overridden in the derived classes. What I had a hard time understanding is once an object of class say SpecialReceive extends Receive it can be referred to as Receive yet still maintain that it's a SpecialReceive.
    What I mean is if I give a Receive object to some method and this method has no idea that this object is actually SpecialReceive and it calls a method say run() which gets overridden by the SpecialReceive. I thought that since this method has no idea what type of Receive this object is it will execute Receive's run(). But it actually does know what type of class it is and it executes the right run() method (the one that SpecialReceive overrides).
    After I realized this there is no more need for casting.
    Thanks everyone for your contributions.

  • Getting Error while creating Document object  after  parsing XML String

    Hi All,
    I have been trying to parse an XML string using the StringReader and InputSource interface but when I am trying to create Document Object using Parse() method getting error like
    [Fatal Error] :2:6: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    seorg.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    Please find the code below which i have been experimenting with:
    import java.io.BufferedReader;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.io.StringReader;
    import java.util.List;
    import java.util.*;
    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.InputSource;
    import org.xml.sax.SAXException;
    import java.io.*;
    public class TestMain {
         public static void main(String[] args) {
              String file = "";
              file = loadFileContent("C:\\Test.xml");
              System.out.println("contents >> "+file);
              parseQuickLinksFileContent(file);
    public static void parseQuickLinksFileContent(String fileContents) {
    PWMQuickLinksModelVO objPWMQuickLinksModelVO = new PWMQuickLinksModelVO();
         try {
    DocumentBuilderFactory factory =           DocumentBuilderFactory.newInstance();
         DocumentBuilder builder = factory.newDocumentBuilder();
         StringReader objRd = new StringReader(fileContents);
         InputSource objIs = new InputSource(objRd);
         Document document = builder.parse(objIs); // HERE I am getting Error.
         System.out.println(document.toString());
    What is happening while I am using builder.parse() method ???
    Thanks,
    Rajendra.

    Getting following error
    [Fatal Error] :2:6: The processing instruction target matching "[xX][mM][lL]" is not allowed.
    seorg.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.

  • SAP BW ERROR OCCURS WHILE CREATING ODS OBJECT

    HI TO SAP BW GURUS
    AFTER CREATING ODS OBJECT,AND ODS OBJECT STRUCTURE,WHILE ACTIVATING THE STRUCTURE I AM GETTING MESSAGE AS
    <b>message : STDO:LOG COULDNOT BE WRITTEN ON OUTPUT DEVICE T</b>
    COULD ANYONE PLS TELL ME HOW TO RECTIFY THT
    VENKAT

    Read the information message carefully. Then proceed, if you intend to have custom  "standard" texts (sort of an oxymoron, but everyplace I've been does this)...
    If you are working in a customer system, only create standard texts using the following naming convention:
    Initial letter Y or Z in the text name with any text ID
    or
    Initial letter Y or Z in the text ID with any text name

  • Easy DMS cannot use additional data while creating a document

    Hello,
    We have installed sap easy dms 7.0
    We have a problem while creating a new document with SAP Easy DMS.
    On the DIR tab the additional data cannot be used.
    Do I have to change a registry setting?
    We already have defined classes and their features and values in CL02 en CT04
    please help
    Geert ter Harmsel

    Hi,
    Additional functions for object links active Indicator controls the activation of additional functions for the links of objects to this document type.
    You can activate the following additional functions for an object to document link:
    1) Valuation
    Additonally, you can link another object to a chosen database table (See example Additional Object).
    You can delete the additional information of an object link.
    2) Classification
    You can classify the link. You must create a class (class type 048 - object link) with the characteristics that you want to specicify for the link (For example, responsibility, organaization).
    When you set the indicator these functions are active during processing of the document info recod, register object link.
    Hope this is what you are looking for.
    Regards,
    Deepak Kori

  • Problem while creating DS Object

    Hello All,
    While creating a DataStore Object named :"0OI_TSW_DS03",I am getting a message "Name OI_TSW_DS03 after prefix 0 has to have spaces between 3 and 8".
    Is it because the no:of letters in the DS Object name exceeded a certain limit or any other reason?
    Thanks in advance,
    Chintu.

    hi Chintu,
    1. you shouldn't use prefix 0 for your own created objects.
    2. maximum name for ODS is 9 characters.
    see following oss note
    hope this helps.
    i guess you are using nw2004s, there is dedicated forum for nw2004s
    /community [original link is broken]
    160317-Customer namespace for objects in the Business Warehouse (BW)
    Symptom
    This note provides information on the customer namespace for objects in BW 12B and BW 2.0, BW 3.0, BW 3.1, BW 3.5 with the standard character set.
    Other terms
    Customer namespace, BW12B, BW20, BW30
    Solution
    Info object:
    Length: 3 - 9 characters.
    Must start with a letter from A - Z.
    Permitted characters:
    Alphanumeric characters, single underscore.
    Non-permitted characters:
    Double underscore, non-alphanumeric characters, German umlauts, underscore at the end of the name.
    Description long CHAR 60.
    Description short CHAR 20.
    Hierarchies:
    Length: 30 characters (technical name).
    Non-permitted characters:
    Non-alphanumeric characters.
    Description long CHAR 60.
    Texts:
    Description long CHAR 60.
    Description medium CHAR 40.
    Description short CHAR 20.
    InfoSource:
    Transaction data:
    Length: 30 characters.
    First character must be a letter from A-X (as of BW 2. 0 A-Z)
    Permitted characters:
    Alphanumeric characters, underscore.
    Non-permitted characters:
    Blank characters, non-alphanumeric characters, German umlauts.
    Description long CHAR 60.
    InfoCube:
    Length: 3 - 9 characters.
    First character must be a letter.
    Permitted characters:
    Alphanumeric characters, underscore.
    Non-permitted characters:
    Blank characters, non-alphanumeric characters, German umlauts.
    Description CHAR 60.
    Query:
    Length: 30 characters.
    First character must be a letter or an underscore.
    Description CHAR 60.
    Aggregate:
    Description CHAR 30.
    InfoPackage, InfoPackage groups:
    Description long CHAR 60.

  • Updation problem while creating multiple objects from enterprise portal

    Hi All,
    From enterprise portal i am calling an RFC 'BAPI_PROJECT_MAINTAIN' to create objects .
    While trying to create multiple objects simultaneously it gives error "sapuser is currently using, can't be created".
    It seems like as i am creating multiple objects by calling RFC repeatedly , while the first one is not updated fully i am sending the second value to be processed.
    Pl. tell me how to overcome this. Do I need to add any sleep time in EP or any other method is there in SAP to overcome this situation.
    thanks
    sandeep

    Dear Sandeep,
    I have discussed this problem with EP team lead in my organisation, i have given your email id to him he will forward the solution on your id.
    If usefull reward points helpfull....
    Regards,
    Rajneesh Gupta

  • Error while creating DiscoveryClient object

    Hi,
    i have an issue creating DiscoveryClient object. I tried to solve this by granting all permissions and THEN generating the secret but i still the same Exception.
    public string discoveryId = "https://api.office.com/discovery/";
    public string cmmAth = "https://login.windows.net/Common";
    public async Task<OutlookServicesClient> EnsureClientCreatedAsync()
    try
    string authority = cmmAth;
    _authenticationContext = new AuthenticationContext(authority);
    DiscoveryClient discoCli = new DiscoveryClient(async () => await GetTokenHelperAsync(_authenticationContext, discoveryId));
    CapabilityDiscoveryResult discoResult = await discoCli.DiscoverCapabilityAsync("Calendar");
    var outlookCli = new OutlookServicesClient(discoResult.ServiceEndpointUri, async () => await GetTokenHelperAsync(_authenticationContext, discoResult.ServiceResourceId));
    return outlookCli;
    catch (AdalException e)
    MessageBox.Show(e.ToString());
    if(_authenticationContext != null && _authenticationContext.TokenCache != null){
    _authenticationContext.TokenCache.Clear();
    return null;
    public async Task<string> GetTokenHelperAsync(AuthenticationContext context, string resourceId)
    string accessToken = null;
    AuthenticationResult result = null;
    ClientCredential cliCred = new ClientCredential("xxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx", "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy=");
    result = await context.AcquireTokenAsync(resourceId, cliCred);
    accessToken = result.AccessToken;
    return accessToken;
    and my AdalException is
    AADSTS70001: Application with identifier xxxxx-xxxx-xxxx-xxx-xxxxx was not found in the directory api.office.com
    thx for any Help
    Maciej 

    Hi,
    What the application type did you develop with: Web Application or Windows Client Application?
    To use Office 365 API in ASP.NET Web Application, I suggest you referencing the sample project
    O365-ASPNETMVC-Start.
    internal static async Task<OutlookServicesClient> EnsureOutlookServicesClientCreatedAsync(string capabilityName)
    var signInUserId = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value;
    var userObjectId = ClaimsPrincipal.Current.FindFirst("http://schemas.microsoft.com/identity/claims/objectidentifier").Value;
    AuthenticationContext authContext = new AuthenticationContext(SettingsHelper.Authority, new ADALTokenCache(signInUserId));
    try
    DiscoveryClient discClient = new DiscoveryClient(SettingsHelper.DiscoveryServiceEndpointUri,
    async () =>
    var authResult = await authContext.AcquireTokenSilentAsync(SettingsHelper.DiscoveryServiceResourceId,
    new ClientCredential(SettingsHelper.ClientId,
    SettingsHelper.AppKey),
    new UserIdentifier(userObjectId,
    UserIdentifierType.UniqueId));
    return authResult.AccessToken;
    var dcr = await discClient.DiscoverCapabilityAsync(capabilityName);
    return new OutlookServicesClient(dcr.ServiceEndpointUri,
    async () =>
    var authResult = await authContext.AcquireTokenSilentAsync(dcr.ServiceResourceId,
    new ClientCredential(SettingsHelper.ClientId,
    SettingsHelper.AppKey),
    new UserIdentifier(userObjectId,
    UserIdentifierType.UniqueId));
    return authResult.AccessToken;
    catch (AdalException exception)
    //Handle token acquisition failure
    if (exception.ErrorCode == AdalError.FailedToAcquireTokenSilently)
    authContext.TokenCache.Clear();
    throw exception;
    return null;
    For Windows client application, you could get the token by using the code as following:
    private async void GetToken()
    string authority = "https://login.windows.net/Common";
    AuthenticationContext authenticationContext = new AuthenticationContext(authority);
    string discoveryResourceId = "https://api.office.com/discovery/";
    String clientId = "{Client ID}";
    Uri redirectUri = new Uri("http://localhost/{return GUID}");
    var token = authenticationContext.AcquireToken(discoveryResourceId, clientId, redirectUri);
    Regards,
    Jeffrey
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

Maybe you are looking for

  • How do i turn off messages with the new mountain lion os?

    My husband and I share an Apple ID. When I use the iMessages on my MacBook it send them to both of our iPhones. How can I turn this off on my computer?

  • Installation sun one studio ver. 5 fail in mandrake

    I download sun one studio ver.5 in my mandrake linux ver. 9.0 and I have jsdk1.4.1_03. When I tried install it I received this message: To install sun one studio 5 you need to log in a superuser or a user with administrator privileges. I login in a t

  • Looking for a nice solution for different cases with nearly same operations

    Hi everybody: I'm looking for a nice solution for the following problem: I'm measuring different data at the same time (with different devices). I would like to save these data all in one array (or cluster?), but I don't know exactly the way to do th

  • Flash Builder (4.5.1) iOS on-device debug crash

    Hi all, I've got a Flex app that I'm building for an iPAD and I can debug it on the simulator and on the iPad device (if I select 'fast' packaging method). The problem is when I want to debug on the device using the "Standard" option for packaging (w

  • Reporting Standards

    Hi All, I am new to sap-abap programming .Can any one of you tell me the SAP standards that are to be followed while writing an abap program ? Also can I use joins for the four tables at once . I heard that this would have performance issues so we ll