Linking 2 classes together

This is always what i find hardest to do in java for some reason. Basically i have some code which is part of the class database, and this class adds records to my database as seen below;
class Database
     public Database(){
     int answer = JOptionPane.YES_OPTION;
     int count = 0;
     final int ARRAY_SIZE = 12;
     CD[] data = new CD[ARRAY_SIZE];
     while (answer == JOptionPane.YES_OPTION)
     String a;
     String c;
     int n;
     a = JOptionPane.showInputDialog("Please, enter artist name");
     c = JOptionPane.showInputDialog("Please, enter CD name");
     n = Integer.parseInt(JOptionPane.showInputDialog("Please enter total number of tracks"));
     data[count] = new CD(a, c, n);
     answer = JOptionPane.showConfirmDialog(null, "Enter another record?",
                     "???", JOptionPane.YES_NO_OPTION);
     count++;
     System.exit(0);
}Next i have a new class called search which is supposed to search for a CD typed in by the user. This is the code i have;
class Search
int result;
String searchKey = JOptionPane.showInputDialog("Give me the name of a CD");
result = linearSearch(data, searchKey, ARRAY_SIZE);
     if(result== -1)
     JOptionPane.showMessageDialog(null,"KEY " + searchKey + " NOT FOUND");
     else
     JOptionPane.showMessageDialog(null,"KEY " + searchKey + " FOUND in position " + result);
     System.exit(0);
public static int linearSearch(String[] data, String key, int sizeOfArray)
for (int counter = 0; counter < sizeOfArray; counter++)
if (data[counter].equalsIgnoreCase (key))
return counter;
return -1;
}How do i get the information from the database into my search class, because at the moment my search class wont compile due to identifiers being expected, most problably for the variables data and ARRAY_SIZE. Also, i am not sure if this makes a difference but the information i need from the database class is only the CD name and not the whole array object. If i am unclear, just let me know.
Cheers

above these 2 classes, i have a constructor and method which states my array object;
class CD
     String artistName, CDname;
     int noOfTracks;
     public String records;     
     public CD (String ar, String cd, int no){
     //data that is passed is stored in variables below
     artistName=ar;
     CDname= cd;
     noOfTracks=no;
     String printData(){
     //processed data stored in variable record      
     records =artistName  + "    "+ CDname + "     " + noOfTracks ;
     //value of record returned
     return records;
}Can i use this constructor and class to create a new method which will search the array, or do i have to create constructors for my other classes, and if so is it the database class or the search class i need these methods and constructors?

Similar Messages

  • Linking classes together

    hi, do u guys know of any tutorials about linking two or more classes together?
    i need to learn anything and everything about it.
    thx,
    gildan2020

    class A
        public static void main(String[] args)
            // uses static PrintStream object in System class and
            // calls the println() method on that PrintStream object.
            System.out.println("Hello World");
    }http://java.sun.com/docs/books/tutorial/
    http://java.sun.com/learning/new2java/index.html
    http://javaalmanac.com
    http://www.jguru.com
    http://www.javaranch.com
    Bruce Eckel's Thinking in Java
    Joshua Bloch's Effective Java
    Bert Bates and Kathy Sierra's Head First Java

  • The text in my links run together.

    The text in my links run together. Any ideas how to fix this? Here's a link to the page: http://bodyprecision.com/main-line-pilates-teacher-training/pilates-full-training-test.htm l Thank you!

    Sunflower19714 wrote:
    Thank you for doing this. I fixed everything that was noted and ran the code through the validator again. It came out clean but the problem still exists.
    Ok, this is a weird one I'd say, it happens.
    The issue is in this stylesheet:
    ../../bp-styles.css
    Can you do a test for me. Grab everything in that stylesheet and paste it between <style> </style> brackets directly in your pages code before the closing </head> tag:
    <style>
    PASTE ALL CSS FROM bp-styles.css HERE
    </style>
    </head>
    Then comment out the orginal linked bp-styles.css style sheet to stop it working by adding <!--       --> (see below)
    <!-- <link href="../../bp-styles.css" rel="stylesheet" type="text/css" /> -->
    What happens when you view the page then?
    I think you may just have a corrupt file somehow.

  • [EJB:015001]Unable to link class while server start up.

    I am getting the below exception during weblogic server start up.
    In the server under autodeploy folder there exist a class - AccountCacheLoaderMDB. I clue less, what is the cause for this exception. Can anyone help me out in solving this issue please,its urgent
    <Jun 2, 2011 10:23:01 AM EDT> <Error> <Deployer> <BEA-149205> <Failed to initialize the application 'gts' due to error weblogic.application.ModuleException: Exception preparing module: EJBModule(autodeploy)
    [EJB:011023]An error occurred while reading the deployment descriptor. The error was:
    Error processing annotations: ..
    weblogic.application.ModuleException: Exception preparing module: EJBModule(autodeploy)
    [EJB:011023]An error occurred while reading the deployment descriptor. The error was:
    Error processing annotations: .
         at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:454)
         at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
         at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)
         Truncated. see log file for complete stacktrace
    weblogic.utils.ErrorCollectionException:
    There are 1 nested errors:
    weblogic.j2ee.dd.xml.AnnotationProcessException: [EJB:015001]Unable to link class sepact.sepact-app.com.citi.gts.alto.accountservice.service.AccountCacheLoaderMDB in Jar C:\Oracle\user_projects\domains\base_domain\autodeploy : java.lang.NoClassDefFoundError: sepact/sepact-app/com/citi/gts/alto/accountservice/service/AccountCacheLoaderMDB (wrong name: com/citi/gts/alto/accountservice/service/AccountCacheLoaderMDB)
         at weblogic.j2ee.dd.xml.BaseJ2eeAnnotationProcessor.addProcessingError(BaseJ2eeAnnotationProcessor.java:1272)
         at weblogic.j2ee.dd.xml.BaseJ2eeAnnotationProcessor.addFatalProcessingError(BaseJ2eeAnnotationProcessor.java:1277)
         at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processAnnotations(EjbAnnotationProcessor.java:168)
         at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.processStandardAnnotations(EjbDescriptorReaderImpl.java:332)
         at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.createReadOnlyDescriptorFromJarFile(EjbDescriptorReaderImpl.java:192)
         at weblogic.ejb.spi.EjbDescriptorFactory.createReadOnlyDescriptorFromJarFile(EjbDescriptorFactory.java:93)
         at weblogic.ejb.container.deployer.EJBModule.loadEJBDescriptor(EJBModule.java:1210)
         at weblogic.ejb.container.deployer.EJBModule.prepare(EJBModule.java:382)
         at weblogic.application.internal.flow.ModuleListenerInvoker.prepare(ModuleListenerInvoker.java:93)
         at weblogic.application.internal.flow.DeploymentCallbackFlow$1.next(DeploymentCallbackFlow.java:387)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:58)
         at weblogic.application.internal.flow.DeploymentCallbackFlow.prepare(DeploymentCallbackFlow.java:42)
         at weblogic.application.internal.BaseDeployment$1.next(BaseDeployment.java:609)
         at weblogic.application.utils.StateMachineDriver.nextState(StateMachineDriver.java:37)
         at weblogic.application.internal.BaseDeployment.prepare(BaseDeployment.java:185)
         at weblogic.application.internal.SingleModuleDeployment.prepare(SingleModuleDeployment.java:40)
         at weblogic.application.internal.DeploymentStateChecker.prepare(DeploymentStateChecker.java:154)
         at weblogic.deploy.internal.targetserver.AppContainerInvoker.prepare(AppContainerInvoker.java:60)
         at weblogic.deploy.internal.targetserver.AppDeployment.prepare(AppDeployment.java:141)
         at weblogic.management.deploy.internal.DeploymentAdapter$1.doPrepare(DeploymentAdapter.java:39)
         at weblogic.management.deploy.internal.DeploymentAdapter.prepare(DeploymentAdapter.java:187)
         at weblogic.management.deploy.internal.AppTransition$1.transitionApp(AppTransition.java:21)
         at weblogic.management.deploy.internal.ConfiguredDeployments.transitionApps(ConfiguredDeployments.java:233)
         at weblogic.management.deploy.internal.ConfiguredDeployments.prepare(ConfiguredDeployments.java:165)
         at weblogic.management.deploy.internal.ConfiguredDeployments.deploy(ConfiguredDeployments.java:122)
         at weblogic.management.deploy.internal.DeploymentServerService.resume(DeploymentServerService.java:173)
         at weblogic.management.deploy.internal.DeploymentServerService.start(DeploymentServerService.java:89)
         at weblogic.t3.srvr.SubsystemRequest.run(SubsystemRequest.java:64)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
         at weblogic.j2ee.dd.xml.BaseJ2eeAnnotationProcessor.addProcessingError(BaseJ2eeAnnotationProcessor.java:1271)
         at weblogic.j2ee.dd.xml.BaseJ2eeAnnotationProcessor.addFatalProcessingError(BaseJ2eeAnnotationProcessor.java:1277)
         at weblogic.ejb.container.dd.xml.EjbAnnotationProcessor.processAnnotations(EjbAnnotationProcessor.java:168)
         at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.processStandardAnnotations(EjbDescriptorReaderImpl.java:332)
         at weblogic.ejb.container.dd.xml.EjbDescriptorReaderImpl.createReadOnlyDescriptorFromJarFile(EjbDescriptorReaderImpl.java:192)
         Truncated. see log file for complete stacktrace
    >
    ===============================================================
    Here is the message driven bean.
    package com.xxx.gts.alto.accountservice.service;
    import com.xxx.gts.alto.accountservice.adapter.AccountAdapter;
    import com.xxx.gts.alto.accountservice.util.AccBeanUtil;
    import com.xxx.gts.alto.accountservice.util.AccountConstants;
    import com.xxx.gts.alto.accountservice.util.AccountLoader;
    import org.apache.log4j.Logger;
    import org.springframework.beans.factory.BeanFactory;
    import javax.ejb.ActivationConfigProperty;
    import javax.ejb.EJB;
    import javax.ejb.MessageDriven;
    import javax.ejb.TransactionAttribute;
    import javax.ejb.TransactionAttributeType;
    import javax.ejb.TransactionManagement;
    import javax.ejb.TransactionManagementType;
    import javax.jms.Message;
    import javax.jms.MessageListener;
    import javax.jms.TextMessage;
    * MDB for the Account Cache Loader.
    @MessageDriven(mappedName = "AccountCacheLoaderQueue", activationConfig = {@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),@ActivationConfigProperty(propertyName = "destinationName", propertyValue = "AccountCacheLoaderQueue")})
    @TransactionManagement(value = TransactionManagementType.CONTAINER)
    @TransactionAttribute(value = TransactionAttributeType.NOT_SUPPORTED)
    public class AccountCacheLoaderMDB implements MessageListener {
    private static Logger logger = Logger.getLogger(AccountCacheLoaderMDB.class.getName());
    private static final String LOCAL_ADAPATER = AccBeanUtil.getProperty(AccountConstants.ADAPTER_ID);
    private static final String TOKEN_SEPARATOR = ","; // \\s
    @EJB
    private BeanFactory beanFactory;
    public void onMessage(Message message) {
    logger.debug("Entering onMessage of AccountCacheLoaderMDB");
    try {
    if (message instanceof TextMessage) {
    TextMessage tmsg = (TextMessage) message;
    String[] msgArr = tmsg.getText().split(TOKEN_SEPARATOR);
    logger.debug("Trying to get AccountAdapter");
    AccountAdapter acctAdapter = (AccountAdapter) beanFactory.getBean(LOCAL_ADAPATER);
    if (acctAdapter == null) {
    throw new RuntimeException("Account Adapter cannot be determined.");
    for (String msg : msgArr) {
    if (msg.equalsIgnoreCase(AccountConstants.ACC_RELOAD)) {
    logger.debug("Calling AccountLoader.load");
    AccountLoader.load(acctAdapter);
    } else if (msg.equalsIgnoreCase(AccountConstants.BIC_RELOAD)) {
    logger.debug("Calling AccountLoader.loadBicData");
    AccountLoader.loadBicData(acctAdapter);
    } catch (Exception e) {
    logger.error("Error while loading Account.", e);
    throw new RuntimeException(e);
    logger.debug("Exiting onMessage of AccountCacheLoaderMDB");
    can any one throw some light please...its urgent

    Your class seems to be in the wrong folder structure.
    instead of sepact/sepact-app/com/citi/gts/alto/accountservice/service/ it needs to be in com/citi/gts/alto/accountservice/service/ which matches the folder structure.

  • Using CSS class together with CSS Rule

    Hi,
    I design my web site in Dreamweaver and then use Web
    Developer 2005 Express for the dynamic stuff. I amalgamate all the
    work I have done in Dreamweaver into 2005 Express. However with the
    new server side controls I do not know how to add a CSS class
    together with a CSS rule.
    In the normal client side control in Dreamweaver I have -
    <input name="txtPassword" type="password" class="Input"
    id="SpacerBottom" />
    In the server side controls the ID keyword is used now -
    <asp:TextBox ID="txtPassword" runat="server"
    Style="z-index: 107" CssClass="Input" ></asp:TextBox>
    I have tried to use the name="txtPassword", but it ignores
    this.
    I would really like to know how I can use a class and an id
    selector with the new server side controls and would really
    appreciate some help on this.
    Many thanks,
    Polly Anna

    the explicit " match-any" will do just that.So, a nested ACL can be configured for multiple criteria.
    The alternate is a "match-all" where all nested options in your acl MUST be met. Hope this helps.
    T

  • I am new to pages and want to know how to link elements together to create one unified element that I can then duplicate several times on the same page?

    I am new to pages and want to know how to link elements together to create one unified element that I can then duplicate several times on the same page?

    I think you are talking about grouping objects.
    1. They must all be floating objects
    2. Command click on each in turn
    Menu > Arrange > Group
    Peter

  • Error When Linking Projects Together in Captivate 4

    Hello!
    I've been having some challenges linking multiple captivate projects together.  I've done some research on the forums here and have noticed that this is a pretty common issue.  But unfortunately for me, after following the advice that I've read, I'm still having problems.  There's obviously something that I must be missing, so I'll do my best to outline what I've done in as much detail as possible in hopes that someone can help me.
    Software:
    I'm using Captivate version 4.0.1. Build 1658
    Situation:
    I'm creating an e-learning that it is made up of 8 separate projects:
    Project A - Welcome Page (1 slide) which has a button that is linked to Project B
    Project B - Home Page (1 slide) made up of 6 buttons, each one links to one of the 6 captivate projects (C-H) listed below
    Project C - Lesson 1 (41 slides)
    Project D - Lesson 2 (45 slides)
    Project E - Lesson 3 (36 slides)
    Project F - Lesson 4 (33 slides)
    Project G - Lesson 5 (29 slides)
    Project H - Lesson 6 (30 slides)
    Links:
    All of the links are made through text buttons, and when each button was created, in the area where it asks "If the user clicks the button", I select the "open other project" option.  Then I browse to the .cp project that I want to launch after the user clicks the button.  Only the relative path of the project I selected is showing in the "Project" field, then I click Apply, then OK.
    Publishing:
    I created a folder on my C: Drive named "MyName Captivate", and I published all of the projects to that folder.  Additionally, all of the projects are also in that folder as well.  When publishing the projects, I'm publishing them as Flash (.swf) files.  On the publishing screen, on the "Project Title" field, I left that field unchanged (it defualts to the project's name).  The "Folder" field has C:\MyName Captivate in it.  I checked "Publish Files to a Folder" and "Export HTML" under Export Options.
    Flash Security Settings:
    I went to the Flash Security Settings and made sure that the "Always Allow" radio button was clicked, and then I went to the "Edit Locations" drop down box and navigated to the "C:\MyName Captivate" folder where all of my .cp projects are located and added it to the "Always Trust Files in These Locations" field.
    The Problem:
    After all of the files have been published, and I test it out in my web browser, I get the following error message when I click the button to go to the linked project (in this case, when clicked, the button is supposed to take me to Project B): "Cannot find file:///C:/Users?HP%20User/AppData/Local/Temp/cp4Temp/~Cal55B/ProjectB.htm.  Make sure the path or Internet address is correct."  I am confused about where that internet path is coming from, because I made sure to place all of the project files into the "C:\MyName Captivate" folder, and the button when clicked should "open other project", which in this case is Project B.
    I hope that all made sense.  If anyone can help guide me in the right direction, it would be greatly appreciated.  Thanks so much for your help!

    WestCoast,
    I believe this is an extremely common issue. Personally, I gave up trying to link projects together like this. I also wanted to offer my users a more "perpetual" interface. I wanted the user, at any time, to be able to switch to another Captivate movie - rather than being forced to navigate through more slides to find the right button to click. So, I created a product called the Launch Pad. It works by using one web page with a menu. Clicking a menu item pulls in a seperate .SWF file into the web page.
    One suggestion might be to have your buttons link to fully qualified (http://myserver/myfolder) URLs instead of "projects". Each button links to the HTML file that Captivate publishes. Full URLs with the entire URL of the HTML file seem to work better than relative URLs.

  • Help to link buttons together

    I got 9 buttons thats needs to work together.
    When pressing Bench PWR. The Bench PWR. and OFF goes ON.
    When pressing NO LOAD, OFF buttons goes off and Bench PWR. stays on.
    When pressing 200VA Unity, NO LOAD goes off and Bench PWR. stays on.
    And sow on, the Bench PWR. button must always stay ON, and the other buttons must change.
    When pressing Bench PWR. to OFF all buttons goes off.
    I also want all the buttons abow Bench PWR. not to work if Bench PWR. is not ON.

    Hi Kimlorentz,
    If i well understand the requirement why you are not planning to use radio button.
    Look the attached VI.
    Thanks and Regards
    Himanshu Goyal | LabVIEW Engineer- Power System Automation
    Values that steer us ahead: Passion | Innovation | Ambition | Diligence | Teamwork
    It Only gets BETTER!!!
    Attachments:
    Link Buttons Together.vi ‏14 KB

  • Linking Apps Together

    I was watching Adobe TV and I noticed that the instructor hsd edge code linked within the Illustrator app. There were different icons for different apps at the top underneath the option tabs. Does anyone know how I can do this with my apps? Thanks in advance. By the way, I'm using CC but I also have all the CS6 apps as well.

    From: [email protected]
    Sent: Friday, July 12, 2013 7:45 AM
    To: robert.fiore1
    Subject: Linking Apps Together
    Re: Linking Apps Together
    created by <http://forums.adobe.com/people/%5Bscott+w%5D>  in Illustrator - View the full discussion <http://forums.adobe.com/message/5499176#5499176

  • Linking songs together

    i was wondering if there was a way to link songs together so when playing music in shuffle mode i can set certain songs to play together before moving on to another random song. basically how can i make 2 or 3 songs play as if they were 1 song. for example, Pink Floyd's "Another Brick in the Wall Pt1" "The Happiest Days of our Lives" & "Another Brick in the Wall Pt2" is sort of a trilogy of songs that should be played in their respective order one after the other. However when playing in shuffle mode, it will randomly select songs and never plays them in order or one after the other. How can i make it so iTunes thinks the three songs are actually just one, and therefore always plays them together and in order. I have other songs that i'd like to do this with as well. Any help would be appreciated.
    Thanks in advance, GL

    With iTunes you can only do this while ripping from a CD. (See the option in the "Advanced" menu.) For existing files you'd have to use some other application.
    Alexander.

  • Link everything together to be used in Python

    for linking python and c i use this instruction:
        g++ -shared func.o func_wrap.o -o _func.so
    but I get this error:
        ld: symbol(s) not found for architecture x86_64
        clang: error: linker command failed with exit code 1 (use -v to see invocation)
    I tried different place for -v but it dose not work.
    what is problem? 
    I compiled through these commands:
    // Compiling the actual function
        g++ -c -fpic func.c
    // Generate the wrapping C code using SWIG
        swig -python func.i
    // Compile the wrapping C code
        g++ -c -fpic func_wrap.c -I/usr/include/python2.6
    // Link everything together to be used in Python
        g++ -shared func.o func_wrap.o -o _func.so

    Hello,
    on which version of BPC are you running ?
    Can you try to make all your SSIS variables upper case, it helped me on earlier versions of BPC.
    Be aware too that if you have an instruction like GLOBAL(STR,some_value), BPC will do a string replacement within the MODIFYSCRIPT variable  : "STR" -> "some_value".
    for example :
    GLOBAL(STR,some_value)
    TASK(STR TSK,....) will be replaced by TASK(some_value, ....).
    Vladimir.

  • Linking classes - How do you make a new window?

    Hey
    Im currently working on a project for my final course grade, however, it requires that we create a gui interface in java (JCreator) whilst linking it to a microsoft access database we made perviously.
    I would like to know if it is possible to open/run/excute another class (either opening it in the same window / jframe, or more preferably opening another whole jframe) from clicking on a button in the origional class (which is the main menu, clicking on the button will open client details) if so, how?
    I greatly apperciate any feedback
    cheers

    I would advise you to have a look at the swing tutorial @ http://java.sun.com/docs/books/tutorial/uiswing/
    Read the basics and Swing Components for creating windows, for the button click part, read the section about ActionListeners.

  • Is there a way to link documents together?

    Okay basically, I'm new to macs, and I am a uni student so when i'm doing notes etc I have to open up a pages document and usually a pdf file on preview. I was wondering if there was any way to somehow link these two documents together so that when I open one of them, the other one opens... I don't know if maybe i could add the pages file as a comment to the pdf or something. And I don't want to just merge the two files together so that the pdf is at the end of the notes, I still want 2 documents that are seperate but open automatically together... I know that sounds so lazy but I have sooo many different files I need that it takes me forever to find the corresponding ones!
    Hope you can help!
    Shannon x

    In the words of the Rolling Stones, "you can't always get what you want."
    So you have documents that have unfilled pages, each of which has an assigned page number that you synched through the book panel, but now you want the text in these documents to flow as one continuous thread? How do you think InDesign is going to be able to thread text in different files, and what do you expect to happen to your page numbering?

  • Override Link Class in "Other CSS" Box

    Hi -is there a way to override the class of a link in the "other styles" box for a component?
    My example is this:
    I use a skin with a dark header. The text for the widgets in the header are white (Administration, etc)
    The body of the site is white.
    When I put another widget that uses the same class (x106 in this case) it makes the link color white and you can't see it on the page.
    I've tried many ways to go into the "other CSS" box (under the style tab) and none seem to work.
    Thanks.

    Hi - thanks.
    That's not exactly the problem. I know what the classes are (x106 and x107).
    The problem is that I am trying to use two "widgets" or ADF components (like the login/logout or My Favorites links) on two different background colors.
    I cannot get into the code of the ADF component to tell it to use a different class.
    Also, if I change the class (x106 for example) it changes ALL of them.
    What I think I need is a way to override the CSS for the link in the "Other CSS" box for that component somehow (I've tried many things - can't figure it out and not sure it can be done). I would think that this would override the class in the skin.
    In short - what I'm asking, I guess, is this.
    IS there a way to override the CSS LINK color for an ADF template component - OTHER THAN in the Skin's CSS file.
    Thanks!

  • Running 2 classes together

    I have 2 classes that i want to run together. They both have
    GUI components to run there separate methods. The code is long
    so i've shown the stripped down basic idea below.
    public class Class2 extends JFrame
         public Class2(String name)
                super(name);
              //Code for GUI
         public Class2()
              //Default constructor to access the class
         public void createPopupFrame()
              //code to show the Internal Frame
              frame.show();
         public static void main(String[] args)
              //Runs the GUI
              new Class2("Class2");
    } i want to call the method for the internal Frame ( createPopupFrame() ) from Class1
    while Class2 is running and therefore popUp that frame in class2.
    class Class1 extends JFrame
         //Various GUI components
           public Class1(String name)
                 super(name);
                //Code for GUI
                //Button to call the method callPopUP()
           public Class1()
                //Default constructor to access the class
         public void callPopUP()
              Class2 dis = new Class2();
              dis.createPopupFrame();
         public static void main(String[] args)
              //Runs the GUI
              new Class1("Class1");
         }//end main
    }I'm having trouble implementing this in java. I searched around the api
    and the forums and found some stuff about Runnable interface but i'm not really
    any the wiser. I've tested the createPopupFrame() method and i works fine from within
    class2.
    When i call it from class1 while class2 is running i get a NullPointerException. Although
    i expected this because i knew, that would just be too easy.
    Any help appreciated.

    Line 171 in class2I assumed line 171 referenced an object created
    somewhere in line 170.I believe this to be an incorrect assumption.
    and line 7 in class1I fail to see the null reference here by virtue of
    line 6.Typically , a stack trace shows a call sequence. Since line 7 calls the method containing line 171, if frame is null, the NPE stack sequence would show:
    NPE in line 171
    called from line 7
    OP. Try the following:
    public void createPopupFrame()
        //code to show the Internal Frame
        if ( frame != null )
            frame.show();
        else
            System.out.println( "The frame object has not been instantiated." );
    }Good luck.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

Maybe you are looking for

  • Error in pl/sql statement

    Hai All I have write a trigger in key next item to fetch the dates my code is go_item('Leave_date'); declare v_fromdate date; v_todate date; begin v_fromdate := :leave_data.from_date; v_todate := :leave_data.to_date; while v_fromdate <= v_todate loop

  • FCP wont open

    Just as the topic says, my Final Cut won't open. I have version 5.0.4 and have all of the system requirements for it. A few days ago my Mac was working just fine, today when I tried to open it, the loading screen popped up and then it went straight b

  • CFCs Not Recognized by Dreamweaver 8

    Am using Dreamweaver 8 and CF MX 7. All the CFCs I've created were created manually, not using Dreamweaver. I then copy the CFC, and modify it as needed for other applications in different folders. But all apps are part of the same SITE. By the way,

  • Ledger Currency

    Posting this on behalf of Daniel In SPRO transaction, through path: Financial Accounting (New) => Financial Accounting Global Settings (New) => Ledgers => Ledger => Define and Activate Non-Leading Ledgers It is possible to define the currencies for t

  • HT1199 How to make sure Mavericks will be compatible with other older software?

    What are the steps, prior to updating from Snow Leopard to Mavericks, to prevent conflicts with other, older software?