Problem adding item to list using a function.  Error - Null pointer

Hi Guys,
I'm not sure what the problem is, but for some reason I am unable to add an item to a list using a function. I can add an item when I call it in the same function that the list is created, but I cannot add the item from anoter function. Here is the code:
Main:
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;
public class main {
      * @param args
     public static void main(String[] args) {
          JFrame JFrame = new JFrame();
          JFrame.setSize(400,400);
          testpanel panel1 = new testpanel();
          panel1.setBackground(Color.red);
          JPanel panel2 = new testpanel();
          panel2.setBackground(Color.BLUE);
          JFrame.add(panel1);
          JFrame.add(panel2);
          JFrame.setLayout(new FlowLayout());
          //THIS GIVES ERROR:
          //NullPointerException
          panel1.addListItem("test");
          JFrame.setVisible(true);
}And here is the testpanel class:
* To change this template, choose Tools | Templates
* and open the template in the editor.
* testpanel.java
* Created on Apr 7, 2010, 6:10:24 PM
import java.awt.List;
import java.awt.ScrollPane;
import java.awt.event.ActionListener;
* @author Snowraver1
public class testpanel extends javax.swing.JPanel {
     public void addListItem(String string){
          list.add(string);
    /** Creates new form testpanel */
    public testpanel() {
        initComponents();
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        jButton1 = new javax.swing.JButton();
        ScrollPane scrollPane = new ScrollPane();
        List list = new List();
        jButton1.setText("jButton1");
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(49, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addGap(46, 46, 46))
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(123, 123, 123)
                .addComponent(jButton1)
                .addContainerGap(139, Short.MAX_VALUE))
        this.add(scrollPane);
        scrollPane.add(list);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private ScrollPane scrollPane;
    private List list;
    // End of variables declaration//GEN-END:variables
}Thanks for the help!
-- Snow

You should check how you are initializing your variables in your testpanel class. You initialize your button correctly, but your other class variables are being overridden. As a result, your class variables still have a value of 'null'.

Similar Messages

  • Copy one list items new list using client side object model

    Hi,
    I have a requirement like i need to copy one list information to new list with createdby and modified by fields.I need to use client side object model code.Can u please send me the code sample.
    Regards,
    Praveen

    Hi,
    According to your post, my understanding is that you want to copy one list items new list using client side object model.
    You can use console application.
    Here is a similar thread for your reference:
    https://social.technet.microsoft.com/Forums/sharepoint/en-US/28a43891-7505-4d34-b513-fdd66773c2a3/copy-list-item-to-another-list-using-client-object-model-in-console-application?forum=sharepointdevelopmentprevious
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Error while adding items to cart using oracle.apps.ibe.shoppingcart.list.ShopList.saveQuoteFromListLines API

    Hello,
    I am getting the below error message when I try to add line items to cart using oracle.apps.ibe.shoppingcart.list.ShopList.saveQuoteFromListLines API.
    ORA-01403: no data found in Package IBE_Shop_List_PVT Procedure Save_Quote_From_List_Items
    This is the underlying procedure/package getting called:  IBE_Shop_List_Wrapper_PVT.Save_Quote_From_List_Items
    Please help me in resolving this issue.
    Thanks in advance!

    L S P.. wrote:
    Hi,
    Actually that notes says about invalid objects in ASO and IBE objects.
    But i couldn't found any invalid objects. Also i was cleared cache using functional administrator also.
    But still am getting this error.
    Please help on this.. It is on critical.Please log a SR if the doc did not help.
    Thanks,
    Hussein

  • Update item in list using rest api - failed when browsing in juniper session

    this issue is about browsing to an on premises sharepoint 2013 inside a LAN using Juniper session
    the user can see everything and can create new list items with rest api but
    cannot update existing items using the function below.
    we've got this function which we use to update list items in rest
    it works like a charm when browsing inside the LAN
    function updateListItem(itemIdentityField, itemIdentity, listName, siteUrl, item, success, failure) {
    getListItemWithId(itemIdentityField, itemIdentity, listName, siteUrl, function (data) {
    $.ajax({
    url: data.__metadata.uri,
    type: "POST",
    contentType: "application/json;odata=verbose",
    data: JSON.stringify(item),
    headers: {
    "Accept": "application/json;odata=verbose",
    "X-RequestDigest": $("#__REQUESTDIGEST").val(),
    "X-HTTP-Method": "MERGE",
    "If-Match": data.__metadata.etag
    success: function (data) { success(data, callBackIndex, null) },
    error: function (data) {
    getError(data);
    }, function (data) {
    failure(data);
    the error i get in ULS log is:
    Original error: Microsoft.SharePoint.Client.InvalidClientQueryException: The parameter __metadata does not exist in method GetItemByStringId.
    at Microsoft.SharePoint.Client.MethodInformation.GetParameter(String parameterName)
    at Microsoft.SharePoint.Client.ClientCallableEdmModelBuilder.CreateFunctionImportForMethodBodyParser(MethodInformation clientMethod, List`1 parameterNames, ProxyContext proxyContext)
    at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.ParseParametersFromBody(MethodInformation methodInfo, Boolean allowPostBodyAccess, Boolean isLeafSegment, ClientValueCollection args)
    at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.ParseParametersFromBodyOrQueryString(MethodInformation methodInfo, Boolean allowPostBodyAccess, Boolean isLeafSegment, ClientValueCollection args)
    at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.CreateMethodArgumentsUsingNamedParameters(MethodInformation methodInfo, IList`1 parameterList, Boolean isLeafSegment, Boolean allowPostBodyAccess)
    at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.InvokeMethod(Boolean mainRequestPath, Object value, ServerStub serverProxy, EdmParserNode node, Boolean resourceEndpoint, MethodInformation methodInfo, Boolean isExtensionMethod, Boolean isIndexerMethod)
    at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.GetObjectFromPathMember(Boolean mainRequestPath, String path, Object value, EdmParserNode node, Boolean resourceEndpoint, MethodInformation& methodInfo)
    at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.GetObjectFromPath(Boolean mainRequestPath, String path, String pathForErrorMessage)
    at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.Process()
    at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.ProcessRequest()
    at Microsoft.SharePoint.Client.Rest.RestService.ProcessQuery(Stream inputStream, IList`1 pendingDisposableContainer)
    Any help?
    Somebody?
    Thanks

    Hi patrik
    Really appreciate your replying.
    Could you try and refer to the issues below:
     this error occurs even with site collection administrator (i tested it with three different
    users)
    there isnt any difference between items in list - all have same permissions
    it occurs in several lists in site (all lists have same permissions)
    if browsing inside the LAN everything works just fine
    updating from the UI works fine in all means
    It really seems like a Rest related problem(is there anyone from the Microsoft REST team who can take look at this error?)
    Thanks
    Hushay

  • Create Multiple tasks for Single Item in List using state machine workflow in sharepoint

    Hi,
    I want to create multiple create tasks for Single Item in List based on Assigned to column using state machine Workflow through visual studio
    Here Assigned to column allows multiple users. so i have to create task for every user based on column .
    I'm trying for this but i didn't got any solution
    Please provide solution for this.

    Hi,
    According to your post, my understanding is that you wanted to allow multiple users to approve.
    There are some articles about creating parallel tasks in state machine workflow, you can have a look at them.
    http://www.codeproject.com/Articles/477849/Create-Parallel-Task-in-State-Machine-Workflow-in
    http://msdn.microsoft.com/en-us/library/office/hh128697(v=office.14).aspx
    http://social.technet.microsoft.com/Forums/office/en-US/b16ee858-4360-479a-a686-4ee35b7be9db/sharepoint-2010-workflow-creating-multiple-tasks?forum=sharepointdevelopmentprevious
    Thanks & Regards,
    Jason
    Jason Guo
    TechNet Community Support

  • Problem while Sending data concurrently using Evsnd function.

    Hi All,
    i am trying to send data from input schudule using evsnd function.
    As per a test scenerio.
    User 1: one user( cantains all bas members) , opens the input schudule  , waits for and hour  and do planning for few basmemebers and  then submit the data.
    User 2:another user ( subset of all base members) ,opens input schudule  ,do planning and submits the data.
    Now when  user 1 Sumits the data , it overwrites the value of user 2.
    is there is any way by which we can restrict user 1 of sending those value only that he/she  changed.
    Edited by: Tapeshwar Singh Bagal on Mar 11, 2009 11:02 AM

    First, I'd strongly encourage you to use EVDRE instead of EVSND, as it gives a lot better control over many aspects of the input schedule.
    As to your point, EVDRE definitely will only send back to the server the cells which have changed. It's been a few releases since I used EVSND (and its behavior may have changed some in the meantime), but if I recall correctly, it also does some of this same checking.
    Another option to consider is to make the input schedule smaller (fewer accounts or entities or products or whatever your dimensions), and split it into two pieces, one for each of the business processes that the 2 users are performing.
    If the 2 users are maintaining the same intersection of data, and performing the same business process (acting as a team, for example) then BPC has limited ability to support "checking out for edit" or locking the data for one user, in a way that prevents another user from changing it. The "park n go" feature does this in a way, but it's something that the user needs to do intentionally. That doesn't sound like your User 1 scenario of waiting for an hour before submitting -- probably when they opened it up, they thought it would only take 2 minutes, but then the phone rang, and then an email.... and then finally they finish it an hour or 8 later.

  • After adding fields on KNA1 using append structure, not null dn't work

    Hello, all.
    let me ask you something.
    after adding fields on standard table 'KNA1' using append structure, not null , default value doesn't work.
    when I check table using data object check(utilities > data object > check),  the report says like this.
    Fld name  Position Data Type     Length Decimals Not null  Default
    MANDT    1            VARCHAR2 9                           X           '000'
    KUNNR    2            VARCHAR2 30                         X            ' '
    LAND1    3            VARCHAR2 9                           X            ' '
    ZMBRN   178        VARCHAR2 30                          X            ' '
    ZKUNNR 179        VARCHAR2 30      
    ZSEQ     180         VARCHAR2 12      
    fields ZKUNNR, ZSEQ  doesn't check not null, default.
    Any advice will help.
    thank in advance.

    Using 'initial values' check at SE11, I can explicitly make a filed not null.
    but when I use append structure, there is no way for checking 'initial values' check at SE11.
    thanks anyway.

  • Using Back button causes Null Pointer exception

    Hi,
    I have done some customization by extending the seeded Controller on a Page.I have altered the View query and executed it again dynamically as its not a static query.
    There is a functionality called compare which directs the users to a page from the page I have customised the controller.
    If the user uses the back button to return to the previous page it is giving a Null Pointer exception.
    Also refresh button causes a similar Null Pointer exception on the customised controller page.
    can anybody throw some light?
    Also is there a way to disable the back and refresh button on the page?

    Is the control entering the back button code in process request in your CO? Have you confirmed this by putting some debug comments?It many be that this error might being from the code where you have handled back button.
    Put debugging comments and check.
    --Mukul                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Problem - Adding item using wwsbr_api.add_item

    Hi, I´m using portal 10.1.2.0.2 and when I try to add an file using wwsbr_api.add_item, it returns me the following error "ORA-29532: Java call terminated by uncaught Java exception: java.lang.NullPointerException"
    But It happens only when the file name has special caracter.
    Anybody has any idea how to solve it?

    You mentioned at the top of the thread that the region type had not been defined. I have not tried this in 10.1.4, but I know in previous versions if you programmatic ally added a item to an undefined region it didn't show up until that region was manually configured as an item region. The symptoms were as you describe -- nothing showed up in edit or view mode. As soon as the region was setup as a item region, the items appeared.
    Roche's suggestion will establish if the item is even being created at all.
    Rgds/Mark M.

  • Problems adding my Epson C1100 using Bonjour

    Hi all,
    I have my APE running perfectly and my printers also perfectly running. Last week I had to shut down my network because I am rebuilding my studio. I kept on working on my MAC but deleted my printer.
    Right now I need the printer and I try to add it. Bonjour fond the printer and everything, but when I klik add I get the "beachball". I am waiting now for 8 hrs and stil no printer is added.
    On my Windows machine evrything works just fine!
    So what is the problem?? How do I get my printer working on my MAC?

    I jusr like to add that I am running OS 10.4.4 on a iMac G5 and trying to print to an Epson C1100.
    I can use the printer setup utility to set up and print to this printer just fine when it is direct connected via USB.
    However, when I try to add this same printer via Bonjour hooked up to an airport express, print setup utility sees the printer just fine, indicates that it is connected to my airport, and detects the drivers (the "Print Using" drop down list in the add printer dialog box, after waiting for a period.
    I installed the drivers again, old and new ones. Still nothing. I also downgaded my firmware of APE to 6.1.1, still nothing. Also back to 6.3 doesn't help out.
    The worst is that it worked a fewe weeks ago. When I unplugged my APE for a while and went back to work and tried to add my printer this all happened!
    I'm about to tear my hair out...

  • Problem ADDING ITEM

    Hello there!!!
    I am having problems trying to add a new item in a content area, the following error pop up:
    ORA-01403: no data found
    ORA-06512: at "PORTAL.WWV_ADDITEM", line 270
    ORA-06512: at line 7
    DAD name: portal
    PROCEDURE : PORTAL.wwv_additem.additem
    URL : http://PORTAL:80/pls/portal/PORTAL.wwv_additem.additem
    PARAMETERS :
    ============
    P_THINGID:
    P_SEQ:
    P_LANGUAGE:
    us
    P_SITEID:
    94
    P_CURRCORNERID:
    4210
    P_SETTINGSSETID:
    1
    P_PARENTID:
    this happens once i try to define the item type (moving toward step 2 in the wizard).
    I will appreciate any help.
    null

    Jose,
    The upgrade scripts are available on technet at http://technet.oracle.com/support/products/iportal/listing.htm .
    You first need to upgrade the Early Adopter Release to 3.0.6. You should then upgrade to the latest release (3.0.8). Any patches you have will be included in the upgrade.
    Regards,
    Jerry

  • Count of items ina list using CAML Query

    Hi,
    Thanks in Advance
    I'm using an app called blumshapiro to customize the tile in sharepoint 2013, I also have a requirement of getting the item count from the list which can be done by writing a CAML Query. Can anyone please assist me with the syntax to fetch the item count
    in caml Query.
    Regards,
    Niranjan

    Hi 
    There is nothing like item count in Camel query.You can get Required result using SPListItemCollection.Count
    Do a normal where clause having condition.
    SPQuery query = new SPQuery();
    string camlquery = @"<Query>
    <Where>
    <Eq>
    <FieldRef Name='Vendor_x0020_Product_x0020_Name'/>
    <Value Type='Text'>" + xpathresultBTADSLMAX + @"</Value>
    </Eq>
    </Where>
    </Query>";
    query.Query = camlquery;
    SPListItemCollection listItemCollection = list.GetItems(query);int count=0;if(listItemCollection !=null) { count=ListItemCollection.Count}MSDN reference
    http://msdn.microsoft.com/en-us/library/ms467521.aspx
    Regards, Rajendra Singh If a post answers your question, please click Mark As Answer on that ost and Vote as Helpful http://sharepointundefind.wordpress.com/

  • Problem adding NAS quorum device using scconf with RSH disabled on filer

    Hi,
    we are having problems to configure a quorum device via scconf.
    /usr/cluster/bin/scconf -a -q name=XXXdc00xp1,type=netapp_nas,filer=XXX607ap fails with
    scconf: Failed to add quorum device (XXX00xp1) - invalid quorum configuration.
    scconf: Unable to communicate with filer "XXX607ap".
    using snoop i realized that scconf is trying to configure the quorum using rsh. as our filer is only accessible via http and ssh - i have no idea how to configure a quorum using the standard methods described in the documentation provided by sun.
    the documents only state that we need http administrative access - which is available.
    any ideas ???
    thankd,
    chris

    Hi Christian,
    this should be a bug. If you send me some more customer details offline, I can add them to the bug and make sure this gets fixed.
    The workaround should be (according to well informed sources):
    on filer do:
    options rsh.enable on
    do scconf to add quorum and then
    options rsh.enable off on filer
    This has been tested and found to work. If it does not let us know.
    Regards
    Hartmut

  • Using JOIN Function with NULL Dynamic Parameters

    I have a report with utilizes dynamic parameters but will not run if any of the parameters are null.  I am also using the JOIN function to print out the values of these parameters. If the user doesn't enter in all the parameters, can the report still run?

    Hi eburton 
    In CR 2008 we have optional parameter functionality, this will allow the report to run without parameter values.
    If you are not using CR2008 then the functionality is not available.
    Thanks,
    Sastry

  • (SOLVED)Problem to recover backup created using mysqldump, shows error

    I use this command to restore:
    mysql -u root -ppasswd db1 < /media/wd1500GB/backup/mysql/db1_2014-03-28.sql
    Shows this error:
    ERROR 1050 (42S01) at line 25: Table '`db1`.`phpbb_acl_groups`' already exists
    Mysql is running.
    What can be wrong? thanks
    Last edited by rado3105 (2014-03-31 09:02:32)

    Please remember to mark the thread as solved https://bbs.archlinux.org/viewtopic.php?id=130309

Maybe you are looking for

  • Error when creating Service for transaction in SICF.

    Hi, I created a Transaction, and for this transaction transaction I am trying to create a service for this transaction using SICF transaction. but after creagting service when I am doing test service I am gettging error follwoing message - can any on

  • Webservice with HTTPS in PI 7.1

    Hello, I am doing a scenario where the an sender application will publish the data to webservice at PI. It will use HTTPS without client authantication. I generated the WSDL from the sender agrrement and tried testing the interface using Altova. Thou

  • Password protected iWeb sites - problem with login

    This is an FYI regarding a problem I recently encountered. Neither MobileMe, nor Apple tech support or specialists were able to resolve it, but I finally figured it out. I created a company website for my client, including secondary websites that wer

  • Failed to bring up UDS Control Panel

    Hi, I have installed FORTE-UDS 5.0.3 on a Windows 2000 professional machine. The problem is, when I tried to bring up the UDS Control Panel, I see the start up screen flashed by and nothing happened. From the DOS prompted, I manually invoked the comm

  • Pro's and Con's between Mag+ and DPS

    What are some Pro's & Con's between Mag+ and Adobe DPS? Do they both have the same features, is one easier to use vs the other?