Help with TYPE and LIKE statements

HI guys,
I know this is really novice stuff, but I am a little confused.
Can anyone please explain the exact difference between TYPE and like with the help of a program, to understand it.
What situation would demand the use of each of the LIKE statement, since I can do all these things using the TYPE ?

Hi Akhil,
I summarized the info in SDN posts and SAP Help, to make it easier for you to understand. I also included some code snippets. Hope these prove to be helpful to you.
The following is from SAP Help:
The Additions TYPE and LIKE
The additions TYPE type and LIKE dobj are used in various ABAP statements. The additions can have various meanings, depending on the syntax and context.
·        Definition of local types in a program
·        Declaration of data objects
·        Dynamic creation of data objects
·        Specification of the type of formal parameters in subroutines
·        Specification of the type of formal parameters in methods
·        Specification of the type of field symbols
A known data type can be any of the following:
·        A predefined ABAP type to which you refer using the TYPE addition
·        An existing local data type in the program to which you refer using the TYPE addition
·        The data type of a local data object in the program to which you refer using the LIKE addition
·        A data type in the ABAP Dictionary to which you refer using the TYPE addition. To ensure compatibility with earlier releases, it is still possible to use the LIKE addition to refer to database tables and flat structures in the ABAP Dictionary. However, you should use the TYPE addition in new programs.
The LIKE addition takes its technical attributes from a visible data object. As a rule, you can use LIKE to refer to any object that has been declared using DATA or a similar statement, and is visible in the current context.  The data object only has to have been declared. It is irrelevant whether the data object already exists in memory when you make the LIKE reference.
·        In principle, the local data objects in the same program are visible. As with local data types, there is a difference between local data objects in procedures and global data objects. Data objects defined in a procedure obscure other objects with the same name that are declared in the global declarations of the program.
·        You can also refer to the data objects of other visible ABAP programs. These might be, for example, the visible attributes of global classes in class pools. If a global class cl_lobal has a public instance attribute or static attribute attr, you can refer to it as follows in any ABAP program:
DATA dref TYPE REF TO cl_global.
DATA:  f1 LIKE cl_global=>attr,
       f2 LIKE dref->attr.
You can access the technical properties of an instance attribute using the class name and a reference variable without first having to create an object. The properties of the attributes of a class are not instance-specific and belong to the static properties of the class.
Example
TYPES: BEGIN OF struct,
         number_1 TYPE i,
         number_2 TYPE p DECIMALS 2,
       END OF struct.
DATA:  wa_struct TYPE struct,
       number    LIKE wa_struct-number_2,
       date      LIKE sy-datum,
       time      TYPE t,
       text      TYPE string,
       company   TYPE s_carr_id.
This example declares variables with reference to the internal type STRUCT in the program, a component of an existing data object wa_struct, the predefined data object SY-DATUM, the predefined ABAP type t and STRING, and the data element S_CARR_ID from the ABAP Dictionary.
The following info is from various posts:
--> Type: It is used when userdefined object link with SAP system data type.
Local types mask global types that have the same names. When typing the interface parameters or field symbols, a reference is also possible to generic types ANY, ANY TABLE,INDEX TABLE, TABLE or STANDARD TABLE, SORTED TABLE and HASHED TABLE.
--> Like: It is when data object link with the other data object.
--> TYPE, you assign datatype directly to the data object while declaring.
--> LIKE,you assign the datatype of another object to the declaring data object. The datatype is referenced indirectly.
you can refer to all visible data objects at the ABAP program's positon in question. Only the declaration of the data object must be known. In this case it is totally irrelevant whether the data object already exists physically in
memory during the LIKE reference. Local data objects mask global data objects that have the same name.
--> Type is a keyword used to refer to a data type whereas Like is a keyword used to copy the existing properties of already existing data object.
Types: var1(20) type c.
data: var2 type var1. ( type is used bcoz var1 is defined with TYPES and it
does not occupy any memory spce.
data: var3 like var2. ( like is used here bcoz var2 is defined with DATA
so it does occupy space in memory ).
data: material like mara-matnr. ( like is used here bcoz mara-matnr is stored in memory)
--> Type refers the existing data type
--> Like refers the existing data object
Please Reward Points if any of the above points are helpful to you.
Regards,
Kalyan Chakravarthy

Similar Messages

  • Help with writing and retrieving data from a table field with type "LCHR"

    Hi Experts,
    I need help with writing and reading data from a database table field which has a type of "LCHR". I have given an example of the original code but don't know what to change it to in order to fix it and still read in the original data that's stored in the LCHR field.
    Basically we have two Function modules, one that saves list data to a database table and one that reads in this data. Both Function modules have an identicle table which has an array of fields from type INT4, CHAR, and type P. The INT4 field is the first one.
    Incidentally this worked in the 4.7 non-unicode system but is now dumping in the new ECC6 Unicode system.
    Thanks in advance,
    C
    SAVING THE LIST DATA TO DB
    DATA: L_WA(800).
    LOOP AT T_TAB into L_WA.
    ZDBTAB-DATALEN = STRLEN( L_WA ).
    MOVE: L_WA to ZDBTAB-RAWDATA.
    ZDBTAB-LINENUM = SY-TABIX.
    INSERT ZDBTAB.
    READING THE DATA FROM DB
    DATA: BEGIN OF T_DATA,
                 SEQNR type ZDBTAB-LINENUM,
                 DATA type ZDBTAB-RAWDATA,
               END OF T_TAB.
    Select the data.
    SELECT linenum rawdata from ZDBTAB into table T_DATA
         WHERE repid = w_repname
         AND rundate = w_rundate
         ORDER BY linenum.
    Populate calling Internal Table.
    LOOP AT T-DATA.
    APPEND T_DATA to T_TAB.
    ENDLOOP.

    Hi Anuj,
    The unicode flag is active.
    When I run our report and then to try and save the list data a dump is happening at the following point
    LOOP AT T_TAB into L_WA.
    As I say, T_TAB consists of different fields and field types whereas L_WA is CHAR 800. The dump mentions UC_OBJECTS_NOT_CONVERTIBLE
    When I try to load a saved list the dump is happening at the following point
    APPEND T_DATA-RAWDATA to T_TAB.
    T_DATA-RAWDATA is type LCHR and T_TAB consists of different fields and field types.
    In both examples the dumps mention UC_OBJECTS_NOT_CONVERTIBLE
    Regards
    C

  • Difference b/w DATA TYPE and DATA OBJECT & differences b/w TYPE and LIKE

    hai
    can any one say the differences between Data type and Data Object.
    And also differences between TYPE and LIKE
    thanks
    Gani

    hi,
    _Data Types and Data Objects_
          Programs work with local program data – that is, with byte sequences in the working memory. Byte sequences that belong together are called fields and are characterized by a length, an identity (name), and – as a further attribute – by a data type. All programming languages have a concept that describes how the contents of a field are interpreted according to the data type.
          In the ABAP type concept, fields are called data objects. Each data object is thus an instance of an abstract data type. There are separate name spaces for data objects and data types. This means that a name can be the name of a data object as well as the name of a data type simultaneously.
    Data Types
       As well as occurring as attributes of a data object, data types can also be defined independently. You can then use them later on in conjunction with a data object. The definition of a user-defined data type is based on a set of predefined elementary data types. You can define data types either locally in the declaration part of a program using the TYPESstatement) or globally in the ABAP Dictionary. You can use your own data types to declare data objects or to check the types of parameters in generic operations.
         All programming languages distinguish between various types of data with various uses, such as ….. type data for storing or displaying values and numerical data for calculations. The attributes in question are described using data types. You can define, for example, how data is stored in the repository, and how the ABAP statements work with the data.
    Data types can be divided into elementary, reference, and complex types.
    a. Elementary Types
    These are data types of fixed or variable length that are not made up of other types.
    The difference between variable length data types and fixed length data types is that the length and the memory space required by data objects of variable length data types can change dynamically during runtime, and that these data types cannot be defined irreversibly while the data object is being declared.
    Predefined and User-Defined Elementary Data Types
    You can also define your own elementary data types in ABAP using the TYPES statement. You base these on the predefined data types. This determines all of the technical attributes of the new data type. For example, you could define a data type P_2 with two decimal places, based on the predefined data type P. You could then use this new type in your data declarations.
    b.  Reference Types
    Reference types are deep data types that describe reference variables, that is, data objects that contain references. A reference variable can be defined as a component of a complex data object such as a structure or internal table as well as a single field.
    c. Complex Data Types
    Complex data types are made up of other data types. A distinction is made here between structured types and table types.
    Data Objects
          Data objects are the physical units with which ABAP statements work at runtime. The contents of a data object occupy memory space in the program. ABAP statements access these contents by addressing the name of the data object and interpret them according to the data type.. For example, statements can write the contents of data objects in lists or in the database, they can pass them to and receive them from routines, they can change them by assigning new values, and they can compare them in logical expressions.
           Each ABAP data object has a set of technical attributes, which are fully defined at all times when an ABAP program is running (field length, number of decimal places, and data type). You declare data objects either statically in the declaration part of an ABAP program (the most important statement for this is DATA), or dynamically at runtime (for example, when you call procedures). As well as fields in the memory area of the program, the program also treats literals like data objects.
            A data object is a part of the repository whose content can be addressed and interpreted by the program. All data objects must be declared in the ABAP program and are not persistent, meaning that they only exist while the program is being executed. Before you can process persistent data (such as data from a database table or from a sequential file), you must read it into data objects first. Conversely, if you want to retain the contents of a data object beyond the end of the program, you must save it in a persistent form.
    Declaring Data Objects
          Apart from the interface parameters of procedures, you declare all of the data objects in an ABAP program or procedure in its declaration part. These declarative statements establish the data type of the object, along with any missing technical attributes. This takes place before the program is actually executed. The technical attributes can then be queried while the program is running.
         The interface parameters of procedures are generated as local data objects, but only when the procedure is actually called. You can define the technical attributes of the interface parameters in the procedure itself. If you do not, they adopt the attributes of the parameters from which they receive their values.
    ABAP contains the following kinds of data objects:
    a.  Literals
    Literals are not created by declarative statements. Instead, they exist in the program source code. Like all data objects, they have fixed technical attributes (field length, number of decimal places, data type), but no name. They are therefore referred to as unnamed data objects.
    b.  Named Data Objects
    Data objects that have a name that you can use to address the ABAP program are known as named objects. These can be objects of various types, including text symbols, variables and constants.
    Text symbols are pointers to texts in the text pool of the ABAP program. When the program starts, the corresponding data objects are generated from the texts stored in the text pool. They can be addressed using the name of the text symbol.
    Variables are data objects whose contents can be changed using ABAP statements. You declare variables using the DATA, CLASS-DATA, STATICS, PARAMETERS, SELECT-OPTIONS, and RANGESstatements.
    Constants are data objects whose contents cannot be changed. You declare constants using the CONSTANTSstatement.
    c.  Anonymous Data  Objects
    Data objects that cannot be addressed using a name are known as anonymous data objects. They are created using the CREATE DATAstatement and can be addressed using reference variables.
    d.  System-Defined Data Objects
    System-defined data objects do not have to be declared explicitly - they are always available at runtime.
    e.  Interface Work Areas
    Interface work areas are special variables that serve as interfaces between programs, screens, and logical databases. You declare interface work areas using the TABLES and NODESstatements.
    What is the difference between Type and Like?
    Answer1:
    TYPE, you assign datatype directly to the data object while declaring.
    LIKE,you assign the datatype of another object to the declaring data object. The datatype is referenced indirectly.
    Answer2:
    Type is a keyword used to refer to a data type whereas Like is a keyword used to copy the existing properties of already existing data object.
    Answer3:
    type refers the existing data type
    like refers the existing data object
    reward if useful
    thanks and regards
    suma sailaja pvn

  • Help with count and sum query

    Hi I am using oracle 10g. Trying to aggregate duplicate count records. I have so far:
    SELECT 'ST' LEDGER,
    CASE
    WHEN c.Category = 'E' THEN 'Headcount Exempt'
    ELSE 'Headcount Non-Exempt'
    END
    ACCOUNTS,
    CASE WHEN a.COMPANY = 'ZEE' THEN 'OH' ELSE 'NA' END MARKET,
    'MARCH_12' AS PERIOD,
    COUNT (a.empl_id) head_count
    FROM essbase.employee_pubinfo a
    LEFT OUTER JOIN MMS_DIST_COPY b
    ON a.cost_ctr = TRIM (b.bu)
    INNER JOIN MMS_GL_PAY_GROUPS c
    ON a.pay_group = c.group_code
    WHERE a.employee_status IN ('A', 'L', 'P', 'S')
    AND FISCAL_YEAR = '2012'
    AND FISCAL_MONTH = 'MARCH'
    GROUP BY a.company,
    b.district,
    a.cost_ctr,
    c.category,
    a.fiscal_month,
    a.fiscal_year;
    which gives me same rows with different head_counts. I am trying to combine the same rows as a total (one record). Do I use a subquery?

    Hi,
    Whenever you have a problem, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) from all tables involved.
    Also post the results you want from that data, and an explanation of how you get those results from that data, with specific examples.
    user610131 wrote:
    ... which gives me same rows with different head_counts.If they have different head_counts, then the rows are not the same.
    I am trying to combine the same rows as a total (one record). Do I use a subquery?Maybe. It's more likely that you need a different GROUP BY clause, since the GROUP BY clause determines how many rows of output there will be. I'll be able to say more after you post the sample data, results, and explanation.
    You may want both a sub-query and a different GROUP BY clause. For example:
    WITH    got_group_by_columns     AS
         SELECT  a.empl_id
         ,     CASE
                        WHEN  c.category = 'E'
                  THEN  'Headcount Exempt'
                        ELSE  'Headcount Non-Exempt'
                END          AS accounts
         ,       CASE
                        WHEN a.company = 'ZEE'
                        THEN 'OH'
                        ELSE 'NA'
                END          AS market
         FROM              essbase.employee_pubinfo a
         LEFT OUTER JOIN  mms_dist_copy             b  ON   a.cost_ctr     = TRIM (b.bu)
         INNER JOIN       mms_gl_pay_groups        c  ON   a.pay_group      = c.group_code
         WHERE     a.employee_status     IN ('A', 'L', 'P', 'S')
         AND        fiscal_year           = '2012'
         AND        fiscal_month          = 'MARCH'
    SELECT    'ST'               AS ledger
    ,       accounts
    ,       market
    ,       'MARCH_12'          AS period
    ,       COUNT (empl_id)       AS head_count
    FROM       got_group_by_columns
    GROUP BY  accounts
    ,            market
    ;But that's just a wild guess.
    You said you wanted "Help with count and sum". I see the COUNT, but what do you want with SUM? No doubt this will be clearer after you post the sample data and results.
    Edited by: Frank Kulash on Apr 4, 2012 5:31 PM

  • MOVED: [Athlon64] Need Help with X64 and Promise 20378

    This topic has been moved to Operating Systems.
    [Athlon64] Need Help with X64 and Promise 20378

    I'm moving this the the Administration Forum.  It seems more apporpiate there.

  • Help with parsing an UPDATE statement

    I am stuck and need help! The teacher has not gone over parsing with us
    and it is not on his scheduled topics list. But, I am a person that likes to
    scope out and learn new things. For our final project, we have to allow
    updates, delete and inserts into the 5 main tables of the Premiere Products
    database. I have done everything except for the updates. I can achieve
    the updates of the entities by pretty much hardcoding them and that is
    okay by the teacher, but I want to learn about parsing because Barbara
    from this site mentioned this to me.
    This is what I was able to write and I am getting errors:
    CREATE OR REPLACE PROCEDURE updatecust_proc (
    v_cust_num IN customera.cust_num%TYPE,
    v_attributetoupdate VARCHAR2 ,
    v_updatedvalue VARCHAR2 )
    AS
    e_invalidcustnum_error EXCEPTION;
    BEGIN
    v_isvalidcustnum := iscust(v_cust_num);
    IF (v_isvalidcustnum = FALSE) THEN
    RAISE e_invalidcustnum_error;
    END IF;
    PARSE(
    'UPDATE customer
    SET' | | v_attributetoupdate | | '=' | | v_updatedvalue | |
    'WHERE cust_num =' | | v_cust_num
    END;
    EXCEPTION
    WHEN e_invalidcustnum_error THEN
    DBMS_OUTPUT.PUT_LINE('Cannot be updated. Invalid customer number');
    END;
    Any help would be useful. I went to the Oracle help site but their examples are a little too complicated for me to understand, plus, I am not using any C code.
    Thanks in advance!
    Bob

    Now we are getting somewhere. Identifier 'PARSE' must be declared.
    I again used the 'Search' link just above the forum posts and entered 'dbms_sql.parse' and got a short list of hits (as I suggested in my previous reply).
    There is one with Barbara's name on it. It shows exactly how to do what you are trying to do. In particular note her code:
    DBMS_SQL.PARSE
    (cursor_name,
    'UPDATE client SET '
    | | v_column
    | | ' = ' | | '''' | | v_new_data | | ''''
    | | ' WHERE account_id = '
    | | v_account_id,
    DBMS_SQL.NATIVE);
    Compare her PARSE statement to yours and you will see some major differences. The PARSE procedure is defined in the DBMS_SQL package and must be reference by DBMS_SQL.PARSE as Barbara shows.
    In addition to dynamic SQL using the DBMS_SQL package Oracle 8i also supports the EXEC IMMEDIATE statement.
    All of Oracle's documentation is available online via the 'Documentation' link on the left side of the OTN home page.
    The 'Supplied PL/SQL Packages Reference' has a chapter for each package (including DBMS_SQL) and describes the procedures/functions in the package and how to use them.
    The 'Application Developers Guide - Fundamentals' has chapters on 'processing SQL statements' and 'dynamic SQL' that go into some detail on performing dynamic sql.
    Yes, Barbara's code uses a CURSOR. The DBMS_SQl package requires it and so does your code. Almost all SQL uses a CURSOR either implicitly or explicitly.
    My comments are not, and were not, directed at you personally so I hope you don't take them that way.
    Your latest reply has a lot of useful information in it.
    1. 19/1 PLS-00201: identifier 'PARSE' must be declared. This is the explicit error message we need to help someone. We don't have to guess which error they are talking about. We can look it up in the MESSAGES manual if necessary. When someone says 'I get an error', or 'I get a PARSE error' we can only guess which error they are talking about.
    In your reply you state that you looked at Barbara's code, she uses a cursor and you don't need a cursor. That is very useful information to someone trying to help you because it tells us two things: you are trying to find the answer for yourself (a lot of people just want someone to write the code for them) and it shows that you haven't made the connection between Barbara's example (which shows EXACTLY what you need to do) and your own code.
    This is a public forum and I have found it useful to keep repeating certain suggestions.
    For whatever reason many people still do not seem to realize that:
    1. ALL of Oracle's documentation is available on-line via the 'Documentation' link on the left side of the OTN main page.
    2. You can purchase (for about $50) a CD-ROM that has all of the Oracle documentation on it in both PDF and HTML format.
    3. The 'search' link just above each discussion forum allows one to search any or all forums for topics, users, etc.
    The above resources should be used by everyone.
    Good luck!
    null

  • Difference between TYPE and LIKE?

    data: a type "a data element",
            b like a.
    I know the basic difference of these two statement. But what is the insight?

    Have a look at below links:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb367a358411d1829f0000e829fbfe/content.htm
    http://help.sap.com/saphelp_nw2004s/helpdata/en/fc/eb2ff3358411d1829f0000e829fbfe/frameset.htm
    If you use the addition TYPE, you can either reference to an inbuilt ABAP type, a predefined elementary type in the local program, or to a data element defined in the ABAP Dictionary. If you use a LIKE reference, dobj can be an existing data object with an elementary data type. If you do not use the TYPE or LIKE addition, the system uses the default predefined type c.
    In other words, LIKE means the datatype of the variable is similar to the referenced variable.
    TYPE means it is a predefined data type.
    Eg:
    DATA int TYPE i.
    Here int is of integer data type.
    DATA var LIKE int.
    var IS a variable having same data type of int. which in turn is integer.
    You can find these helpful when you reference database table variables... You need not know what is the datatype defined.
    Also it adds to FLEXIBILITY.
    Whenever you make changes to your database tables and fields, that change is REFLECTED back to your program that is, You need not change all your program code when you change your table fields...
    I hope it helps.
    Best Regards,
    Vibha
    *Please mark all the helpful answers

  • Help with encapsulation and a specific case of design

    Hello all. I have been playing with Java (my first real language and first OOP language) for a couple months now. Right now I am trying to write my first real application, but I want to design it right and I am smashing my head against the wall with my data structure, specifically with encapsulation.
    I go into detail about my app below, but it gets long so for those who don't want to read that far, let me just put these two questions up front:
    1) How do principles of encapsulation change when members are complex objects rather than primitives? If the member objects themselves have only primitive members and show good encapsulation, does it make sense to pass a reference to them? Or does good encapsulation demand that I deep-clone all the way to the bottom of my data structure and pass only cloned objects through my top level accessors? Does the analysis change when the structure gets three or four levels deep? Don't DOM structures built of walkable nodes violate basic principles of encapsulation?
    2) "Encapsulation" is sometimes used to mean no public members, othertimes to mean no public members AND no setter methods. The reasons for the first are obvious, but why go to the extreme of the latter? More importantly HOW do you go to the extreme of the latter? Would an "updatePrices" method that updates encapsulated member prices based on calculations, taking a single argument of say the time of year be considered a "setter" method that violates the stricter vision of encapsulation?
    Even help with just those two questions would be great. For the masochistic, on to my app... The present code is at
    http://www.immortalcoil.org/drake/Code.zip
    The most basic form of the application is statistics driven flash card software for Japanese Kanji (Chinese characters). For those who do not know, these are ideographic characters that represent concepts rather than sounds. There are a few thousand. In abstract terms, my data structure needs to represent the following.
    -  There are a bunch of kanji.
       Each kanji is defined by:
       -  a single character (the kanji itself); and
       -  multiple readings which fall into two categories of "on" and "kun".
          Each reading is defined by:
          -  A string of hiragana or katakana (Japanese phoenetic characters); and
          -  Statistics that I keep to represent knowledge of that reading/kanji pair.Ideally the structure should be extensible. Later I might want to add statistics associated with the character itself rather than individual readings, for example. Right now I am thinking of building a data structure like so:
    -  A Vector that holds:
       -  custom KanjiEntry objects that each hold
          -  a kanji in a primitive char value; and
          -  two (on, kun) arrays or Vectors of custom Reading objects that hold
             -  the reading in a String; and
             -  statistics of some sort, probably in primitive valuesFirst of all, is this approach sensible in the rough outlines?
    Now, I need to be able to do the obvious things... save to and load from file, generate tables and views, and edit values. The quesiton of editting values raises the questions I identified above as (1) and (2). Say I want to pull up a reading, quiz the user on it, and update its statistics based on whether the user got it right or wrong. I could do all this through the KanjiEntry object with a setter method that takes a zillion arguments like:
    theKanjiEntry.setStatistic(
    "on",   // which set of readings
    2,      // which element in that array or Vector
    "score", // which statistic
    98);      // the valueOr I could pass a clone of the Reading object out, work with that, then tell the KanjiEntry to replace the original with my modified clone.
    My instincts balk at the first approach, and a little at the second. Doesn't it make more sense to work with a reference to the Reading object? Or is that bad encapsulation?
    A second point. When running flash cards, I do not care about the subtlties of the structure, like whether a reading is an on or a kun (although this is important when browsing a table representing the entire structure). All I really care about is kanij/reading pairings. And I should be able to quickly poll the Reading objects to see which ones need quizzing the most, based on their statistics. I was thinking of making a nice neat Hashtable with the keys being the kanji characters in Strings (not the KanjiEntry objects) and the values being the Reading objects. The result would be two indeces to the Reading objects... the basic structure and my ad hoc hashtable for runninq quizzes. Then I would just make sure that they stay in sync in terms of the higher level structure (like if a whole new KanjiEntry got added). Is this bad form, or even downright dangerous?
    Apart from good form, the other consideration bouncing around in my head is that if I get all crazy with deep cloning and filling the bottom level guys with instance methods then this puppy is going to get bloated or lag when there are several thousand kanji in memory at once.
    Any help would be appreciated.
    Drake

    Usually by better design. Move methods that use the
    getters inside the class that actually has the data....
    As a basic rule of thumb:
    The one who has the data is the one using it. If
    another class needs that data, wonder what for and
    consider moving that operation away from that class.
    Or move from pull to push: instead of A getting
    something from B, have B give it to A as a method
    call argument.Thanks for the response. I think I see what you are saying.. in my case it is something like this.
    Solution 1 (disfavored):
    public class kanjiDrill{ // a chunk of Swing GUI or something
         public void runDrill(Vector kanjiEntries){
              KanjiEntry currentKanjiEntry = kanjiEntries.elementAt(0); // except really I will pick one randomly
              char theKanji = currentKanjiEntry.getKanji();
              String theReading = currentKanjiEntry.getReading();
              // build and show a flashcard based on theKanji and theReading
              // use a setter to change currentKanji's data based on whether the user answers correctly;
    }Solution 2 (favored):
    public class kanjiDrill{ // a chunk of Swing GUI or something
         public void runDrill(Vector kanjiEntries){
              KanjiEntry currentKanjiEntry = kanjiEntries.elementAt(0); // except really I will pick one randomly
              currentKanji.buildAndShowFlashcard(); // method includes updating stats
    }I can definitely see the advantages to this, but two potential reasons to think hard about it occur to me right away. First, if this process is carried out to a sufficient extreme the objects that hold my data end up sucking in all the functionality of my program and my objects stop resembling natural concepts.
    In your shopping example, say you want to generate price tags for the items. The price tags can be generated with ONLY the raw price, because we do not want the VAT on them. They are simple GIF graphics that have the price printed on a an irregular polygon. Should all that graphics generating code really go into the item objects, or should we just get the price out of the object with a simple getter method and then make the tags?
    My second concern is that the more instance methods I put into my bottom level data objects the bigger they get, and I intend to have thousands of these things in memory. Is there a balance to strike at some point?
    It's not really a setter. Outsiders are not setting
    the items price - it's rather updating its own price
    given an argument. This is exactly how it should be,
    see my above point. A breach of encapsulation would
    be: another object gets the item price, re-calculates
    it using a date it knows, and sets the price again.
    You can see yourself that pushing the date into the
    item's method is much beter than breaching
    encapsulation and getting and setting the price.So the point is not "don't allow access to the members" (which after all you are still doing, albeit less directly) so much as "make sure that any functionality implicated in working with the members is handled within the object," right? Take your shopping example. Say we live in a country where there is no VAT and the app will never be used internationally. Then we would resort to a simple setter/getter scheme, right? Or is the answer that if the object really is pure data are almost so, then it should be turned into a standard java.util collection instead of a custom class?
    Thanks for the help.
    Drake

  • Help with Facebook and Social Media wigets (Was: How do I fix the three probs that...)

    I am having problems with the facebook or social media widgets. I would like the link to send viewers to my facebook business page, but when testing it shows my pic and a 'switch' sign (see screen shot) and when I open the site the message is as the other screenshot, great, but I don't know where to find which 'asset' is the problem and why. Also why bother having child pages if the menu doesn't reflect that? I see that drop down menus are an issue, also with some other forum members.
    Thanks for any help offered!, I think I have solved the first problem now but still would appreciate any help with the other 2!
    For some reason the facebook widget now loads the correct page, and I give up about the drop down menu, hopefully this will be addressed in the next update of Muse??

    Hello,
    For the "asset" issue, try locating the asset in the assets panel. It should have an icon like this: http://jingsite.businesscatalyst.com/jing/2013-12-16_0917.png
    For the child pages in the menus issue, go to the menu options (by clicking the small blue arrow in the right top corner of the menu), and then change the menu type to "All Pages" instead of "Top Level Pages".
    Hope this helps.
    Cheers
    Parikshit

  • Time variables with if and else statements for class script

    Hello, for an in class assignment to create a script using random generated answers im trying to get the script set up for different answers depending on the time of day here is what i have so far, in bold is my second time that i would like to have if the
    time is 6pm, the one that works right now is the one that is anything greater then 12pm and the one that is everything before 12pm the 6pm will not work:
    #Clear the Windows command console screen
    Clear-Host
    #Define the variables used in this script to collect player inputs
    $question = ""   #This variables will store the player's question
    $status = "Play"  #This variable will be used to control game termination
    $answer = 0  #This variable stores a randomly genrated number
    $time = (Get-Date).Hour  #This variable stores the current hour of the day
    #Display the game's opening screen
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host "               W E L C O M E   T O   T H E   W I N D O W S"
    Write-Host
    Write-Host
    Write-Host
    Write-Host "            P O W E R S H E L L   F O R T U N E   T E L L E R"
    Write-Host
    Write-Host
    Write-Host   
    Write-Host "                          By Zelandra"
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host " Press Enter to continue."
    #Pause script execution and wait for the player to press the Enter key
    Read-Host
    #Clear the Windows command console screen
    Clear-Host  
    #Provide the player with instructions
    Write-Host
    Write-Host " The fortune teller is a very busy and impatient mystic. Make"
    Write-Host 
    Write-Host " your questions brief and simple and only expect to receive"
    Write-Host
    Write-host " Yes / No styled answers."   
    Write-Host 
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host " Press Enter to continue."
    #Pause script execution and wait for the player to press the Enter key
    Read-Host
    #Continue game play until the player decides to stop
    while ($status -ne "Stop") {
      #Ask the player the first question
      while ($question -eq ""){
        Clear-Host  #Clear the Windows command console screen
        Write-Host
        $question = read-host " What is your question? "
      $question = ""  #Reset variable to a empty string
      #Retrieve a random number between 1 and 7
      $answer = Get-Random -minimum 1 -maximum 8
      #If it is the night the fortune teller will be a little more cranky 
      if ($time -gt 18) {
        Write-Host
        if ($answer -eq 1) { " Grrrr. The answer is NO, now let me get back to sleep!" }
        if ($answer -eq 2) { " Grrrr. The answer is !!!NEVER!!!" }
        if ($answer -eq 3) { " Grrrr. The answer is unclear, did you really think i would know?" }
        if ($answer -eq 4) { " Grrrr. The answer is sure whatever!" }
        if ($answer -eq 5) { " Grrrr. Even if i wanted to tell your fortune i wouldnt!" }
        if ($answer -eq 6) { " Grrrr. Look at the time, im busy SLEEPING!" }
        if ($answer -eq 7) { " Grrrr. Take whatever answer you want and leave me alone!" }
      #Select an answer based on the time and the random number
      #If it is the afternoon the fortune teller will be a little cranky
      if ($time -gt 12) {
        Write-Host
        if ($answer -eq 1) { " Grrrr. The answer is no!" }
        if ($answer -eq 2) { " Grrrr. The answer is never" }
        if ($answer -eq 3) { " Grrrr. The answer is unclear!" }
        if ($answer -eq 4) { " Grrrr. The answer is yes!" }
        if ($answer -eq 5) { " Grrrr. The answer is absolutely not!" }
        if ($answer -eq 6) { " Grrrr. The answer is unforseeable!" }
        if ($answer -eq 7) { " Grrrr. Im sorry could you repeat that?" }
      #If it is morning the fortune teller will be in a good mood
      else {
        Write-Host
        if ($answer -eq 1) { " Ah. The answer is yes!" }
        if ($answer -eq 2) { " Ah. The answer is Always" }
        if ($answer -eq 3) { " Ah. The answer is uncertain!" }
        if ($answer -eq 4) { " Ah. The answer is no!" }
        if ($answer -eq 5) { " Ah. The answer is there is a fair cha... OH LOOK A SQUIRREL!" }
        if ($answer -eq 6) { " Ah. I think you meant to ask something else!" }
        if ($answer -eq 7) { " Ah. Well it looks like your wish will be ready tonight!" }
      Write-Host
      Write-Host
      Write-Host
      Write-Host
      Write-Host
      Write-Host
      Write-Host
      Write-Host
      Write-Host
      Write-Host
      Write-Host
      Write-Host
      Write-Host
      Write-Host
      Write-Host
      Write-Host
      Write-Host
      Write-Host
      Write-Host
      Write-Host " Press Enter to continue."
      #Pause script execution and wait for the player to press the Enter key
      Read-Host
      #Clear the Windows command console screen
      Clear-host
      Write-Host
      #Prompt the player to continue or quit
      $reply = read-host " Press Enter to ask another question or type Q to quit."
      if ($reply -eq "q") { $status = "Stop" }
    #Clear the Windows command console screen
    Clear-Host
    #Provide the player with instructions
    Write-Host 
    Write-Host " Very well then. Please return again to get all your questions"
    Write-Host " answered." 
    Write-Host
    Write-Host 
    Write-Host
    Write-Host
    Write-Host
    Write-Host 
    Write-Host
    Write-Host
    Write-Host  
    Write-Host 
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host 
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host
    Write-Host " Press Enter to continue."
    #Pause script execution and wait for the player to press the Enter key
    Read-Host
    #Clear the Windows command console screen
    Clear-Host  
    Thanks again if anyone can provide help.

    Hi,
    Use -and in your afternoon if test.
    Don't retire TechNet! -
    (Don't give up yet - 12,950+ strong and growing)

  • Help with Importing and Editing an Image

    Hello All,
    I am working on a project where I need to import an image into LabView and edit it. The gist of my program is that I want to create a VI that generates an interactive floorplan.
    I want to be able to import the bitmap or png into my file so I can edit the file by assigning flashing colors to each room, etc.
    I tried to import the .png by wiring "Read png" --> "Draw Flattened Pixmap" --> "new picture".
    When I run the program I get a "general I/O" error in the "Read PNG" block even though it lets me select which png I can import.
    Does LabVIEW 8.5 not allow for importing PNG files? Does anyone have any idea why I am getting this error?
    On another note, I was reading about some of the IMAQ VI's and they seem like they may work for importing an image and creating graphics, etc. Should I try to delve a little deeper into the IMAQ stuff?
    Thanks much for the help!

    Great call on checking whether it was just a bad file.
    I tried to convert it from a .bmp to a .png by simply renaming it which LabVIEW did not like...
    So I just opened it up and re-saved it with photo editing software and it worked!
    Now I just have to play around with my editing options to get the graphics I want. 
    I'll post some sample code just for suggestions that anyone may have. This is just my preliminary structure without most of my condition statements. All the code inside the case structures will be added when I figure all this stuff out.
    My goal is to have each strobe and interlock correspond to a different graphic on the floorplan. For example, when strobe 1 reads red, I want the corresponding room to flash red and vice versa with green and yellow. Also, when interlock 1 reads false, I want a flashing light to pop up next to the corresponding door.  
    Anyone have any ideas for how to make these kinds of graphics? I figured I may be able to use a color box for the solid colors and LEDs for the flashing lights but I would rather edit the pixels to make it look more professional.
    Thanks for all the help!
    Attachments:
    LabStatusProgram.vi ‏9 KB

  • Help with httprequests and responses

    it is my first time writing a servlet, but i need one to work with a project i'm working on. I have a class that will do all the methods on the server side of the project, but my problem now which i need to resolve, is how to get my client side app (made in flash mx) to work with my servlet and communicate the xml information i'm getting on the server back and forth.
    I know that you must answer a httpRequest in the servlet, and i know this must be sent somehow from the clientside app, but i need information and help on how to get information sent in this request the right way, and also help on how to properly format a response that will work.
    from what i know so far- it looks like the type of client-side app isn't important, as long as the request is sent right- so knowing that, flash and java should work fine in communication as long as flash sends a valid request and java answers it right.
    could anyone help me with information and/or help about how the requests and responses send information and what code you need to write to get information (even generalized code will work)
    Help would be really really appreciated.
    -mike

    To get data to and from the server and client, you'll have to seriaze it at one end and deserialize it at the other end.
    I don't know much about Flash MX but a java program on the client can exchange data with a servlet using the above means.
    For example, to read a string from a servlet using a java program on the client, you do the following:
    On the servlet:
    1. set content type to 'application/x-java-serialized-object'
    2. Get an output stream thus:
    ObjectOutputStream outStream =
    new ObjectOutputStream(response.getOutputStream());
    3. Write the data and flush the stream to be sure that all content has been sent:
    outStream.writeObject(myString);
    outStream.flush();
    On the client (java prog):
    1. get a URL: URL dataURL = new URL(protocol, host, port, address)
    2. connect to the URL: URLConnection connection = dataURL.openConnection();
    3. for fresh results everytime, turn off caching:
    connection.setUseCaches(false)
    4. get an input stream:
    ObjectInputStream in = new ObjectInputStream(connection.getInputStream());
    5. Get your string thus:
    String myString = (String) in.readObject();
    This is a very simplified example (you'll have to catch exception an a reall application).
    I recommend the book 'Core Servlet and JavaServer Pages' by Marty Hall
    http://www.coreservlets.com

  • Help with treemap and other stuff

    hi guys..
    i m new to this forum..
    and this is my first post....so if i act a little naive .....please bare with me.
    and if this is not the correct place to post ..i m sorry for that.
    i have an assignment to submit....i m getting the whole picture ....but not sure how to go about implementing it.
    here it is...
    Write an Object Oriented solution to the problem in Java. The solution is to consist of:
    A TableIndex class
    A TableNavigator Interface
    A data row class ....class that i have to create.
    An application class to use and test your TableIndex class
    The following UML class diagrams show the public methods of the classes. Other methods may be specified. Specify data members, inner classes and interfaces as appropriate.
    TableIndex Class
    The TableIndex class is an index to a collection of objects. The class is to approximate an index to a data table in memory that consists of a number of rows. To control access to the index a current row is defined that specifies the row that can be accessed. To retrieve a row from the index it must be the current row. The get() method is the only method in TableIndex class that retrieves a row from the index. The current row can be changed explicitly using the methods: previous(), next(), first(), last(), gotoBookmark and find(K); and implicitly using insert(K, V), modify(K, V) and remove().
    The TableIndex class is to be implemented using the java API's TreeMap class and must use Generics. The data types K and V below are generic types for the Key and Value (row) respectively. An important aspect of the assignment is using the Java API documentation to understand the TreeMap class.
    guys ....can u plz help with the starting bit ..
    what should be the opening statement of the class...
    public class TableIndex<K , V> .....????
    and what should be the treemap declaration..??
    TreeMap<K , V> indexTable = new TreeMap<K , V>();...???
    i m confused....
    can u plz explain to me..

    hi mate.....didnt quite get you..
    can u plz be a bit more simple in explanation..!!!
    i will post the whole question ..so that anyone reading will understand better....
    Problem Description
    You are to develop an index class and associated classes.
    Requirements
    Write an Object Oriented solution to the problem in Java. The solution is to consist of:
    A TableIndex class
    A TableNavigator Interface
    A data row class
    An application class to use and test your TableIndex class
    The following UML class diagrams show the public methods of the classes. Other methods may be specified. Specify data members, inner classes and interfaces as appropriate.
    TableIndex Class
    The TableIndex class is an index to a collection of objects. The class is to approximate an index to a data table in memory that consists of a number of rows. To control access to the index a current row is defined that specifies the row that can be accessed. To retrieve a row from the index it must be the current row. The get() method is the only method in TableIndex class that retrieves a row from the index. The current row can be changed explicitly using the methods: previous(), next(), first(), last(), gotoBookmark and find(K); and implicitly using insert(K, V), modify(K, V) and remove().
    The TableIndex class is to be implemented using the java API's TreeMap class and must use Generics. The data types K and V below are generic types for the Key and Value (row) respectively. An important aspect of the assignment is using the Java API documentation to understand the TreeMap class.
    TableIndex
    +TableIndex()
    +TableIndex(name: String, comp: Comparator)
    +getName(): String
    +isEmpty(): Boolean
    +size(): Integer
    +hasPrevious(): Boolean
    +hasNext(): Boolean
    +previous()
    +next()
    +first()
    +last()
    +setBookmark(): Boolean
    +clearBookmark()
    +gotoBookmark(): Boolean
    +contains(key: K): Boolean
    +find(key: K): Boolean
    +get(): V
    +insert(key:K, value: V): Boolean
    +modify(value: V): Boolean
    +modify(key: K, value: V): Boolean
    +remove(): V
    +iterator(): Iterator
    +equals(obj2: Object): Boolean
    +toString(): String
    Additional Notes:
    The table index has an order defined by the compareTo method of the key's class or by the compare method specified in the class that implements the Comparator interface.
    getName(): the name of the index, blank by default.
    isEmpty(): returns true if there aren't any rows in the table index
    size(): returns the number of rows in the table index
    hasPrevious(): returns true if there is a row before the current row.
    hasNext(): returns true if there is a row after the current row in sequence.
    previous(): if there is a row before the current row, move to the row and make it the new current row.
    next() if there is a row after the current row, move to the row and make it the new current row.
    first(): if the table isn't empty, move to the first row and make it the new current row.
    last(): if the table isn't empty, move to the last row and make it the new current row.
    setBookmark(): sets a bookmark at the current row. If the bookmark is successfully set the method returns true. The bookmark is cleared if the TableIndex is empty or the row the bookmark was set on is deleted..
    clearBookmark(): sets the bookmark to null, indicating there isn't a bookmark.
    gotoBookmark(): if a bookmark has been set, go to the bookmarked row. If successful the book marked row becomes the current row and the method returns true.
    contains(K): return true if a row with the key specified exists.
    find(K): if a row is found with the specified key, the current row is set to the row found.
    get(): returns the current row. Null is returned if there isn't a current row.
    insert(K, V): inserts a row (value) with the key specified. The key must not be null and must be unique (not already in the TableIndex). The row (value) must not be null. If the row is successfully inserted true is returned, and the row becomes the current row..
    modify(V): change the current row's data to the row (value) specified. The key and the current row key are to remain the same. If successful true is returned.
    modify(K, V): change the current row's key and data to the key and row (value) specified. If successful the changed row becomes the new current row. If successful true is returned. Note: this is more difficult than modify(V).
    remove(): remove the current row. When a row is deleted the next row (if available) becomes the current row, otherwise if there isn't a next row the previous row becomes the current row, otherwise the table is empty therefore the current row is null.
    iterator(): returns an iterator to the rows (values) in the index. The rows are to be retrieved in order. The remove method does not need to be implemented (its method body can be empty)..
    the equals method uses the name, and the rows (values) in order when testing for equality.
    the toString method should return appropriately formatted data members and the rows (values/data) in the index.
    TableNavigator Interface
    «interface»
    TableNavigator
    +isEmpty(): Boolean
    +hasPrevious(): Boolean
    +hasNext(): Boolean
    +previous()
    +next()
    +first()
    +last()
    +contains(key: K): Boolean
    +find(key: K): Boolean
    Additional Notes:
    The TableIndex class implements the TableNavigator Interface.
    The purpose of the above methods is outlined in the TableIndex class.
    Your Data Row Class
    You are to include a class of your own to represent a row of data in the TableIndex. This is not to be a class that was covered in other programming subjects. It does not need to be complex but must include a range of data types. This class will be used to test your TableIndex class. The class should have an appropriate name and deal with something of interest to you.
    Your Application Class
    The application class is to make use of the TableIndex class and your data row class. It is to clearly show how the TableIndex class is used, and in doing so, test it. The class should have an appropriate name. The application class should create two indexes of different key data types. One of the indexes must make use of the Comparator interface to have a key that is in descending order.
    Output
    Output in the test classes/programs is to go to standard out or a text file. There should be no output from the TableIndex class or your data row class. A GUI interface is NOT required. There is no need to input data from the keyboard or file. Use the Unix script command or write output to a text file (etc) to provide example runs of your test programs.

  • Help with Mathscipt and for loop

    I have a code in Mathscript/matlab and I need to output the array out. One option is my first code,the other option is using a for loop, but I am only getting the last ouput out. I need to get the whole output out.
    Any help.
    Thanks
    Solved!
    Go to Solution.
    Attachments:
    Help with Mathscript_for loop.vi ‏115 KB
    Help with Mathscript_for loop2.vi ‏84 KB

    Here's how it should look like.
    Message Edited by altenbach on 10-30-2008 05:12 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    MathscriptInFOR.png ‏15 KB

  • Need help with JTextArea and Scrolling

    import java.awt.*;
    import java.awt.event.*;
    import java.text.DecimalFormat;
    import javax.swing.*;
    public class MORT_RETRY extends JFrame implements ActionListener
    private JPanel keypad;
    private JPanel buttons;
    private JTextField lcdLoanAmt;
    private JTextField lcdInterestRate;
    private JTextField lcdTerm;
    private JTextField lcdMonthlyPmt;
    private JTextArea displayArea;
    private JButton CalculateBtn;
    private JButton ClrBtn;
    private JButton CloseBtn;
    private JButton Amortize;
    private JScrollPane scroll;
    private DecimalFormat calcPattern = new DecimalFormat("$###,###.00");
    private String[] rateTerm = {"", "7years @ 5.35%", "15years @ 5.5%", "30years @ 5.75%"};
    private JComboBox rateTermList;
    double interest[] = {5.35, 5.5, 5.75};
    int term[] = {7, 15, 30};
    double balance, interestAmt, monthlyInterest, monthlyPayment, monPmtInt, monPmtPrin;
    int termInMonths, month, termLoop, monthLoop;
    public MORT_RETRY()
    Container pane = getContentPane();
    lcdLoanAmt = new JTextField();
    lcdMonthlyPmt = new JTextField();
    displayArea = new JTextArea();//DEFINE COMBOBOX AND SCROLL
    rateTermList = new JComboBox(rateTerm);
    scroll = new JScrollPane(displayArea);
    scroll.setSize(600,170);
    scroll.setLocation(150,270);//DEFINE BUTTONS
    CalculateBtn = new JButton("Calculate");
    ClrBtn = new JButton("Clear Fields");
    CloseBtn = new JButton("Close");
    Amortize = new JButton("Amortize");//DEFINE PANEL(S)
    keypad = new JPanel();
    buttons = new JPanel();//DEFINE KEYPAD PANEL LAYOUT
    keypad.setLayout(new GridLayout( 4, 2, 5, 5));//SET CONTROLS ON KEYPAD PANEL
    keypad.add(new JLabel("Loan Amount$ : "));
    keypad.add(lcdLoanAmt);
    keypad.add(new JLabel("Term of loan and Interest Rate: "));
    keypad.add(rateTermList);
    keypad.add(new JLabel("Monthly Payment : "));
    keypad.add(lcdMonthlyPmt);
    lcdMonthlyPmt.setEditable(false);
    keypad.add(new JLabel("Amortize Table:"));
    keypad.add(displayArea);
    displayArea.setEditable(false);//DEFINE BUTTONS PANEL LAYOUT
    buttons.setLayout(new GridLayout( 1, 3, 5, 5));//SET CONTROLS ON BUTTONS PANEL
    buttons.add(CalculateBtn);
    buttons.add(Amortize);
    buttons.add(ClrBtn);
    buttons.add(CloseBtn);//ADD ACTION LISTENER
    CalculateBtn.addActionListener(this);
    ClrBtn.addActionListener(this);
    CloseBtn.addActionListener(this);
    Amortize.addActionListener(this);
    rateTermList.addActionListener(this);//ADD PANELS
    pane.add(keypad, BorderLayout.NORTH);
    pane.add(buttons, BorderLayout.SOUTH);
    pane.add(scroll, BorderLayout.CENTER);
    addWindowListener( new WindowAdapter()
    public void windowClosing(WindowEvent e)
    System.exit(0);
    public void actionPerformed(ActionEvent e)
    String arg = lcdLoanAmt.getText();
    int combined = Integer.parseInt(arg);
    if (e.getSource() == CalculateBtn)
    try
    JOptionPane.showMessageDialog(null, "Got try here", "Error", JOptionPane.ERROR_MESSAGE);
    catch(NumberFormatException ev)
    JOptionPane.showMessageDialog(null, "Got here", "Error", JOptionPane.ERROR_MESSAGE);
    if ((e.getSource() == CalculateBtn) && (arg != null))
    try{
    if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 1))
    monthlyInterest = interest[0] / (12 * 100);
    termInMonths = term[0] * 12;
    monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest,  -termInMonths))));
    lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
    if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 2))
    monthlyInterest = interest[1] / (12 * 100);
    termInMonths = term[1] * 12;
    monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest,  -termInMonths))));
    lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
    if ((e.getSource() == CalculateBtn) && (rateTermList.getSelectedIndex() == 3))
    monthlyInterest = interest[2] / (12 * 100);
    termInMonths = term[2] * 12;
    monthlyPayment = combined * (monthlyInterest / (1 - (Math.pow (1 + monthlyInterest,  -termInMonths))));
    lcdMonthlyPmt.setText(calcPattern.format(monthlyPayment));
    catch(NumberFormatException ev)
    JOptionPane.showMessageDialog(null, "Invalid Entry!\nPlease Try Again", "Error", JOptionPane.ERROR_MESSAGE);
    }                    //IF STATEMENTS FOR AMORTIZATION
    if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 1))
    loopy(7, 5.35);
    if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 2))
    loopy(15, 5.5);
    if ((e.getSource() == Amortize) && (rateTermList.getSelectedIndex() == 3))
    loopy(30, 5.75);
    if (e.getSource() == ClrBtn)
    rateTermList.setSelectedIndex(0);
    lcdLoanAmt.setText(null);
    lcdMonthlyPmt.setText(null);
    displayArea.setText(null);
    if (e.getSource() == CloseBtn)
    System.exit(0);
    private void loopy(int lTerm,double lInterest)
    double total, monthly, monthlyrate, monthint, monthprin, balance, lastint, paid;
    int amount, months, termloop, monthloop;
    String lcd2 = lcdLoanAmt.getText();
    amount = Integer.parseInt(lcd2);
    termloop = 1;
    paid = 0.00;
    monthlyrate = lInterest / (12 * 100);
    months = lTerm * 12;
    monthly = amount *(monthlyrate/(1-Math.pow(1+monthlyrate,-months)));
    total = months * monthly;
    balance = amount;
    while (termloop <= lTerm)
    displayArea.setCaretPosition(0);
    displayArea.append("\n");
    displayArea.append("Year " + termloop + " of " + lTerm + ": payments\n");
    displayArea.append("\n");
    displayArea.append("Month\tMonthly\tPrinciple\tInterest\tBalance\n");
    monthloop = 1;
    while (monthloop <= 12)
    monthint = balance * monthlyrate;
    monthprin = monthly - monthint;
    balance -= monthprin;
    paid += monthly;
    displayArea.setCaretPosition(0);
    displayArea.append(monthloop + "\t" + calcPattern.format(monthly) + "\t" + calcPattern.format(monthprin) + "\t");
    displayArea.append(calcPattern.format(monthint) + "\t" + calcPattern.format(balance) + "\n");
    monthloop ++;
    termloop ++;
    public static void main(String args[])
    MORT_RETRY f = new MORT_RETRY();
    f.setTitle("MORTGAGE PAYMENT CALCULATOR");
    f.setBounds(600, 600, 500, 500);
    f.setLocationRelativeTo(null);
    f.setVisible(true);
    }need help with displaying the textarea correctly and the scroll bar please.
    Message was edited by:
    new2this2020

    What's the problem you're having ???
    PS.

Maybe you are looking for