Get_previous_data from process_item, class IF_PURCHASE_ORDER_ITEM_MM

Hi everyone,
I'm new to the use of BADI's and classes in general. I'm using BADI IF_PURCHASE_ORDER_ITEM_MM, and under process_item, I want to use the method get_previous_data. But whenever it's the first time that the method is called (and when there's no previous data, the system generates a runtime error, NO_DATA. I tried to catch this with a try, catch statement, but it isn 't working. Here's my code :
TRY.
          CALL METHOD im_item->get_previous_data
            IMPORTING
              ex_data = ls_prev_mepoitem.
          lv_matn = ls_prev_mepoitem-matnr.
        CATCH no_data INTO oref.
          text = oref->get_text( ).
      ENDTRY.
I'm doing something wrong, but what...

solved, used the user exit instead

Similar Messages

  • Compilation error while calling static method from another class

    Hi,
    I am new to Java Programming. I have written two class files Dummy1 and Dummy2.java in the same package Test.
    In Dummy1.java I have declared a static final variable and a static method as you can see it below.
    package Test;
    import java.io.*;
    public class Dummy1
    public static final int var1= 10;
    public static int varDisp(int var2)
    return(var1+var2);
    This is program is compiling fine.
    I have called the static method varDisp from the class Dummy2 and it is as follows
    package Test;
    import java.io.*;
    public class Dummy2
    public int var3=15;
    public int test=0;
    test+=Dummy1.varDisp(var3);
    and when i compile Dummy2.java, there is a compilation error <identifier > expected.
    Please help me in this program.

    public class Dummy2
    public int var3=15;
    public int test=0;
    test+=Dummy1.varDisp(var3);
    }test+=Dummy1.varDisplay(var3);
    must be in a method, it cannot just be out somewhere in the class!

  • Error while deploying web service from Java class

    Hi,
    I have a simple java class which I want to deploy as web service with some methods in the Java class as web service operations.
    How to do this in Jdev 11g?
    Is there any good detailed tutorial on this?
    I just created an web service from the class and went for deployment in Weblogic.
    This resulted in Illegal Annotation Exception as shown below.
    Please help!!
    Regards,
    Sam
    [Deployer:149034]An exception occurred for task [Deployer:149026]deploy application WorklistWebService-CustomWorklist-context-root on SOA_Cluster.: [HTTP:101216]Servlet: "CustomWorkListUtilSoap12HttpPort" failed to preload on startup in Web application: "WorklistWebService-CustomWorklist-context-root.war".
    javax.xml.ws.WebServiceException: Unable to create JAXBContext
    at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:164)
    at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:94)
    at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:281)
    at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:363)
    at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:202)
    at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:496)
    at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:539)
    at weblogic.wsee.jaxws.JAXWSDeployedServlet.getEndpoint(JAXWSDeployedServlet.java:183)
    at weblogic.wsee.jaxws.JAXWSServlet.registerEndpoint(JAXWSServlet.java:135)
    at weblogic.wsee.jaxws.JAXWSServlet.init(JAXWSServlet.java:64)
    at weblogic.wsee.jaxws.JAXWSDeployedServlet.init(JAXWSDeployedServlet.java:55)
    at javax.servlet.GenericServlet.init(GenericServlet.java:242)
    at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
    at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
    at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
    at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539)
    at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1985)
    at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1959)
    at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1878)
    at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3154)
    at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508)
    at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:485)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:427)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
    at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
    at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:201)
    at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:249)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:427)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
    at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
    at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:28)
    at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:637)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
    at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:205)
    at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:43)
    at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844)
    at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440)
    at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:164)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:69)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    Caused by: java.security.PrivilegedActionException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
    java.lang.StackTraceElement does not have a no-arg default constructor.
    this problem is related to the following location:
    at java.lang.StackTraceElement
    at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
    at java.lang.Throwable
    at public java.lang.Throwable com.gehc.util.jaxws.WorkflowExceptionBean.rootCause
    at com.gehc.util.jaxws.WorkflowExceptionBean
    at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:151)
    at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:95)
    ... 51 more
    Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
    java.lang.StackTraceElement does not have a no-arg default constructor.
    this problem is related to the following location:
    at java.lang.StackTraceElement
    at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
    at java.lang.Throwable
    at public java.lang.Throwable com.gehc.util.jaxws.WorkflowExceptionBean.rootCause
    at com.gehc.util.jaxws.WorkflowExceptionBean
    at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:478)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:308)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1149)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:169)
    at com.sun.xml.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:160)
    at com.sun.xml.ws.developer.JAXBContextFactory$1.createJAXBContext(JAXBContextFactory.java:74)
    at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:159)
    at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:151)
    ... 53 more
    :com.sun.xml.bind.v2.runtime.IllegalAnnotationsException:1 counts of IllegalAnnotationExceptions.
    [08:44:23 PM] Weblogic Server Exception: weblogic.application.ModuleException: [HTTP:101216]Servlet: "CustomWorkListUtilSoap12HttpPort" failed to preload on startup in Web application: "WorklistWebService-CustomWorklist-context-root.war".
    javax.xml.ws.WebServiceException: Unable to create JAXBContext
    at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:164)
    at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:94)
    at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:281)
    at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:363)
    at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:202)
    at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:496)
    at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:539)
    at weblogic.wsee.jaxws.JAXWSDeployedServlet.getEndpoint(JAXWSDeployedServlet.java:183)
    at weblogic.wsee.jaxws.JAXWSServlet.registerEndpoint(JAXWSServlet.java:135)
    at weblogic.wsee.jaxws.JAXWSServlet.init(JAXWSServlet.java:64)
    at weblogic.wsee.jaxws.JAXWSDeployedServlet.init(JAXWSDeployedServlet.java:55)
    at javax.servlet.GenericServlet.init(GenericServlet.java:242)
    at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
    at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
    at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
    at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539)
    at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1985)
    at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1959)
    at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1878)
    at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3154)
    at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508)
    at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:485)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:427)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
    at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
    at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:201)
    at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:249)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:427)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
    at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
    at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:28)
    at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:637)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
    at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:205)
    at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:43)
    at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844)
    at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440)
    at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:164)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:69)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    Caused by: java.security.PrivilegedActionException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
    java.lang.StackTraceElement does not have a no-arg default constructor.
    this problem is related to the following location:
    at java.lang.StackTraceElement
    at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
    at java.lang.Throwable
    at public java.lang.Throwable com.gehc.util.jaxws.WorkflowExceptionBean.rootCause
    at com.gehc.util.jaxws.WorkflowExceptionBean
    at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:151)
    at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:95)
    ... 51 more
    Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
    java.lang.StackTraceElement does not have a no-arg default constructor.
    this problem is related to the following location:
    at java.lang.StackTraceElement
    at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
    at java.lang.Throwable
    at public java.lang.Throwable com.gehc.util.jaxws.WorkflowExceptionBean.rootCause
    at com.gehc.util.jaxws.WorkflowExceptionBean
    at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:478)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:308)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1149)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:169)
    at com.sun.xml.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:160)
    at com.sun.xml.ws.developer.JAXBContextFactory$1.createJAXBContext(JAXBContextFactory.java:74)
    at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:159)
    at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:151)
    ... 53 more
    :com.sun.xml.bind.v2.runtime.IllegalAnnotationsException:1 counts of IllegalAnnotationExceptions
    [08:44:23 PM] Caused by: java.lang.Throwable: Substituted for the exception java.security.PrivilegedActionException which lacks a String contructor, original message - com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
    java.lang.StackTraceElement does not have a no-arg default constructor.
    this problem is related to the following location:
    [08:44:23 PM] See server logs or server console for more details.
    [08:44:23 PM] weblogic.application.ModuleException: [HTTP:101216]Servlet: "CustomWorkListUtilSoap12HttpPort" failed to preload on startup in Web application: "WorklistWebService-CustomWorklist-context-root.war".
    javax.xml.ws.WebServiceException: Unable to create JAXBContext
    at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:164)
    at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:94)
    at com.sun.xml.ws.model.RuntimeModeler.buildRuntimeModel(RuntimeModeler.java:281)
    at com.sun.xml.ws.server.EndpointFactory.createSEIModel(EndpointFactory.java:363)
    at com.sun.xml.ws.server.EndpointFactory.createEndpoint(EndpointFactory.java:202)
    at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:496)
    at com.sun.xml.ws.api.server.WSEndpoint.create(WSEndpoint.java:539)
    at weblogic.wsee.jaxws.JAXWSDeployedServlet.getEndpoint(JAXWSDeployedServlet.java:183)
    at weblogic.wsee.jaxws.JAXWSServlet.registerEndpoint(JAXWSServlet.java:135)
    at weblogic.wsee.jaxws.JAXWSServlet.init(JAXWSServlet.java:64)
    at weblogic.wsee.jaxws.JAXWSDeployedServlet.init(JAXWSDeployedServlet.java:55)
    at javax.servlet.GenericServlet.init(GenericServlet.java:242)
    at weblogic.servlet.internal.StubSecurityHelper$ServletInitAction.run(StubSecurityHelper.java:283)
    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
    at weblogic.servlet.internal.StubSecurityHelper.createServlet(StubSecurityHelper.java:64)
    at weblogic.servlet.internal.StubLifecycleHelper.createOneInstance(StubLifecycleHelper.java:58)
    at weblogic.servlet.internal.StubLifecycleHelper.<init>(StubLifecycleHelper.java:48)
    at weblogic.servlet.internal.ServletStubImpl.prepareServlet(ServletStubImpl.java:539)
    at weblogic.servlet.internal.WebAppServletContext.preloadServlet(WebAppServletContext.java:1985)
    at weblogic.servlet.internal.WebAppServletContext.loadServletsOnStartup(WebAppServletContext.java:1959)
    at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAppServletContext.java:1878)
    at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletContext.java:3154)
    at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.java:1508)
    at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:485)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:427)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
    at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
    at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedModuleDriver.java:201)
    at weblogic.application.internal.flow.ModuleListenerInvoker.start(ModuleListenerInvoker.java:249)
    at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleStateDriver.java:427)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
    at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStateDriver.java:119)
    at weblogic.application.internal.flow.StartModulesFlow.activate(StartModulesFlow.java:28)
    at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.java:637)
    at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:52)
    at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.java:205)
    at weblogic.application.internal.SingleModuleDeployment.activate(SingleModuleDeployment.java:43)
    at weblogic.application.internal.DeploymentStateChecker.activate(DeploymentStateChecker.java:161)
    at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(AppContainerInvoker.java:79)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.activate(AbstractOperation.java:569)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.activateDeployment(ActivateOperation.java:150)
    at weblogic.deploy.internal.targetserver.operations.ActivateOperation.doCommit(ActivateOperation.java:116)
    at weblogic.deploy.internal.targetserver.operations.AbstractOperation.commit(AbstractOperation.java:323)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploymentCommit(DeploymentManager.java:844)
    at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeploymentList(DeploymentManager.java:1253)
    at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(DeploymentManager.java:440)
    at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.commit(DeploymentServiceDispatcher.java:164)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
    at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallbackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:69)
    at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:528)
    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)
    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)
    Caused by: java.security.PrivilegedActionException: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
    java.lang.StackTraceElement does not have a no-arg default constructor.
    this problem is related to the following location:
    at java.lang.StackTraceElement
    at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
    at java.lang.Throwable
    at public java.lang.Throwable com.gehc.util.jaxws.WorkflowExceptionBean.rootCause
    at com.gehc.util.jaxws.WorkflowExceptionBean
    at com.sun.xml.ws.model.AbstractSEIModelImpl.createJAXBContext(AbstractSEIModelImpl.java:151)
    at com.sun.xml.ws.model.AbstractSEIModelImpl.postProcess(AbstractSEIModelImpl.java:95)
    ... 51 more
    Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions
    java.lang.StackTraceElement does not have a no-arg default constructor.
    this problem is related to the following location:
    at java.lang.StackTraceElement
    at public java.lang.StackTraceElement[] java.lang.Throwable.getStackTrace()
    at java.lang.Throwable
    at public java.lang.Throwable com.gehc.util.jaxws.WorkflowExceptionBean.rootCause
    at com.gehc.util.jaxws.WorkflowExceptionBean
    at com.sun.xml.bind.v2.runtime.IllegalAnnotationsException$Builder.check(IllegalAnnotationsException.java:102)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getTypeInfoSet(JAXBContextImpl.java:478)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.<init>(JAXBContextImpl.java:308)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1149)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:169)
    at com.sun.xml.bind.api.JAXBRIContext.newInstance(JAXBRIContext.java:160)
    at com.sun.xml.ws.developer.JAXBContextFactory$1.createJAXBContext(JAXBContextFactory.java:74)
    at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:159)
    at com.sun.xml.ws.model.AbstractSEIModelImpl$1.run(AbstractSEIModelImpl.java:151)
    ... 53 more
    :com.sun.xml.bind.v2.runtime.IllegalAnnotationsException:1 counts of IllegalAnnotationExceptions
    [08:44:23 PM] #### Deployment incomplete. ####
    [08:44:23 PM] Remote deployment failed (oracle.jdevimpl.deploy.common.Jsr88RemoteDeployer)

    javax.xml.ws.WebServiceException: Unable to create JAXBContext
    Webservice:  Unable to create JAXBContext
    javax.xml.ws.WebServiceException: Unable to create JAXBContext
    http://naive-amseth.blogspot.ca/2010/06/error-unable-to-create-jaxbcontext.html

  • Problem getting arraylist from another class

    I am trying to call information about an arraylist from another class. I am using this code to call the size of an arraylist:
    import java.io.*;
    public class Test
        public static void main(String argv[]) throws IOException
    Echo03 thing = new Echo03();
    int y=thing.value();
    System.out.println(y);
    Echo03 thing2 = new Echo03();
    int x=thing2.percent.size();
    System.out.println(x);
    }from another file which starts like this:
    public class Echo03 extends DefaultHandler
    static ArrayList<String> percent = new ArrayList<String>();
    static ArrayList<String> text = new ArrayList<String>();
      int a;
    public int value(){
         return percent.size();
      public static void main(String argv[]) throws IOException
        {The second file is based on an example piece of code from the Java website. I havent posted the whole thing, but if it is relevant then please ask.
    Anyway when I run Echo03 by itself, the arraylist has a size of 2. But when I run it from the Test file, it says a size of 0. Is this because the data is not being transferred between the classes? Or is the Echo03 program not executing (and hence the arraylist is not filling up)?
    How can I fix this? I have tried 2 ways of calling the data (As seen in my Test file). Neither work.

    I didnt post the full bit of the code for the second one. Here it is:
    import java.io.*;
    import org.xml.sax.*;
    import org.xml.sax.helpers.DefaultHandler;
    import javax.xml.parsers.SAXParserFactory;
    import javax.xml.parsers.ParserConfigurationException;
    import javax.xml.parsers.SAXParser;
    import java.util.ArrayList;
    import java.awt.*;
    import javax.swing.*;
    public class Echo03 extends DefaultHandler
    static ArrayList<String> percent = new ArrayList<String>();
    static ArrayList<String> text = new ArrayList<String>();
      int a;
      public static void main(String argv[]) throws IOException
            if (argv.length != 1) {
                System.err.println("Usage: cmd filename");
                System.exit(1);
            // Use an instance of ourselves as the SAX event handler
            DefaultHandler handler = new Echo03();
            // Use the default (non-validating) parser
            SAXParserFactory factory = SAXParserFactory.newInstance();
            try {
                // Set up output stream
       out = new OutputStreamWriter(System.out, "UTF8");
                // Parse the input
                SAXParser saxParser = factory.newSAXParser();
                saxParser.parse( new File(argv[0]), handler);
    for (int b=0; b<percent.size();b++){
         System.out.println(percent.get(b+1));
            } catch (Throwable t) {
            System.exit(0);
        static private Writer  out;
        public void startElement(String namespaceURI,
                                 String lName, // local name
                                 String qName, // qualified name
                                 Attributes attrs)
        throws SAXException
            if (attrs != null) {
    StringBuffer sb = new StringBuffer (250);        
    for (int i = 0; i < attrs.getLength(); i++) {
                    nl();
                    emit(attrs.getValue(i));
              sb.append (attrs.getValue(i));
    String sf = sb.toString ();
    percent.add(sf);
    System.out.println(" String: "+sf); a++;
        public void characters(char buf[], int offset, int len)
        throws SAXException
             emit(" ");
            String s = new String(buf, offset, len);
            if (!s.trim().equals("")) {text.add(s); emit(s);}
    //===========================================================
        // Utility Methods ...
        //===========================================================
        // Wrap I/O exceptions in SAX exceptions, to
        // suit handler signature requirements
        private void emit(String s)
        throws SAXException
            try {
                out.write(s);
                out.flush();
            } catch (IOException e) {
                throw new SAXException("I/O error", e);
        // Start a new line
        private void nl()
        throws SAXException
            String lineEnd =  System.getProperty("line.separator");
            try {
                out.write(lineEnd);
            } catch (IOException e) {
                throw new SAXException("I/O error", e);
    }

  • How can I assign image file name from Main() class

    I am trying to create library class which will be accessed and used by different applications (with different image files to be assigned). So, what image file to call should be determined by and in the Main class.
    Here is the Main class
    import org.me.lib.MyJNIWindowClass;
    public class Main {
    public Main() {
    public static void main(String[] args) {
    MyJNIWindowClass mw = new MyJNIWindowClass();
    mw.s = "clock.gif";
    And here is the library class
    package org.me.lib;
    public class MyJNIWindowClass {
    public String s;
    ImageIcon image = new ImageIcon("C:/Documents and Settings/Administrator/Desktop/" + s);
    public MyJNIWindowClass() {
    JLabel jl = new JLabel(image);
    JFrame jf = new JFrame();
    jf.add(jl);
    jf.setVisible(true);
    jf.pack();
    I do understand that when I am making reference from main() method to MyJNIWindowClass() s first initialized to null and that is why clock could not be seen but how can I assign image file name from Main() class for library class without creating reference to Main() from MyJNIWindowClass()? As I said, I want this library class being accessed from different applications (means different Main() classes).
    Thank you.

    Your problem is one of timing. Consider this simple example.
    public class Example {
        public String s;
        private String message = "Hello, " + s;
        public String toString() {
            return message;
        public static void main(String[] args) {
            Example ex = new Example();
            ex.s = "world";
            System.out.println(ex.toString());
    }When this code is executed, the following happens in order:
    1. new Example() is executed, causing an object to constructed. In particular:
    2. field s is given value null (since no value is explicitly assigned.
    3. field message is given value "Hello, null"
    4. Back in method main, field s is now given value "world", but that
    doesn't change message.
    5. Finally, "Hello, null" is output.
    The following fixes the above example:
    public class Example {
        private String message;
        public Example(String name) {
            message = "Hello, " + name;
        public String toString() {
            return message;
        public static void main(String[] args) {
            Example ex = new Example("world");
            System.out.println(ex.toString());
    }

  • How do i use objects from one class in anohter?

    Hey
    I have two GUI classes ShowWhiteGUI and BasketGUI and then a control class ShowWhite. The control class calls all the method from anohter class's which the GUI classes are gonna use.
    The basis idea with this script is it shall be a very very simpel Shop. Where you can add items to a basket and then show the items in a new window(BasketGUI).
    So here is the problem. I cant create an object in both GUI classes, because then im working with two sets of data, right? So how do i do this?
    Here is my code:
    ShowWhiteGUI
    * ShowWhiteGUI.java
    * Created on 5. februar 2008, 10:43
    package userclasses;
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.*;
    * @author  Lille mus
    public class ShowWhiteGUI extends javax.swing.JFrame {
        private BasketGUI basketGUI;
        private ShowWhite control;
        /** Creates new form ShowWhiteGUI */
        public ShowWhiteGUI() {
            basketGUI = new BasketGUI();
            control = new ShowWhite();
            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.
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
        private void initComponents() {
            aboutDialog = new javax.swing.JDialog();
            jLabel1 = new javax.swing.JLabel();
            jScrollPane1 = new javax.swing.JScrollPane();
            jTextArea1 = new javax.swing.JTextArea();
            itemIdField = new javax.swing.JTextField();
            productIdLabel = new javax.swing.JLabel();
            numberOfItems = new javax.swing.JLabel();
            productId = new javax.swing.JTextField();
            basketButton = new javax.swing.JButton();
            jLabel2 = new javax.swing.JLabel();
            showBasketButton = new javax.swing.JButton();
            jMenuBar1 = new javax.swing.JMenuBar();
            menu = new javax.swing.JMenu();
            jMenu1 = new javax.swing.JMenu();
            open = new javax.swing.JMenuItem();
            quit = new javax.swing.JMenuItem();
            jMenuItem1 = new javax.swing.JMenuItem();
            jMenu2 = new javax.swing.JMenu();
            help = new javax.swing.JMenuItem();
            about = new javax.swing.JMenuItem();
            javax.swing.GroupLayout aboutDialogLayout = new javax.swing.GroupLayout(aboutDialog.getContentPane());
            aboutDialog.getContentPane().setLayout(aboutDialogLayout);
            aboutDialogLayout.setHorizontalGroup(
                aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 400, Short.MAX_VALUE)
            aboutDialogLayout.setVerticalGroup(
                aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 300, Short.MAX_VALUE)
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("Show White's Shop");
            setBackground(new java.awt.Color(0, 102, 255));
            jLabel1.setFont(new java.awt.Font("Baby Kruffy", 0, 36));
            jLabel1.setText("Snow White?s Shop");
            jTextArea1.setColumns(20);
            jTextArea1.setEditable(false);
            jTextArea1.setRows(5);
            jTextArea1.setText(control.getPrintAllStockItems());
            jScrollPane1.setViewportView(jTextArea1);
            productIdLabel.setText("Varenummer:");
            numberOfItems.setText("Antal:");
            basketButton.setText("L?g i kurv");
            basketButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    putInBasket(evt);
            showBasketButton.setText("Vis indk?bskurv");
            showBasketButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    showBasket(evt);
            menu.setLabel("Fil");
            jMenu1.setText("Menu");
            menu.add(jMenu1);
            open.setLabel("?bn");
            open.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    open(evt);
            menu.add(open);
            quit.setLabel("Luk");
            quit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    quit(evt);
            menu.add(quit);
            jMenuItem1.setLabel("Gem");
            jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    save(evt);
            menu.add(jMenuItem1);
            jMenuBar1.add(menu);
            jMenu2.setLabel("Hj?lp");
            help.setLabel("Hj?lp");
            help.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    help(evt);
            jMenu2.add(help);
            about.setLabel("Om Show White Shop");
            jMenu2.add(about);
            jMenuBar1.add(jMenu2);
            setJMenuBar(jMenuBar1);
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(37, 37, 37)
                            .addComponent(jLabel1))
                        .addGroup(layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(productIdLabel)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(numberOfItems))
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(productId, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 65, Short.MAX_VALUE)
                                        .addComponent(basketButton))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(31, 31, 31)
                                        .addComponent(jLabel2)))
                                .addGroup(layout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(showBasketButton)))))
                    .addContainerGap())
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel2))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(productIdLabel)
                                .addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(numberOfItems)
                                .addComponent(productId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(showBasketButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 202, Short.MAX_VALUE)
                            .addComponent(basketButton)))
                    .addContainerGap())
            pack();
        }// </editor-fold>                       
        public void createBasketWindow(){
            basketGUI.setVisible(true);
        private void showBasket(java.awt.event.ActionEvent evt) {                           
            createBasketWindow();
        private void putInBasket(java.awt.event.ActionEvent evt) {                            
            Integer itemId = Integer.parseInt(itemIdField.getText());
            String petToAdd = control.getFindItem(itemId);
            System.out.println(petToAdd);
            control.setAddItemToBasket(itemId);
            basketGUI.addPetToBasket(petToAdd);     
        private void help(java.awt.event.ActionEvent evt) {                     
        private void save(java.awt.event.ActionEvent evt) {                     
            System.out.println("Gemmer fil");
        private void open(java.awt.event.ActionEvent evt) {                     
            System.out.println("?bn fil");
        private void quit(java.awt.event.ActionEvent evt) {                     
            System.exit(0);
        public ShowWhite getControl(){
            return control;
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new ShowWhiteGUI().setVisible(true);
        // Variables declaration - do not modify                    
        private javax.swing.JMenuItem about;
        private javax.swing.JDialog aboutDialog;
        private javax.swing.JButton basketButton;
        private javax.swing.JMenuItem help;
        private javax.swing.JTextField itemIdField;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JMenu jMenu1;
        private javax.swing.JMenu jMenu2;
        private javax.swing.JMenuBar jMenuBar1;
        private javax.swing.JMenuItem jMenuItem1;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JTextArea jTextArea1;
        private javax.swing.JMenu menu;
        private javax.swing.JLabel numberOfItems;
        private javax.swing.JMenuItem open;
        private javax.swing.JTextField productId;
        private javax.swing.JLabel productIdLabel;
        private javax.swing.JMenuItem quit;
        private javax.swing.JButton showBasketButton;
        // End of variables declaration                  
    }BasketGUI:
    * Basket.java
    * Created on 5. februar 2008, 15:29
    package userclasses;
    import javax.swing.JTextArea;
    * @author  Lille mus
    public class BasketGUI extends javax.swing.JFrame {
        private String newline = "\n";
        private InvoiceGUI invoiceGUI;
        /** Creates new form Basket */
        public BasketGUI() {       
            initComponents();
            //invoiceGUI = new InvoiceGUI();
        public void addPetToBasket(String pet){
            jTextArea1.append(pet+newline);
        /** 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.
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
        private void initComponents() {
            jLabel1 = new javax.swing.JLabel();
            jScrollPane1 = new javax.swing.JScrollPane();
            jTextArea1 = new javax.swing.JTextArea();
            jButton1 = new javax.swing.JButton();
            itemIdField = new javax.swing.JTextField();
            jLabel2 = new javax.swing.JLabel();
            removeItemButton = new javax.swing.JButton();
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("Indk?bskurv");
            jLabel1.setText("Indk?bskurv");
            jTextArea1.setColumns(20);
            jTextArea1.setRows(5);
            jScrollPane1.setViewportView(jTextArea1);
            jButton1.setText("K?b og print kvittering");
            jButton1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    printInvoice(evt);
            jLabel2.setText("Slet varenr");
            removeItemButton.setText("Slet");
            removeItemButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    removeItemFromBasket(evt);
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(21, 21, 21)
                            .addComponent(jLabel1))
                        .addGroup(layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 141, Short.MAX_VALUE)
                                    .addComponent(jButton1))
                                .addGroup(layout.createSequentialGroup()
                                    .addComponent(jLabel2)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(removeItemButton)))))
                    .addContainerGap())
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addContainerGap()
                    .addComponent(jLabel1)
                    .addGap(20, 20, 20)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(jButton1)
                        .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 125, Short.MAX_VALUE)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(jLabel2)
                        .addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(removeItemButton))
                    .addContainerGap())
            pack();
        }// </editor-fold>                       
        private void removeItemFromBasket(java.awt.event.ActionEvent evt) {                                     
            Integer itemId = Integer.parseInt(itemIdField.getText());
        private void printInvoice(java.awt.event.ActionEvent evt) {                             
            //invoiceGUI.setVisible(true);
        public JTextArea getTextArea(){
            return jTextArea1;
         * @param args the command line arguments
        public static void main(String args[]) {
            java.awt.EventQueue.invokeLater(new Runnable() {
                public void run() {
                    new BasketGUI().setVisible(true);
        // Variables declaration - do not modify                    
        private javax.swing.JTextField itemIdField;
        private javax.swing.JButton jButton1;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JTextArea jTextArea1;
        private javax.swing.JButton removeItemButton;
        // End of variables declaration                  
    }ShowWhite:
    * ShowWhite.java
    * Created on 13. februar 2008, 18:15
    * To change this template, choose Tools | Template Manager
    * and open the template in the editor.
    package userclasses;
    * @author Lille mus
    public class ShowWhite {
        public Basket basket;
        public Stock stock;
        /** Creates a new instance of ShowWhite */
        public ShowWhite() {
            stock = new Stock();
            basket = new Basket();
        public String getFindItem(int itemId){
            String returnItem = stock.findItem(itemId);
            return returnItem;
        public void setAddItemToBasket(int itemId){
            basket.addItemToBasket(itemId);
        public String getPrintAllStockItems(){
            return stock.printAllStockItems();
        public String getShowBasket(){
             return basket.showBasket();
        public void setRemoveItemFromBasket(int itemId){
            basket.removeItemFromBasket(itemId);
    }

    okay i tried this, but it give me a nullpointerexeption:
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at userclasses.ShowWhiteGUI.initComponents(ShowWhiteGUI.java:75)
    at userclasses.ShowWhiteGUI.<init>(ShowWhiteGUI.java:21)
    at userclasses.ShowWhite.<init>(ShowWhite.java:26)
    at userclasses.Main.<init>(Main.java:16)
    at userclasses.Main$1.run(Main.java:31)
    ShowWhite
    public class ShowWhite {
        public Basket basket;
        public Stock stock;
        private ShowWhiteGUI mainGUI;
        private BasketGUI basketGUI;
        /** Creates a new instance of ShowWhite */
        public ShowWhite() {
            stock = new Stock();
            basket = new Basket();
            mainGUI = new ShowWhiteGUI(this);
            basketGUI = new BasketGUI();
        public String getFindItem(int itemId){
            String returnItem = stock.findItem(itemId);
            return returnItem;
        public void setAddItemToBasket(int itemId){
            basket.addItemToBasket(itemId);
        public String getPrintAllStockItems(){
            return stock.printAllStockItems();
        public String getShowBasket(){
             return basket.showBasket();
        public void setRemoveItemFromBasket(int itemId){
            basket.removeItemFromBasket(itemId);
        public void createMainGUI(){
            mainGUI.setVisible(true);
        public BasketGUI getBasketGUI(){
            return basketGUI;
        public void setAddPetToBasket(String pet){
            basketGUI.addPetToBasket(pet);
    }ShowWhiteGUI:
    public class ShowWhiteGUI extends javax.swing.JFrame {
        private ShowWhite control;
        /** Creates new form ShowWhiteGUI */
        public ShowWhiteGUI(ShowWhite control) {
            initComponents();
            this.control = control;
        /** 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.
        // <editor-fold defaultstate="collapsed" desc="Generated Code">                         
        private void initComponents() {
            aboutDialog = new javax.swing.JDialog();
            jLabel1 = new javax.swing.JLabel();
            jScrollPane1 = new javax.swing.JScrollPane();
            jTextArea1 = new javax.swing.JTextArea();
            itemIdField = new javax.swing.JTextField();
            productIdLabel = new javax.swing.JLabel();
            numberOfItems = new javax.swing.JLabel();
            productId = new javax.swing.JTextField();
            basketButton = new javax.swing.JButton();
            jLabel2 = new javax.swing.JLabel();
            showBasketButton = new javax.swing.JButton();
            jMenuBar1 = new javax.swing.JMenuBar();
            menu = new javax.swing.JMenu();
            jMenu1 = new javax.swing.JMenu();
            open = new javax.swing.JMenuItem();
            quit = new javax.swing.JMenuItem();
            jMenuItem1 = new javax.swing.JMenuItem();
            jMenu2 = new javax.swing.JMenu();
            help = new javax.swing.JMenuItem();
            about = new javax.swing.JMenuItem();
            javax.swing.GroupLayout aboutDialogLayout = new javax.swing.GroupLayout(aboutDialog.getContentPane());
            aboutDialog.getContentPane().setLayout(aboutDialogLayout);
            aboutDialogLayout.setHorizontalGroup(
                aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 400, Short.MAX_VALUE)
            aboutDialogLayout.setVerticalGroup(
                aboutDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGap(0, 300, Short.MAX_VALUE)
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setTitle("Show White's Shop");
            setBackground(new java.awt.Color(0, 102, 255));
            jLabel1.setFont(new java.awt.Font("Baby Kruffy", 0, 36));
            jLabel1.setText("Snow White?s Shop");
            jTextArea1.setColumns(20);
            jTextArea1.setEditable(false);
            jTextArea1.setRows(5);
            jTextArea1.setText(control.getPrintAllStockItems());
            jScrollPane1.setViewportView(jTextArea1);
            productIdLabel.setText("Varenummer:");
            numberOfItems.setText("Antal:");
            basketButton.setText("L?g i kurv");
            basketButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    putInBasket(evt);
            showBasketButton.setText("Vis indk?bskurv");
            showBasketButton.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    showBasket(evt);
            menu.setLabel("Fil");
            jMenu1.setText("Menu");
            menu.add(jMenu1);
            open.setLabel("?bn");
            open.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    open(evt);
            menu.add(open);
            quit.setLabel("Luk");
            quit.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    quit(evt);
            menu.add(quit);
            jMenuItem1.setLabel("Gem");
            jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    save(evt);
            menu.add(jMenuItem1);
            jMenuBar1.add(menu);
            jMenu2.setLabel("Hj?lp");
            help.setLabel("Hj?lp");
            help.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    help(evt);
            jMenu2.add(help);
            about.setLabel("Om Show White Shop");
            jMenu2.add(about);
            jMenuBar1.add(jMenu2);
            setJMenuBar(jMenuBar1);
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(layout.createSequentialGroup()
                            .addGap(37, 37, 37)
                            .addComponent(jLabel1))
                        .addGroup(layout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                                    .addComponent(productIdLabel)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(numberOfItems))
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(productId, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 65, Short.MAX_VALUE)
                                        .addComponent(basketButton))
                                    .addGroup(layout.createSequentialGroup()
                                        .addGap(31, 31, 31)
                                        .addComponent(jLabel2)))
                                .addGroup(layout.createSequentialGroup()
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                    .addComponent(showBasketButton)))))
                    .addContainerGap())
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addComponent(jLabel1)
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(layout.createSequentialGroup()
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(jLabel2))
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                                .addComponent(productIdLabel)
                                .addComponent(itemIdField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addComponent(numberOfItems)
                                .addComponent(productId, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                        .addGroup(layout.createSequentialGroup()
                            .addComponent(showBasketButton)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 202, Short.MAX_VALUE)
                            .addComponent(basketButton)))
                    .addContainerGap())
            pack();
        }// </editor-fold>                       
        public void createBasketWindow(){
            control.getBasketGUI().setVisible(true);
        private void showBasket(java.awt.event.ActionEvent evt) {                           
            createBasketWindow();
        private void putInBasket(java.awt.event.ActionEvent evt) {                            
            Integer itemId = Integer.parseInt(itemIdField.getText());
            String petToAdd = control.getFindItem(itemId);
            System.out.println(petToAdd);
            control.setAddItemToBasket(itemId);
            control.setAddPetToBasket(petToAdd);     
        private void help(java.awt.event.ActionEvent evt) {                     
        private void save(java.awt.event.ActionEvent evt) {                     
            System.out.println("Gemmer fil");
        private void open(java.awt.event.ActionEvent evt) {                     
            System.out.println("?bn fil");
        private void quit(java.awt.event.ActionEvent evt) {                     
            System.exit(0);
        public ShowWhite getControl(){
            return control;
        // Variables declaration - do not modify                    
        private javax.swing.JMenuItem about;
        private javax.swing.JDialog aboutDialog;
        private javax.swing.JButton basketButton;
        private javax.swing.JMenuItem help;
        private javax.swing.JTextField itemIdField;
        private javax.swing.JLabel jLabel1;
        private javax.swing.JLabel jLabel2;
        private javax.swing.JMenu jMenu1;
        private javax.swing.JMenu jMenu2;
        private javax.swing.JMenuBar jMenuBar1;
        private javax.swing.JMenuItem jMenuItem1;
        private javax.swing.JScrollPane jScrollPane1;
        private javax.swing.JTextArea jTextArea1;
        private javax.swing.JMenu menu;
        private javax.swing.JLabel numberOfItems;
        private javax.swing.JMenuItem open;
        private javax.swing.JTextField productId;
        private javax.swing.JLabel productIdLabel;
        private javax.swing.JMenuItem quit;
        private javax.swing.JButton showBasketButton;
        // End of variables declaration                  
    }

  • Accessing the same object from multiple classes.

    For the life of me I can't workout how I can access things from classes that haven't created them.
    I don't want to have to use "new" multiple times in seperate classes as that would erase manipulated values.
    I want to be able to access and manipulate an array of objects from multiple classes without resetting the array object values. How do I create a new object then be able to use it from all classes rather than re-creating it?
    Also I need my GUI to recognize the changes my buttons are making to data and reload itself so they show up.
    All help is good help!
    regards,
    Luke Grainger

    As long as you have a headquarters it shouldn't be to painfull. You simply keep a refrence to your ShipDataBase and Arsenal and all your irrellevant stuff in Headquarters. So the start of your Headquarters class would look something like:
    public class Headquarters{
      public Arsenal arsenal;
      public ShipDatabase db;
    //constructor
      public Headquarters(){
        arsenal = new Arsenal(this, ....);
        db = new ShipDatabase(...);
    //The Arsenal class:
    public class Arsenal{
      public Headquarter hq;
      public Arsenal(Headquarter hq, ....){
        this.hq = hq;
        .Then in your ShipDatabase you should, as good programing goes, keep the arraylist as a private class variable, and then make simple public methods to access it. Methods like getShipList(), addToShipList(Ship ship)....
    So when you want to add a ship from arsenal you write:
    hq.db.addToShipList(ship);
    .Or you could of course use a more direct refrence:
    ShipDatabase db = hq.db;
    or even
    ShipList = hq.db.getShipList();
    but this requires that the shiplist in the DB is kept public....
    Hope it was comprehensive enough, and that I answered what you where wondering.
    Sjur
    PS: Initialise the array is what you do right here:
    //constructor
    shipList = new Ship[6];
    shipList[0] = new Ship("Sentry", 15, 10, "Scout");
    " " " "etc
    shipList[5] = new Ship("Sentry", 15, 10, "Scout");PPS: To make code snippets etc. more readable please read this article:
    http://forum.java.sun.com/faq.jsp#messageformat

  • How to kill one class from another class

    I need to dipose one class from another class.
    So that first i have to find what are all threads running in that class and then to kill them
    Assist me.

    Subbu_Srinivasan wrote:
    I am explaining you in clear way
    No you haven't been.
    >
    In my application i am handling many JInternalFrame.Simultaneously i am running working on more than one frame.
    Due to some poor performance of some thread in one JInternalFrame,the thread is keeps on running .
    i could not able to proceed further on that screen.
    So i have to kill that JInternalFrame.Yoinks.
    To be begin with your problem sounds like you are doing everything in one thread. So stop doing that. Second when you get it split up and if a task is taking too much time then interrupt it. No kill. Interrupt. This means the worker thread needs to check sometimes if it has been interrupted.

  • How can I update a JTextArea from another class

    I am new to Java so forgive me if this is confusing, or if I seem to be taking an overly complex route to acheiving my goal.
    I've got a JTextArea component added to a JPanel object, which is then inserted into the JFrame. I have a JMenuBar with a JMenu "file" and a JMenuItem "connect" on this same JFrame. When clicked, the actionEvent of JMenuItem "connect" calls a class "ConnectToDb" to establish a connection with the Database. On a successful connection, I want to append the String "Connection Successful" to the JTextArea component, but since the component is a part of the JPanel object, I cannot seem to get access to the JTextArea component to update it. I tried instantiating the JPanel object from within the "ConnectToDb" class and then called a method I created to set the JTextArea. No luck. Can someone give me an idea of what I need to do that would allow me to update the text of the JTextArea component from anywhere in my program? Once it has been contained in the JPanel or JFrame, can it be updated?
    This is the class that establishes the simple Db Connection
    package cjt;
    import java.io.*;
    import java.sql.*;
    * Get a database connection
    * Creation date: (04/01/2002 4:08:39 PM)
    * @author: Yaffin
    public class ConnectToDB {
    public Connection dbConnection;
    // ConnectToDB constructor
    public ConnectToDB() {
    public Connection DbConnect() {
    try {
    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    String sourceURL = new String("jdbc:odbc:CJTSQL");
    Connection dbConnection = DriverManager.getConnection(sourceURL, "Encryptedtest", "pass");
    System.out.println("Connection Successful\n");
    //this is where I originally tried to append "Connection Successful
    //to the JTextArea Object in WelcomePane()          
    } catch (ClassNotFoundException cnfe) {
    //user code
    System.out.println("This ain't working because of a class not found exeption/n");
    } catch (SQLException sqle) {
    //user code
    System.out.println("SQL Exception caused your DB Connection to SUCK!/n");
    return dbConnection;
    This is the JPanel that contains the JTextArea "ivjStatusArea" I am trying to update from other classes. Specifically the "ConnectToDb" class above.
    package cjt;
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    * Build Welcome Pane
    * Creation date: (04/01/2002 3:42:50 PM)
    * @author: yaffin
    public class WelcomePane extends JPanel {
         private JTextArea ivjtxtConnect = null;
         private JLabel ivjwelcomeLbl = null;
         private JTextArea ivjStatusArea = null;
    * WelcomePane constructor comment.
    public WelcomePane() {
         super();
         initialize();
    * Return the StatusArea property value.
    * @return javax.swing.JTextArea
    private javax.swing.JTextArea getStatusArea() {
         if (ivjStatusArea == null) {
              try {
                   ivjStatusArea = new javax.swing.JTextArea();
                   ivjStatusArea.setName("StatusArea");
                   ivjStatusArea.setLineWrap(true);
                   ivjStatusArea.setWrapStyleWord(true);
                   ivjStatusArea.setBounds(15, 153, 482, 120);
                   ivjStatusArea.setEditable(false);
                   // user code begin {1}
                   // user code end
              } catch (java.lang.Throwable ivjExc) {
                   // user code begin {2}
                   // user code end
                   handleException(ivjExc);
         return ivjStatusArea;
    * Initialize the class.
    private void initialize() {
         try {
              // user code begin {1}
              // user code end
              setName("WelcomePane");
              setLayout(null);
              setSize(514, 323);
              add(getStatusArea(), getStatusArea().getName());
         } catch (java.lang.Throwable ivjExc) {
              handleException(ivjExc);
         // user code begin {2}
         // user code end
    This is the main class where evrything is brought together. Notice the BuildMenu() method where the JMenuItem "connect" is located. Also notice the PopulateTabbedPane() method where WelcomePane() is first instantiated.
    * The main application window
    * Creation date: (04/01/2002 1:31:20 PM)
    * @author: Yaffin
    public class CjtApp extends JFrame {
    private JTabbedPane tabbedPane;
    private ConnectToDB cdb;
    private Connection dbconn;
    public CjtApp() {
    super("CJT Allocation Application");
    // Closes from title bar
    //and from menu
    addWindowListener(new WindowAdapter() {
    public void windowClosing(WindowEvent e) {
    System.exit(0);
    tabbedPane = new JTabbedPane(SwingConstants.TOP);
    tabbedPane.setForeground(Color.white);
    //add menubar to frame
    buildMenu();
    //populate and add the tabbed pane
    populateTabbedPane(dbconn);
    //tabbedPane.setEnabledAt(1, false);
    //tabbedPane.setEnabledAt(2, false);
    getContentPane().add(tabbedPane);
    pack();
    * Build menu bar and menus
    * Creation date: (04/01/2002 2:42:54 PM)
    private void buildMenu() {
    // Instantiates JMenuBar, JMenu,
    // and JMenuItem.
    JMenuBar menubar = new JMenuBar();
    JMenu menu = new JMenu("File");
    JMenuItem item1 = new JMenuItem("Connect");
    JMenuItem item2 = new JMenuItem("Exit");
    //Opens database connection screen
    item1.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    //call the ConnectToDb class for a database connection
    ConnectToDB cdb = new ConnectToDB();
    dbconn = cdb.DbConnect();
    }); // Ends buildMenu method
    //Closes the application from the Exit
    //menu item.
    item2.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
    System.exit(0);
    }); // Ends buildMenu method
    //Adds the item to the menu object
    menu.add(item1);
    menu.add(item2);
    //Adds the menu object with item
    //onto the menu bar     
    menubar.add(menu);
    //Sets the menu bar in the frame
    setJMenuBar(menubar);
    } //closes buildMenu
    public static void main(String[] args) {
    CjtApp mainWindow = new CjtApp();
    mainWindow.setSize(640, 480);
    mainWindow.setBackground(Color.white);
    mainWindow.setVisible(true);
    mainWindow.setLocation(25, 25);
    * Add tabs to the tabbedPane.
    * Creation date: (04/01/2002 2:52:19 PM)
    private void populateTabbedPane(Connection dbconn) {
         Connection dbc = dbconn;
         tabbedPane.addTab(
         "Welcome",
    null,
    new WelcomePane(),
    "Welcome to CJT Allocation Application");
         tabbedPane.addTab(
         "Processing",
    null,
    new ProcessPane(dbc),
    "Click here to process an allocation");
         tabbedPane.addTab(
         "Reporting",
    null,
    new ReportPane(),
    "Click here for reports");
    //End
    Thanks for any assistance you can provide.
    Yaffin

    Thanks gmaurice1. I appreciate the response. I believe I understand your explanation. I am clear that the calling code needs access to the WelcomPane() object. I am assuming that the constructor for the calling class must have the JPanel WelcomePane() instance passed to it as an argument. This way I can refer directly to this specific instance of the object. Is this correct?
    Also, where would you create the set method? I tried to create a set method as part of the WelcomePane() class, and then call it from the calling class, but it didn't seem to work. Lastly, a globally accessible object? Can you explain this concept briefly? Thanks again for your help.
    yaffin

  • How to call a static method of a class from another class?

    Hello,
    I have two classes in a package. The first one
    package my package;
    public class class1
    protected static ImageIcon createIcon(String path)
    The second one
    package my package;
    public class class2
    private ImageIcon image1;
    image1 = class1.createIcon("/mypath");
    This does not work since class2 cannot load the appropriate image. Where do I have to define the ImageIcon variables in class one or two and do they have to be static variables?
    Thanks in advance
    Christos

    If the two classes are in the same package, that will work, in fact. A trivial example:
    package foo;
    public class Foo1 {
         protected static String getString() {
              return "World";
    // Note: Member of the same package
    package foo;
    public class Foo2 {
         public static void main(String[] argv) {
              System.out.println("Hello "+ foo.Foo1.getString());
    }However, if they are in different packages that won't work - the protected keyword guarantees that only classes derived from the class with the protected method can access it: Therefore this will not work:
    package foo;
    public class Foo1 {
         protected static String getString() {
              return "World";
    package foo.bar;
    public class Foo2{
         public static void main(String[] argv) {
              System.out.println("Hello "+ foo.Foo1.getString());
    }But this will:
    package foo;
    public class Foo1 {
         protected static String getString() {
              return "World";
    package foo.bar;
    public class Foo2 extends foo.Foo1 {
         public static void main(String[] argv) {
              System.out.println("Hello "+ foo.Foo1.getString());
    }I think you should read up a bit more about packages and inheritance, because you're going to have a lot of trouble without a good understanding of both. Try simple examples first, like the above, and if you hit problems try to produce a simple test case to help you understand the problem rather than trying to debug your whole application.
    Dave.

  • Getting a variable value from another class

    Is there any way to get the value of a variable from another class? I have a file that calls another that does some checking then gives a true or false. The place the checking is done is inside an ActionListener I want to use that value in the file that calls the second. Any help would be great.

    in 'another class', implement a method,
    public boolean isCheckedOutOK( Object obj )
    do the comparison in that method (use a suitable argument)

  • How to pass a variable from one class to another class?

    Hi,
    Is it possible to pass a variable from one class to another? For e.g., I need the value of int a for calculation purpose in method doB() but I get an error <identifier> expected. What does the error mean? I know, it's a very, very simple question but once I learn this, I promise to remember it forever. Thank you.
    class A {
      int a;
      int doA() {
          a = a + 1;
          return a;
    class B {
      int b;
      A r = new A();
      r.a;  // error: <identifier> expected. What does that mean ?
      int doB() {
         int c = b/a;  // error: operator / cannot be applied to a
    }Thank you!

    elaine_g wrote:
    I am wondering why does (r.a) give an error outside the method? What's the reason it only works when used inside the (b/r.a) maths function? This is illegal syntax:
    class B {
      int b;
      A r = new A();
      r.a;  //syntax error
    }Why? Class definition restricts what you can define within a class to a few things:
    class X {
        Y y = new Y(); //defining a field -- okay
        public X() { //defining a constructor -- okay
        void f() { //defining a method -- okay
    }... and a few other things, but you can't just write "r.a" there. It also makes no sense -- that expression by itself just accesses a field and does nothing with it -- why bother?
    This is also illegal syntax:
    int doB() {
          A r = new A();
          r.a;  // error: not a statement
    }Again, all "r.a" does on its own is access a field and do nothing with it -- a "noop". Since it has no effect, writing this indicates confusion on the part of the coder, so it classified as a syntax error. There is no reason to write that.

  • Passing a variable from one class to another

    Hello:
    I am new to java programming. I am developing an application in Java
    At a particular JTextField call it jtf3, I am invoking Calendar application by clikcing a jbutton.
    I would like to set text in jtf by obtaining the date clicked by the user. I am storing complete date string in the Calendar application during ActionPerformed event at Calendar Application level.
    I do not know how to pass this string to calling frame as it does not listen to the button event happening at the Calendar Application.
    Much appreciated
    Thanks a lot for your time
    regards

    This is the application from which the I am calling the calendar application.
    The method setDate set the date obtained from calendar class during actionperformed event.
    The actionperfomed event from CalendarClass is pasted below as well.
    Much appreciated
    import javax.swing.JFrame;
    import javax.swing.*;
    import java.awt.event.*;
    import java.util.*;
    import java.awt.*;
    public class TestDrive
    public static void main(String[] args) {
    DatePanelFrame dpf = new DatePanelFrame();
    dpf.addWindowListener(new WindowAdapter( ) {
    public void windowClosing(WindowEvent we) { System.exit(0); }
    dpf.pack();
    dpf.setVisible(true);
    class DatePanelFrame extends JFrame {
    JTextField djtf;
    String dateInput;
    public DatePanelFrame() {
    setTitle("Date Panel");
    setSize(100, 800);
    setLocation(300, 100);
    Container content = getContentPane();
    JPanel datePanel = new JPanel();
    JButton calButton = new JButton(".....");
    datePanel.add(calButton, BorderLayout.SOUTH);
    djtf = new JTextField(" ");
    datePanel.add(djtf, BorderLayout.NORTH);
    content.setLayout(new BorderLayout());
    content.add(datePanel, BorderLayout.CENTER);
    calButton.addActionListener(new ActionListener()
              public void actionPerformed(ActionEvent event)
    JFrame fr = new CalendarClass();
    fr.setSize(400, 400);
    fr.setLocation(600, 100);
    ObjCal oc = new ObjCal();
    fr.setVisible(true);
    public void setDate(String d)
    djtf.setText(d);
    repaint();
    System.out.println(djtf.getText());
    The ActionPerformed event from CalendarClass
    jbtArray.addActionListener(new ActionListener()
    public void actionPerformed(ActionEvent event)
    if (event.getActionCommand() != " ")
              daySelected = event.getActionCommand();
              yearSelected = jtfYear.getText();
              int intYearSelected = Integer.valueOf(yearSelected).intValue();
              monthSelected = jtfMonth.getText();
              intDaySelected = Integer.valueOf(daySelected).intValue();
              int intMonthSelected = getMonthNum(monthSelected);
              dateSelected = getDate(intYearSelected, intMonthSelected, intDaySelected);
              TestDrive td = new TestDrive();
              DatePanelFrame dpf = new DatePanelFrame();
              dpf.setDate(dateSelected);

  • Using Variables/Arrays from one class in another

    Hello all,
    First, to explain what I am attempting to create, is a program that will accept input of employee names and hours worked into an array. The first class will accept a command line argument when invoked. If the argument is correct, it will call another class that will gather information from the user via an input box. After all names and hours have been input for employees, this class will calculate the salary based upon the first letter of each employee name and print the total hours, salary, etc. for each employee.
    What I need to do now is to split the second class into two: one that will gather the data and another that will calculate and print the data. Yes, this is an assignment. However, I am trying to learn and I have gotten this far, but I am stuck on how to get a class to be able to use an array/variables from another class.
    I realize the below code isn't exactly cleaned up...yet.
    Code for AverageSalaryGather class:
    import javax.swing.JOptionPane; // uses class JOptionPane
    import java.lang.reflect.Array;     
    import java.math.*;
    public class AverageSalaryGather {
         public static void gatherData() {     
              char[] alphaArray = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','x','y','z'};
              String[][] empInfoArray = new String[100][4];
              String[] empNameArray = new String[100];
              String finalOutput = "Name - Rate - Hours - Total Pay\n";
              String averageHoursOutput = "Average Hours Worked:\n";
              String averageSalaryOutput = "Average Hourly Salary:\n";
              String averageGroupSalaryOutput = "Average Group Salary:\n";
                        String[] rateArray = new String[26];
                        char empNameChar = 'a';
              int empRate = 0;
              int payRate = 0;
                        for (int i = 0; i < 26; i++) {
                   payRate = i + 5;
                   rateArray[i] = Integer.toString(payRate);
                        int countJoo = 0;
              while (true) {
                   String namePrompt = "Please enter the employee name: ";
                   String empName = JOptionPane.showInputDialog(namePrompt);
                                  if (empName == null | empName.equals("")) {
                        break;
                   else {
                        empInfoArray[countJoo][0] = empName;
                        for (int i = 0; i < alphaArray.length; i++) {
                             empNameChar = empName.toLowerCase().charAt(0);
                                                      if (alphaArray[i] == empNameChar) {
                                  empInfoArray[countJoo][1] = rateArray;
                                  break;
                        countJoo++;
              // DecimalFormat dollarFormat = new DecimalFormat("$#0.00");
              for (int i = 0; i < empInfoArray.length; i++) {
                   if (!(empInfoArray[i][0] == null)) {
                        String hourPrompt = "Please enter hours for " + empInfoArray[i][0] + ": ";
                        String empHours = JOptionPane.showInputDialog(hourPrompt);
                        int test = 0;
                        empInfoArray[i][2] = empHours;
                        // convert type String to double
                        //double tmpPayRate = Double.parseDouble(empInfoArray[i][1]);
                        //double tmpHours = Double.parseDouble(empInfoArray[i][2]);
                        //double tmpTotalPay = tmpPayRate * tmpHours;
                        // create via a string in empInfoArray
                             BigDecimal bdRate = new BigDecimal(empInfoArray[i][1]);
                             BigDecimal bdHours = new BigDecimal(empInfoArray[i][2]);
                             BigDecimal bdTotal = bdRate.multiply(bdHours);
                             bdTotal = bdTotal.setScale(2, RoundingMode.HALF_UP);
                             String strTotal = bdTotal.toString();
                             empInfoArray[i][3] = strTotal;
                        //String strTotalPay = Double.toString(tmpTotalPay);
                        //empInfoArray[i][3] = dollarFormat.format(tmpTotalPay);
                        else {
                             break;
              AverageSalaryCalcAndPrint averageSalaryCalcAndPrint = new AverageSalaryCalcAndPrint();
              averageSalaryCalcAndprint.calcAndPrint();
    Code for AverageSalaryCalcAndPrint class (upon compiling, there are more than a few complie errors, and that is due to me cutting/pasting the code from the other class into the new class and the compiler does not know how to access the array/variables from the gatherData class):
    import javax.swing.JOptionPane; // uses class JOptionPane
    import java.lang.reflect.Array;
    import java.math.*;
    public class AverageSalaryCalcAndPrint
         public static void calcAndPrint() {     
              AverageSalaryGather averageSalaryGather = new AverageSalaryGather();
              double totalHours = 0;
              double averageHours = 0;
              double averageSalary = 0;
              double totalSalary = 0;
              double averageGroupSalary = 0;
              double totalGroupSalary = 0;
              int countOfArray = 0;
              for (int i = 0; i < empInfoArray.length; i++) {
                   if (!(empInfoArray[0] == null)) {
                        totalSalary = totalSalary + Double.parseDouble(empInfoArray[i][1]);
                        totalHours = totalHours + Double.parseDouble(empInfoArray[i][2]);
                        totalGroupSalary = totalGroupSalary + Double.parseDouble(empInfoArray[i][3]);
                        countOfArray = i;
              averageHours = totalHours / (countOfArray + 1);
              averageSalary = totalSalary / (countOfArray + 1);
              averageGroupSalary = totalGroupSalary / (countOfArray + 1);
              String strAverageHourlySalary = Double.toString(averageSalary);
              String strAverageHours = Double.toString(averageHours);
              String strAverageGroupSalary = Double.toString(averageGroupSalary);
              for (int i = 0; i < empInfoArray.length; i++) {
                   if (!(empInfoArray[i][0] == null)) {
                        finalOutput = finalOutput + empInfoArray[i][0] + " - " + "$" + empInfoArray[i][1] + "/hr" + " - " + empInfoArray[i][2] + " - " + "$" + empInfoArray[i][3] + "\n";
              averageHoursOutput = averageHoursOutput + strAverageHours + "\n";
              averageSalaryOutput = averageSalaryOutput + strAverageHourlySalary + "\n";
              averageGroupSalaryOutput = averageGroupSalaryOutput + strAverageGroupSalary + "\n";
              JOptionPane.showMessageDialog(null, finalOutput + averageHoursOutput + averageSalaryOutput + averageGroupSalaryOutput, "Totals", JOptionPane.PLAIN_MESSAGE );

    Call the other class's methods. (In general, you
    shouldn't even try to access fields from the other
    class.) Also you should be looking at an
    instance of the other class, and not the class
    itself, generally.Would I not call the other classes method's by someting similar as below?:
    AverageSalaryCalcAndPrint averageSalaryCalcAndPrint = new AverageSalaryCalcAndPrint();
              averageSalaryCalcAndprint.calcAndPrint(); Well... don't break down classes based on broad steps
    of the program. Break them down by the information
    being managed. I'm not expressing this well...Could you give an example of this? I'm not sure I'm following well.
    Anyway, you want one or more objects that represent
    the data, and operations on that data. Those
    operations include calculations on the data. Other
    classes might represent the user interface, and
    different output types (say, a file versus the
    console).Yes, the requirements is to have a separate class to gather the data, and then another class to calculate and print the data. Is this what you mean in the above?

  • Adding a JPanel from one class to another Class (which extends JFrame)

    Hi everyone,
    So hopefully I go about this right, and I can figure out what I'm doing wrong here. As an exercise, I'm trying to write a Tic-Tac-Toe (TTT) game. However, in the end it will be adaptable for different variations of TTT, so it's broken up some. I have a TTTGame.java, and TTTSquareFrame.java, and some others that aren't relavent.
    So, TTTGame:import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import joshPack.jUtil.*;
    public class TTTGame extends JFrame
         private Integer sides = 3;
         private TTTSquareFrame mainSquare;
         private TTTGame newGame;
         private Container contents;
         private JPanel mainSquarePanel, addPanel;
         public static void main(String [] args)
              TTTGame newGame = new TTTGame();
              newGame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public TTTGame()
              super("Tic-Tac-Toe");
              contents = getContentPane();
              contents.setLayout(new FlowLayout());
              addPanel = startSimple();
              if(!addPanel.isValid())
                   System.out.println("Something's wrong");
              contents.add(addPanel);
              setSize(300, 300);
              setVisible(true);
         public JPanel startSimple()
              mainSquare = new TTTSquareFrame(sides);
              mainSquarePanel = mainSquare.createPanel(sides);
              return mainSquarePanel;
    }and TTTSquareFrame:import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import joshPack.jUtil.Misc;
    public class TTTSquareFrame
         private JPanel squarePanel;
         private JButton [] squares;
         private int square, index;
         public TTTSquareFrame()
              System.out.println("Use a constructor that passes an integer specifying the size of the square please.");
              System.exit(0);
         public TTTSquareFrame(int size)
         public JPanel createPanel(int size)
              square = (int)Math.pow(size, 2);
              squarePanel = new JPanel();
              squarePanel.setLayout(new GridLayout(3,3));
              squares = new JButton[square];
              System.out.println(MIN_SIZE.toString());
              for(int i = 0; i < square; i++)
                   squares[i] = new JButton();
                   squares.setRolloverEnabled(false);
                   squares[i].addActionListener(bh);
                   //squares[i].setMinimumSize(MIN_SIZE);
                   squares[i].setVisible(true);
                   squarePanel.add(squares[i]);
              squarePanel.setSize(100, 100);
              squarePanel.setVisible(true);
              return squarePanel;
    }I've successfully added panels to JFrame within the same class, and this is the first time I'm modularizing the code this way. The issue is that the frame comes up blank, and I get the message "Something's wrong" and it says the addPanel is invalid. Originally, the panel creation was in the constructor for TTTSquareFrame, and I just added the mainSquare (from TTTGame class) to the content pane, when that didn't work, I tried going about it this way. Not exactly sure why I wouldn't be able to add the panel from another class, any help is greatly appreciated.
    I did try and cut out code that wasn't needed, if it's still too much let me know and I can try and whittle it down more. Thanks.

    Yea, sorry 'bout that, I just cut out the parts of the files that weren't relevant but forgot to compile it just to make sure I hadn't left any remnants of what I had removed. For whatever it's worth, I have no idea what changed, but something did and it is working now. Thanks for your help, maybe next time I'll post an actual question that doesn't somehow magically solve itself.
    EDIT: Actually, sorry, I've got the panel working now, but it's tiny. I've set the minimum size, and I've set the size of the panel, so...why won't it respond to that? It almost looks like it's being compressed into the top of the panel, but I'm not sure why.
    I've compressed the code into:
    TTTGame.java:
    import java.awt.*;
    import javax.swing.*;
    public class TTTGame extends JFrame
         private Integer sides = 3;
         private TTTSquareFrame mainSquare;
         private TTTGame newGame;
         private Container contents;
         private JPanel mainSquarePanel, addPanel;
         public static void main(String [] args)
              TTTGame newGame = new TTTGame();
              newGame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
         public TTTGame()
              super("Tic-Tac-Toe");
              contents = getContentPane();
              contents.setLayout(new FlowLayout());
              mainSquare = new TTTSquareFrame(sides.intValue());
              contents.add(mainSquare);
              setSize(400, 400);
              setVisible(true);
    }TTTSquareFrame.java
    import java.awt.*;
    import javax.swing.*;
    public class TTTSquareFrame extends JPanel
         private JButton [] squares;
         private int square, index;
         private final Dimension testSize = new Dimension(50, 50);
         public TTTSquareFrame(int size)
              super();
              square = (int)Math.pow(size, 2);
              super.setLayout(new GridLayout(size, size));
              squares = new JButton[square];
              for(int i = 0; i < square; i++)
                   squares[i] = new JButton();
                   squares.setMinimumSize(testSize);
                   squares[i].setVisible(true);
                   super.add(squares[i]);
              setSize(200, 200);
              setVisible(true);
    I've made sure the buttons are smaller than the size of the panel, and the panel is smaller than the frame, so...
    Message was edited by:
    macman104

Maybe you are looking for

  • IPhone no longer appears in iTunes

    I have been syncing my iPhone(s) with iTunes since June 2007 on my G5 iMac running Mac OS 10.4.11. Yesterday, I finally updated my OS to 10.5.8 and the Leopard version of iTunes 9.0.2. However, my iPhone no longer shows up in the source pane of the i

  • 10.1" tablet uses full install of Windows 8.1

    I have just purchased a new tablet. It is an "Unbranded" Windows 8.1 - 10.1" - Tablet - 32GB. My question is where does this tablet fall into on installation. Since it is running the full Windows 8.1 do I install the Adobe programs on it like I did f

  • Retrieving a file

    Hi! I would like to find a file (doc.xml) in my architecture, at the second level bottom. For this, I use the following code: import java.io.*; import java.util.*; public class recherche extends Object { public static void main (String args[]) throws

  • VTO-2014 Error - Informative

    After Installing an Oracle 9i database and its patches then installing a 9i and 10g client dicovered problems running enterprise manager. When I used the feature Show DDL and Create Like for certain objects I would receive the following erros VTO-201

  • Iphone 4S error code 36

    hi i upgraded my iphone 4S from IOS 7.0 to 7.0.2, it went on restart and didn't make the successfull loading. now when i connect it through itunes, it asks for the restore and when do so, it comes with Error Code 36, please anybody can help me, would