Dynamically growing JList

I have created a JList which grows according to information received over a serial port, but can't figure out how to make the JList (contained in JScrollPane) show the last element that has been added.
I have set JList.setVisibleRowCount(5), so that a scroll bar appears in the JScrollPane when the size of the list goes over 5, but can't get it to scroll down and show the last element in the list.
Anybody know how I could do this?
Thanks, Nick.
PS: using JList.setSelectedIndex(index) doesn't work. It just selects the item, but doesn't center on that item.

Doesn't matter how many times you look through the API, you never see the method that you need...
Thanks, Nick.

Similar Messages

  • Dynamically grow and wrap the column within the page

    Hi All,
    I have the situation where my xml includes a lot of cells (columns) but only about 5 cells (columns) can fit in a page with 8 1/2 in. Can i set up a form to dynamically wrap the table when it hit the maximum of width? Anyone have any idea about this. In the designer i only see the option to set row grow but not cell (column). Is this possible to dynamically grow the column.
    Thanks
    --Khiem

    Your only option would be to increase the width of a page. You could use a landscape page or simply make the width of the page as big as necessary.
    Paul

  • Dynamically updating JList.

    This is my code snippet for showing images as a preview in scrollpane.
    In ListTableModel, u can get the Jlist and scrollpane of the JList.
    setFileStats method is used to set those data (images) into the JList after making imageicon from the filepath which is available in ImageName vector. It is showing all the images in preview mode at a time after setting everything in jList, but i want to show the every images loading in JList dynamically.
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.event.ListDataListener;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import java.util.Vector;
    public class ListTableModel extends AbstractListModel {
         public Vector data = new Vector();
         public JList localList;
         public JScrollPane tempPane;
         public ListTableModel(JList initList, JScrollPane argPane) {
              localList = initList; //Here i am pasing the list and scrollpane.
              tempPane = argPane;
              initList.setCellRenderer(new IVMListCellRenderer());
         public Object getElementAt(int index) {
              return (data.get(index));
         public int getSize() {
              return data.size();
         public void addListDataListener(ListDataListener ldl) {
              // since the list never changes, we don't need this :-)
         public void removeListDataListener(ListDataListener ldl) {
              // since the list never changes, we don't need this :-)
         public void setFileStats(Vector imageNames) {
              //data = new Object [imageNames.size()];
              data = new Vector();
              for ( int i = 0; i < imageNames.size(); i++ ) {
                        ImageIcon newScaled = new ImageIcon((String)imageNames.get(i));
                        newScaled.setDescription((String)imageNames.get(i));
                        data.add(newScaled);
                        localList.setListData(data);
                        fireIntervalAdded(data, 0, i);
                        fireContentsChanged(data, 0 , getSize());
                        localList.revalidate();
                        tempPane.revalidate();
                        localList.ensureIndexIsVisible(i);
    class IVMListCellRenderer extends DefaultListCellRenderer {
         public IVMListCellRenderer()
              setOpaque(true);
         public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
              super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
              ImageIcon tempValue = (ImageIcon)value;
              setIcon(tempValue);
              int lastPosition = tempValue.getDescription().lastIndexOf("/");
              String sizeOfStR = tempValue.getDescription().substring(lastPosition + 1);
              setText(sizeOfStR);
              return this;
    }

    This is my code snippet for showing images as a preview in scrollpane.
    In ListTableModel, u can get the Jlist and scrollpane of the JList.
    setFileStats method is used to set those data (images) into the JList after making imageicon from the filepath which is available in ImageName vector. It is showing all the images in preview mode at a time after setting everything in jList, but i want to show the every images loading in JList dynamically.
    import javax.swing.*;
    import java.awt.*;
    import javax.swing.event.ListDataListener;
    import javax.swing.event.ListSelectionEvent;
    import javax.swing.event.ListSelectionListener;
    import java.util.Vector;
    public class ListTableModel extends AbstractListModel {
         public Vector data = new Vector();
         public JList localList;
         public JScrollPane tempPane;
         public ListTableModel(JList initList, JScrollPane argPane) {
              localList = initList; //Here i am pasing the list and scrollpane.
              tempPane = argPane;
              initList.setCellRenderer(new IVMListCellRenderer());
         public Object getElementAt(int index) {
              return (data.get(index));
         public int getSize() {
              return data.size();
         public void addListDataListener(ListDataListener ldl) {
              // since the list never changes, we don't need this :-)
         public void removeListDataListener(ListDataListener ldl) {
              // since the list never changes, we don't need this :-)
         public void setFileStats(Vector imageNames) {
              //data = new Object [imageNames.size()];
              data = new Vector();
              for ( int i = 0; i < imageNames.size(); i++ ) {
                        ImageIcon newScaled = new ImageIcon((String)imageNames.get(i));
                        newScaled.setDescription((String)imageNames.get(i));
                        data.add(newScaled);
                        localList.setListData(data);
                        fireIntervalAdded(data, 0, i);
                        fireContentsChanged(data, 0 , getSize());
                        localList.revalidate();
                        tempPane.revalidate();
                        localList.ensureIndexIsVisible(i);
    class IVMListCellRenderer extends DefaultListCellRenderer {
         public IVMListCellRenderer()
              setOpaque(true);
         public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus)
              super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
              ImageIcon tempValue = (ImageIcon)value;
              setIcon(tempValue);
              int lastPosition = tempValue.getDescription().lastIndexOf("/");
              String sizeOfStR = tempValue.getDescription().substring(lastPosition + 1);
              setText(sizeOfStR);
              return this;
    }

  • Dynamically Growing Bar Chart

    Can a bar chart grow dynamically?
    I have a report that can have hundreds of items on its bar chart. I made the chart horizontal so they would presumably all show. Crystal displays it in the amount of space I have given it and only displays the text for as many items at it thinkks it can fit comfortably
    So I get a chart that looks like
    Item 1         |----
                      |----
    Item 13       |---
                      |---
    Item 37       |---
    I would like to have a chart that would display the text of all of the items and grow down the page so if I happen to have 128 items the chart will be a lot longer than it will be if I have 30 items.
    Is this possible?
    Thanks,
    Dick

    hi Dick,
    Right Click the Chart,
    Format Chart -> Can Grow (Option is Grayed out/Disabled)
    From the above, Chart can't grow dynamically based on data in CR.
    If you want all labels to appear,
    Chart Expert -> Axes ->Number of Divisions -> manual :1
    But when data is more, these labels appear very smaller.
    Also, you can fix the size of chart based on estimated data before hand.
    Regards,
    Vamsee

  • How to create a dynamically growing list in SAPUI5?

    Hi,
    I want to create a growing list in SAPUI5 like this http://help.sap-ag.de/saphelp_uiaddon10/helpdata/en/91/64ba7047b74a25a19baf9c5bb986ae/content.htm
    However, I want to hit a url to fetch data every time[10 rows on every load]. My JSON data contains more than 200 rows and I do not want to load everything when the app starts. Can you help me with your code for achieving this?
    Thanks
    Senthil Kumar

    Hi,
    Like I said, if it's an OData service call, then data is loaded from the server, and the amount of retrieved data specified by the threshold.
    if it is a simple REST / JSON service, then all data is loaded during the initial service call, but the list only shows (and grows) by what's specified at the threshold parameter.
    In other words, the real benefit of the growing list is when using OData services

  • How to show the "latest" row in a dynamically growing Jtable

    I thought, this topic was poeted before, but as I could not find it, here is my question.
    I have a Jtable ( 5 columns ) putted on a JScrollbar.
    Adding new rows lets the vertical-scrollbar shrink, thus showing there are more rows towards the end.
    But how can I force the bottom-row to be shown.
    I did neither find a way handling the JTable nor the jSCrollBar
    Thanks for any hint
    Hanns

    I think you have your JTable in a JScrollPane like that :
    JTable table = ...
    JScrollPane scroller = new JScrollPane(table);
    After adding a row, you should use the method scrollRectToVisible(Rectangle r), where r is the bounds of the first cell in the last row.
    ex :
    int lastRowIndex = table.getRowCount();
    table.scrollRectToVisible(table.getCellRect(lastRowIndex, 0, true));Denis

  • Dynamically growing columns

    Hi,
    I'm using forms6i.
    I have a holiday calendar table, Cal_header, having columns empcode,leavetype,Date et...
    Which contains all the holidays available for an employee for a whole year.
    Now i need to provide, one screen to query. The i/ps can be Employee, and duration.
    So if i/p are Employee: '1' and duration: from 01-mar-2011 to 31-mar-2011.
    For this i/p , suppose we got few record from holiday calendar like
    Employee          Leavetype                  Date
    1                      Friday               02-mar-2011
    1                      Saturday           03-mar-2011
    1                      Natday              16-mar-2011
    1                      friday                09-mar-2011
    etc...So the query screen i'm providing should display these data like
    Employee        01/mar/2011   02/mar/2011.........   09/mar/2011   10/mar/2011........16/mar/2011......31/mar/2011
    1                             Friday                    Friday                        NatdayI have no idea how to approach this.How can this be done!?
    Please help
    Thanks

    Thanks for the link.
    Based on that i've created a from-clause query in the form.
    But at runtime i'm getting exception
    SELECT CAL_EMP_CODE,DT1,DT2,DT3,DT4,DT5,DT6,DT7,DT8,DT9,DT10,DT11,DT12,DT13,DT14
    FROM (Select ech_emp_code cal_emp_code,max(decode(to_char(ech_date,'dd-MON-YYYY'),'01-APR-2011',ech_CODE)) DT1,
    max(decode(to_char(ech_date,'dd-MON-YYYY'),'02-APR-2011',ech_CODE)) DT2,
    max(decode(to_char(ech_date,'dd-MON-YYYY'),'03-APR-2011',ech_CODE)) DT3,
    max(decode(to_char(ech_date,'dd-MON-YYYY'),'04-APR-2011',ech_CODE)) DT4,
    max(decode(to_char(ech_date,'dd-MON-YYYY'),'05-APR-2011',ech_CODE)) DT5,
    max(decode(to_char(ech_date,'dd-MON-YYYY'),'06-APR-2011',ech_CODE)) DT6,
    max(decode(to_char(ech_date,'dd-MON-YYYY'),'07-APR-2011',ech_CODE)) DT7,
    max(decode(to_char(ech_date,'dd-MON-YYYY'),'08-APR-2011',ech_CODE)) DT8,
    max(decode(to_char(ech_date,'dd-MON-YYYY'),'09-APR-2011',ech_CODE)) DT9,
    max(decode(to_char(ech_date,'dd-MON-YYYY'),'10-APR-2011',ech_CODE)) DT10,
    max(decode(to_char(ech_date,'dd-MON-YYYY'),'11-APR-2011',ech_CODE)) DT11,
    max(decode(to_char(ech_date,'dd-MON-YYYY'),'12-APR-2011',ech_CODE)) DT12,
    max(decode(to_char(ech_date,'dd-MON-YYYY'),'13-APR-2011',ech_CODE)) DT13,
    max(decode(to_char(ech_date,'dd-MON-YYYY'),'14-APR-2011',ech_CODE)) DT14
    from (Select * from emp_cal_header
            where ech_date between *2011/04/01 00:00:00* and *2011/04/14 00:00:00* order by ech_Date)
            group by ech_emp_code) i'm getting Error: ORA-00905: missing keyword.
    The bold characters(sorry it didn look bold, so the data betweem two *s) are the i/p from user, accepted using two Date items through form.
    Please help

  • Editable ALV with dynamically growing columns

    Hi Gurus,
    I have one Parameter table and another data (transaction) table
    When I fetch the data from data table I have put a when condition to one of date field in data table with between sy-datum and sy-datum + need to run days in parameter table
    Its working properly
    So my requirement is …. &#61516;
    There are three key fields (fixed) and
    when the parameter value = 4 ALV columns must be 7
    when the parameter value = 6 ALV columns must be 9
    like that.
    So I want to know how can I do this?
    My second question is when the ALV displaying, user need to change there value in ALV list, so therefore ALV should be editable.
    Please help me o solve these problems.

    below  is the program  to  make   an  parameter  as  Editable in the ALV Grid  .  example <b> Net price</b>  .
    see the field catalog   statement  for    netprice   * edit  parameter for  that  field .
    *& Report  ZDEMO_ALVGRID_EDIT                                          *
    *& Example of a simple ALV Grid Report                                 *
    *& The basic ALV grid, Enhanced to display specific fields as          *
    *& editable depending on field value                                   *
    REPORT  ZDEMO_ALVGRID_EDIT                 .
    TABLES:     ekko.
    TYPE-POOLS: slis.                                 "ALV Declarations
    *Data Declaration
    TYPES: BEGIN OF t_ekko,
      ebeln TYPE ekpo-ebeln,
      ebelp TYPE ekpo-ebelp,
      statu TYPE ekpo-statu,
      aedat TYPE ekpo-aedat,
      matnr TYPE ekpo-matnr,
      menge TYPE ekpo-menge,
      meins TYPE ekpo-meins,
      netpr TYPE ekpo-netpr,
      peinh TYPE ekpo-peinh,
      field_style  TYPE lvc_t_styl, "FOR DISABLE
    END OF t_ekko.
    DATA: it_ekko TYPE STANDARD TABLE OF t_ekko INITIAL SIZE 0,
          wa_ekko TYPE t_ekko.
    *ALV data declarations
    DATA: fieldcatalog TYPE slis_t_fieldcat_alv WITH HEADER LINE.
    DATA: it_fieldcat TYPE lvc_t_fcat,     "slis_t_fieldcat_alv WITH HEADER LINE,
          wa_fieldcat TYPE lvc_s_fcat,
          gd_tab_group TYPE slis_t_sp_group_alv,
          gd_layout    TYPE lvc_s_layo,     "slis_layout_alv,
          gd_repid     LIKE sy-repid.
    *Start-of-selection.
    START-OF-SELECTION.
      PERFORM data_retrieval.
      PERFORM set_specific_field_attributes.
      PERFORM build_fieldcatalog.
      PERFORM build_layout.
      PERFORM display_alv_report.
    *&      Form  BUILD_FIELDCATALOG
    *       Build Fieldcatalog for ALV Report
    FORM build_fieldcatalog.
      wa_fieldcat-fieldname   = 'EBELN'.
      wa_fieldcat-scrtext_m   = 'Purchase Order'.
      wa_fieldcat-col_pos     = 0.
      wa_fieldcat-outputlen   = 10.
      wa_fieldcat-emphasize   = 'X'.
      wa_fieldcat-key         = 'X'.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'EBELP'.
      wa_fieldcat-scrtext_m   = 'PO Item'.
      wa_fieldcat-col_pos     = 1.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'STATU'.
      wa_fieldcat-scrtext_m   = 'Status'.
      wa_fieldcat-col_pos     = 2.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'AEDAT'.
      wa_fieldcat-scrtext_m   = 'Item change date'.
      wa_fieldcat-col_pos     = 3.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'MATNR'.
      wa_fieldcat-scrtext_m   = 'Material Number'.
      wa_fieldcat-col_pos     = 4.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'MENGE'.
      wa_fieldcat-scrtext_m   = 'PO quantity'.
      wa_fieldcat-col_pos     = 5.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'MEINS'.
      wa_fieldcat-scrtext_m   = 'Order Unit'.
      wa_fieldcat-col_pos     = 6.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'NETPR'.
    wa_fieldcat-scrtext_m   = 'Net Price'.
      <b>wa_fieldcat-edit        = 'X'. "sets whole column to be editable</b>
      wa_fieldcat-col_pos     = 7.
      wa_fieldcat-outputlen   = 15.
      wa_fieldcat-datatype     = 'CURR'.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
      wa_fieldcat-fieldname   = 'PEINH'.
      wa_fieldcat-scrtext_m   = 'Price Unit'.
      wa_fieldcat-col_pos     = 8.
      APPEND wa_fieldcat TO it_fieldcat.
      CLEAR  wa_fieldcat.
    ENDFORM.                    " BUILD_FIELDCATALOG
    *&      Form  BUILD_LAYOUT
    *       Build layout for ALV grid report
    FORM build_layout.
    * Set layout field for field attributes(i.e. input/output)
      gd_layout-stylefname = 'FIELD_STYLE'.
      gd_layout-zebra             = 'X'.
    ENDFORM.                    " BUILD_LAYOUT
    *&      Form  DISPLAY_ALV_REPORT
    *       Display report using ALV grid
    FORM display_alv_report.
      gd_repid = sy-repid.
    *  call function 'REUSE_ALV_GRID_DISPLAY'
      CALL FUNCTION 'REUSE_ALV_GRID_DISPLAY_LVC'
           EXPORTING
                i_callback_program      = gd_repid
    *            i_callback_user_command = 'USER_COMMAND'
                is_layout_lvc               = gd_layout
                it_fieldcat_lvc             = it_fieldcat
                i_save                  = 'X'
           TABLES
                t_outtab                = it_ekko
           EXCEPTIONS
                program_error           = 1
                OTHERS                  = 2.
      IF sy-subrc <> 0.
    * MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
    *         WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
      ENDIF.
    ENDFORM.                    " DISPLAY_ALV_REPORT
    *&      Form  DATA_RETRIEVAL
    *       Retrieve data form EKPO table and populate itab it_ekko
    FORM data_retrieval.
      SELECT ebeln ebelp statu aedat matnr menge meins netpr peinh
       UP TO 10 ROWS
        FROM ekpo
        INTO  CORRESPONDING FIELDS OF TABLE it_ekko.
    ENDFORM.                    " DATA_RETRIEVAL
    *&      Form  set_specific_field_attributes
    *       populate FIELD_STYLE table with specific field attributes
    form set_specific_field_attributes .
      DATA ls_stylerow TYPE lvc_s_styl .
      DATA lt_styletab TYPE lvc_t_styl .
    * Populate style variable (FIELD_STYLE) with style properties
    * The NETPR field/column has been set to editable in the fieldcatalog...
    * The following code sets it to be disabled(display only) if 'NETPR'
    * is gt than 10.
      LOOP AT it_ekko INTO wa_ekko.
        IF wa_ekko-netpr GT 10.
          ls_stylerow-fieldname = 'NETPR' .
          ls_stylerow-style = cl_gui_alv_grid=>mc_style_disabled.
                                                 "set field to disabled
          APPEND ls_stylerow  TO wa_ekko-field_style.
          MODIFY it_ekko FROM wa_ekko.
        ENDIF.
      ENDLOOP.
    endform.           
    reward  points if it is usefull ....
    Girish

  • How do I create a dynamic growing table which holds "copies" of the footer Row from several instances?

    Mission:        
    To create a summary table with Rows from several (yet to be determined) instances
    Coordinates of the enemy   (or Row in question):  
    ROOT.category[*].sub_category_total.sub_category_summary.Row1
    Background information:
    An order form with option for several categories (2 – 10) with subcategories (2 – 20).
    Since the finished form might be up to 20 pages long I would like to get to the point
    with a click of a button (so to speak)
    Therefore a summary list seems the only logic solution.
    Reward:
    Unending gratefulness and publishing of finished sample for others to learn from
    Additional Note:
    Should you choose to accept this mission I will never deny your existence and will
    always give credit to whom credit belongs.
    This message will NOT self-destruct.    

    Hi Steve,
    thanks for the example ... nice and close but not 100 % solution.
    The sample requires me to set up the summary table with fixed rows.
    But I don't know how many main categories & subcategories will be there - it can vary between 2 and 20.
    One solution would be to set up a table with 20+ rows and hide them if rawValue ... equals 0.
    Might work -  but is not very elegant ....
    I guess I was looking for the script that counts the instances and then creates automatically the necessary rows.
    I know it is a lot to ask in a forum ... but I guess it might be possible. Isn't it??
    Please let me know if I'm reaching for the impossible 
    Jixin

  • Add item in JList

    How i can add each item to JList. Using loop not use array?

    I have not used a JList before, but looking at the API, one of the JLists constructors will take a Vector as one of it's argument
    JList API http://java.sun.com/j2se/1.4.2/docs/api/javax/swing/JList.html
    constructor
    JList(Vector listData) so you would be able to add elements to the vector in a loop using the add() method of the vector class
    then construct the JList after the elements have been added to the vector, this will mean that you do not have to specify the size of the vector (all thought you can) as it will dynamically grow as you add items to it.
    So if you don't know the amount of items that you will be adding to your JList to start with, it is a better bet than using an array
    again have a look at the vector API http://java.sun.com/j2se/1.4.2/docs/api/java/util/Vector.html
    hope that points you in the right direction
    JaVAmUG3380

  • Create a dynamic object HELP PLS!!! URGENT

    hi
    I would like to create an object(e.g. a torch ... this will be created using 3D MAX or VRML) which can be viewed in an applet, where the object will dynamically grow by just keying in values. Is this possible?? If so can you pls tell me how OR point me to the right directions on where i can find more information. Thx in advance!!!

    It's definitely possible. I have seen quite a few people
    with interactivity problems, though, after loading their
    objects from files. You will have to interfere with the
    object creation process enough to allow changes to your
    object after getting your scene live. This is the first
    you will need to check: How to set the capabilities for
    your loaded object. Second, I would advise you to have
    a look at transforming and translating. You will need to
    define transformations which - when applied to some
    object - result in changing its size. It would probably
    be easier to use distance instead of real resizing. In
    other words: The object at the beginning is some distance
    away, when you start "enlarging" it, it is moved closer
    to the viewer, thereby visually growing. Truly enlarging
    something to scale will be a lot more difficult, I'd
    think. Oh, and one other thing, since you said, it should
    be an applet: You DO know, that Java 3D by default is not
    supported by browsers without first installing the Java 2
    and Java 3D plugins, right?
    Jens

  • Checking Account and help with code ?

    Hi all..my computer hung up on me, so I'm not sure if my last post went through. First of all thank you all for helping me out the other day with my question on the Bank Account. It continues :)
    I'm trying to work on each class one by one..when I test my Checking Account, it isn't printing out the correct balance. The string method to print this is coming from the Withdrawal class...so I know it has to be somewhere in there but I can't seem to figure out why it isn't totalling the balance...or how to get it too.
    Then when I test my MyBank class, it hangs up on line 63..which I could swear I have written correctly. Again I am getting a NullPointerException and I honestly think I have the line of code written right, but I'm guessing I dont.
    Any help would be appreciated.
    public abstract class BankAccount {
        public static final String bankName = "BrianBank";
        protected String custName;
        protected String pin;
        protected Transaction[] history;
        private double balance;
        private double amt, amount;
        private double bal, initBal;
        private int transactions;
        private final int MAX_HISTORY = 100;
        private int acct;
        protected BankAccount(String cname, String cpin, double initBal) {
         custName = cname;
         pin = cpin;
         balance = initBal;
         history = new Transaction[MAX_HISTORY];
         transactions =0;
        public double getBalance() {
         return balance;
        public void withdraw(double amt) {
         history [transactions] = new Withdrawal (bal, amt);
       balance = bal;
         amount = amt;
         balance -= amt;
       transactions = transactions + 1;     
        public void deposit(double amt) {     
         history [transactions] = new Deposit (bal, amt);
         balance = bal;
         amount = amt;
         balance += amt;
         transactions = transactions +1;
        // abstract method to return account number
        public abstract int getAcctNum();
        // abstract method to return a summary of transactions as a string
        public abstract String getStatement();
    public class CheckingAccount extends BankAccount implements IncursFee
          private int transactions;
          private double balance, initBal, amt;
          private static final int NOFEE_WITHDRAWALS = 10;
          private static final double TRANSACTION_FEE = 5.00;
          public static final String bankName = "iBank";
          public static final int STARTING_ACCOUNT_NUMBER = 10000;
          private int checkingAccountNumber = STARTING_ACCOUNT_NUMBER;
          private static int accountNumberCounter = STARTING_ACCOUNT_NUMBER;
          private String custName;
          private String pin;
          public CheckingAccount (String cname, String cpin, double initBal)
             super (cname, cpin, initBal);
              custName = cname;
              pin = cpin;
             balance = initBal;
             accountNumberCounter++; 
             checkingAccountNumber = accountNumberCounter;
          //initialize a count of transactions
             transactions = 0;          
           public double getBalance()
             return balance;
           public void withdraw(double amt)
            super.withdraw (amt);
             transactions ++;
           public void deposit(double amt)
           super.deposit (amt);
             transactions ++;
           public int getAcctNum ()
             return checkingAccountNumber;     
           public String getStatement ()
             int i = 0;
             String output = "";
             while ( i < history.length && history[i] != null )
                output += history.toString () + "\n";
    i++;
    return output;     
    public void deductFee(double fee)
    if (transactions > NOFEE_WITHDRAWALS)
    {  fee = TRANSACTION_FEE *(transactions - NOFEE_WITHDRAWALS);
    super.withdraw(fee);
    balance -=fee;
    transactions = 0;
    public interface IncursFee {
    public abstract void deductFee(double fee);
    public abstract class Transaction {
    protected double initBal;
    protected double tranAmt;
    // constructor
    protected Transaction(double bal, double amt) {
         initBal = bal;
         tranAmt = amt;
    abstract public String toString();
    public class Withdrawal extends Transaction
         private double initBal;
         private double amount;
         private static NumberFormat fmt = NumberFormat.getCurrencyInstance();
         public Withdrawal (double bal, double amt)
              super (bal, amt);
              initBal = bal;
              amount = amt;
         public String toString ()
         return "Balance : " + fmt.format(initBal) + "\n" + "Withdrawal : " + fmt.format(amount);
    import java.text.NumberFormat;
    public class Deposit extends Transaction
         private double initbal, balance;
         private double amount;
         private static NumberFormat fmt = NumberFormat.getCurrencyInstance();
         public Deposit (double bal, double amt)
         super (bal, amt);
         initbal = bal;
         amount = amt;
         public String toString ()
         return "Balance : " + fmt.format(initbal) + "\n" + "Deposit : " + fmt.format(amount);
    public class TestCheckingAcct {
    public static void main(String[] args) {
         BankAccount b1 = new CheckingAccount("Harry", "1234", 500.0);
         System.out.println (b1.getBalance ());
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.deposit(50);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.deposit(10);
         b1.withdraw(1);
         System.out.println(b1.getStatement());
    // This interface specifies the functionality requirements of a bank
    public interface Bank {
    public abstract int openNewAccount(String customerName, String customerPIN, String accType, double initDepAmount);
    public abstract void processWithdrawal(int accNum, String pin, double amount);
    // executes a deposit on the specified acct by the amount
    public abstract void processDeposit(int accNum, String pin, double amount);
    // returns the balance of acct
    public abstract double processBalanceInquiry(int accNum, String pin);
    // returns summary of transactions
    public abstract String processStatementInquiry(int accNum, String pin);
    import java.util.ArrayList;
    public class MyBank implements Bank
    private ArrayList<BankAccount> savAccounts = new ArrayList<BankAccount>(); //dynamically grows
    private ArrayList<BankAccount> chkAccounts = new ArrayList<BankAccount>(); //dynamically grows
    private SavingsAccount sav;
    private CheckingAccount chk;
    private int accNum;
    private String customerName, customerPIN, accType, pin;
    private double initDepAmount, amount, balance;
    public int openNewAccount(String customerName, String customerPIN, String accType, double initDepAmount)
    this.customerName = customerName;
    this.customerPIN = customerPIN;
    this.accType = accType;
    this.initDepAmount = initDepAmount;
    if ( accType.equals("Savings"))
    BankAccount savAcct = new SavingsAccount(customerName, customerPIN, initDepAmount);
    try
    savAccounts.add(savAcct);
    catch (ArrayIndexOutOfBoundsException savAccounts)
    return savAcct.getAcctNum();
    else
    CheckingAccount chkAcct = new CheckingAccount(customerName, customerPIN, initDepAmount);
         try
    chkAccounts.add(chkAcct);
    catch (ArrayIndexOutOfBoundsException chkAccounts)
    return chkAcct.getAcctNum();
    public void processWithdrawal (int accNum, String pin, double amount)
         this.accNum = accNum;
         this.pin = pin;
         this.amount = amount;
    if (accNum >10000 && accNum < 20000)
         chk.withdraw (amount);
    if (accNum >50000 && accNum <60000)
         sav.withdraw (amount);
    public void processDeposit (int accNum, String pin, double amount)
         this.accNum = accNum;
         this.pin = pin;
         this.amount = amount;
    if (accNum >10000 && accNum < 20000)
         chk.deposit (amount);
    if (accNum >50000 && accNum <60000)
         sav.deposit (amount);
    public double processBalanceInquiry (int accNum, String pin)
         this.accNum = accNum;
         this.pin = pin;
         this.balance = 0;
    if (accNum >10000 && accNum <20000)
         balance = chk.getBalance ();
    if (accNum >50000 && accNum <60000)
         balance = sav.getBalance ();
    return balance;
    public String processStatementInquiry(int accNum, String pin)
         this.accNum = accNum;
         this.pin = pin;
         this.statement = "";
    if (accNum >10000 && accNum <20000)
    statement = chk.getStatement ();
    if (accNum >50000 && accNum <60000)
    statement= sav.getStatement ();
         return statement;

    Here's some quick code review:
    public abstract class BankAccount {
    public static final String bankName =
    me = "BrianBank";
    protected String custName;
    protected String pin;
    protected Transaction[] history;
    private double balance;
    private double amt, amount;
    private double bal, initBal;
    private int transactions;// make MAX_HISTORY private static final, too.
    private final int MAX_HISTORY = 100;
    private int acct;
    protected BankAccount(String cname, String cpin,
    pin, double initBal) {
         custName = cname;
         pin = cpin;
         balance = initBal;
         history = new Transaction[MAX_HISTORY];
         transactions =0;
    public double getBalance() {
         return balance;
    public void withdraw(double amt) {
         history [transactions] = new Withdrawal (bal, amt);
    balance = bal;
         amount = amt;
         balance -= amt;// ++transactions above would be elegant.
    transactions = transactions + 1;     
    public void deposit(double amt) {     
         history [transactions] = new Deposit (bal, amt);
         balance = bal;
         amount = amt;
         balance += amt;
         transactions = transactions +1;
    // abstract method to return account number// why abstract?
    public abstract int getAcctNum();
    // abstract method to return a summary of
    y of transactions as a string// why abstract?
    public abstract String getStatement();
    public class CheckingAccount extends BankAccount
    implements IncursFee
    private int transactions;
    private double balance, initBal, amt;
    private static final int NOFEE_WITHDRAWALS =
    WALS = 10;
    private static final double TRANSACTION_FEE =
    _FEE = 5.00;
    public static final String bankName = "iBank";
    public static final int STARTING_ACCOUNT_NUMBER
    NUMBER = 10000;
    private int checkingAccountNumber =
    mber = STARTING_ACCOUNT_NUMBER;
    private static int accountNumberCounter =
    nter = STARTING_ACCOUNT_NUMBER;// BankAccount has a custName attribute; why does CheckingAccount need
    // one if it extends BankAccount?
    private String custName;
    private String pin;
    public CheckingAccount (String cname, String
    String cpin, double initBal)
    super (cname, cpin, initBal);
    custName = cname;
    pin = cpin;
    balance = initBal;
    accountNumberCounter++;
    checkingAccountNumber =
    tNumber = accountNumberCounter;
    //initialize a count of transactions
    transactions = 0;          
    // same as BankAccount - why rewrite it?
    public double getBalance()
    return balance;
    // same as BankAccount - why rewrite it?
    public void withdraw(double amt)
    super.withdraw (amt);
    transactions ++;
    // same as BankAccount - why rewrite it?
    public void deposit(double amt)
    super.deposit (amt);
    transactions ++;
              // same as BankAccount - why rewrite it?
    public int getAcctNum ()
    return checkingAccountNumber;     
    public String getStatement ()
    int i = 0;
    String output = "";
    while ( i < history.length && history[i] !=
    ory[i] != null )
    output += history.toString () + "\n";
    i++;
    return output;     
    public void deductFee(double fee)
    if (transactions > NOFEE_WITHDRAWALS)
    {  fee = TRANSACTION_FEE *(transactions -
    ansactions - NOFEE_WITHDRAWALS);
    super.withdraw(fee);
    balance -=fee;
    transactions = 0;
    public interface IncursFee {
    public abstract void deductFee(double fee);
    public abstract class Transaction {
    protected double initBal;
    protected double tranAmt;
    // constructor
    // why protected? make it public.
    protected Transaction(double bal, double amt) {
         initBal = bal;
         tranAmt = amt;
    abstract public String toString();
    public class Withdrawal extends Transaction
         private double initBal;
         private double amount;
    private static NumberFormat fmt =
    = NumberFormat.getCurrencyInstance();
         public Withdrawal (double bal, double amt)
              super (bal, amt);
              initBal = bal;
              amount = amt;
         public String toString ()
    return "Balance : " + fmt.format(initBal) + "\n" +
    + "Withdrawal : " + fmt.format(amount);
    import java.text.NumberFormat;
    public class Deposit extends Transaction
         private double initbal, balance;
         private double amount;
    private static NumberFormat fmt =
    = NumberFormat.getCurrencyInstance();
         public Deposit (double bal, double amt)
         super (bal, amt);
         initbal = bal;
         amount = amt;
         public String toString ()
    return "Balance : " + fmt.format(initbal) + "\n" +
    + "Deposit : " + fmt.format(amount);
    public class TestCheckingAcct {
    public static void main(String[] args) {
    BankAccount b1 = new CheckingAccount("Harry",
    , "1234", 500.0);
         System.out.println (b1.getBalance ());
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.deposit(50);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.withdraw(1);
         b1.deposit(10);
         b1.withdraw(1);
         System.out.println(b1.getStatement());
    // This interface specifies the functionality
    requirements of a bank
    public interface Bank {
    public abstract int openNewAccount(String
    String customerName, String customerPIN, String
    accType, double initDepAmount);
    public abstract void processWithdrawal(int
    (int accNum, String pin, double amount);
    // executes a deposit on the specified acct by
    t by the amount
    public abstract void processDeposit(int accNum,
    Num, String pin, double amount);
    // returns the balance of acct
    public abstract double processBalanceInquiry(int
    (int accNum, String pin);
    // returns summary of transactions
    public abstract String
    ring processStatementInquiry(int accNum, String
    pin);
    import java.util.ArrayList;
    public class MyBank implements Bank
    private ArrayList<BankAccount> savAccounts =
    unts = new ArrayList<BankAccount>(); //dynamically
    grows
    private ArrayList<BankAccount> chkAccounts =
    unts = new ArrayList<BankAccount>(); //dynamically
    grows
    private SavingsAccount sav;
    private CheckingAccount chk;
    private int accNum;
    private String customerName, customerPIN,
    erPIN, accType, pin;
    private double initDepAmount, amount, balance;
    public int openNewAccount(String customerName,
    erName, String customerPIN, String accType, double
    initDepAmount)
    this.customerName = customerName;
    this.customerPIN = customerPIN;
    this.accType = accType;
    this.initDepAmount = initDepAmount;
    if ( accType.equals("Savings"))
    BankAccount savAcct = new
    vAcct = new SavingsAccount(customerName, customerPIN,
    initDepAmount);
    try
    savAccounts.add(savAcct);
    catch (ArrayIndexOutOfBoundsException
    Exception savAccounts)
    return savAcct.getAcctNum();
    else
    CheckingAccount chkAcct = new
    hkAcct = new CheckingAccount(customerName,
    customerPIN, initDepAmount);
         try
    chkAccounts.add(chkAcct);
    catch (ArrayIndexOutOfBoundsException
    Exception chkAccounts)
    return chkAcct.getAcctNum();
    public void processWithdrawal (int accNum,
    accNum, String pin, double amount)
         this.accNum = accNum;
         this.pin = pin;
         this.amount = amount;
    if (accNum >10000 && accNum < 20000)
         chk.withdraw (amount);
    if (accNum >50000 && accNum <60000)
         sav.withdraw (amount);
    public void processDeposit (int accNum, String
    String pin, double amount)
         this.accNum = accNum;
         this.pin = pin;
         this.amount = amount;
    if (accNum >10000 && accNum < 20000)
         chk.deposit (amount);
    if (accNum >50000 && accNum <60000)
         sav.deposit (amount);
    public double processBalanceInquiry (int accNum,
    String pin)
         this.accNum = accNum;
         this.pin = pin;
         this.balance = 0;
    if (accNum >10000 && accNum <20000)
         balance = chk.getBalance ();
    if (accNum >50000 && accNum <60000)
         balance = sav.getBalance ();
    return balance;
    public String processStatementInquiry(int accNum,
    m, String pin)
         this.accNum = accNum;
         this.pin = pin;
         this.statement = "";
    if (accNum >10000 && accNum <20000)
    statement = chk.getStatement ();
    if (accNum >50000 && accNum <60000)
    statement= sav.getStatement ();
         return statement;
    Very bad style with those brace placements. Pick a style and stick with it. Consistency is the key.
    Your code isn't very readable.
    You don't have a SavingsAccount here anywhere, even though your MyBank uses one.
    You use JDK 1.5 generics yet you've got ArrayList as the static type on those declarations. Better to use the interface type List as the compile time type on the LHS.
    You have a lot of compile time problems, and some incomprehensible stuff, but I was able to change it enough to my TestCheckingAcct run to completion. No NPE exceptions.
    I'm not sure I agree with your design.
    No SavingsAccount. The accounts I have ALL incur fees - no need for a special interface there. Savings accounts are usually interest bearing. That's the way they behave differently from checking accounts. Where do you have that?
    You rewrite too much code. If you put behavior in the abstract BankingAccount class (a good idea), the whole idea is that concrete classes that extend BankingAccount don't need to overload any methods whose default behavior is correct for them.
    I don't know that I'd have separate Deposit and Withdrawal to implement Transaction. I'd make Transaction concrete and have starting balance, ending balance, and a transaction type String (e.g., "DEPOSIT", "WITHDRAWAL")
    It'd be good to see some thought put into exception handling. I don't see an OverdrawnException anywhere. Seems appropriate.
    No transfer methods from one account to another. I often do that with my bank.
    That's enough to get started.

  • Problem with Data in Form

    I have begun using the Form feature in Adobe 8.0. I have made my forms using the Livecycle designer. I have received back completed forms via email and then I have entered the data in the actual form itself by hitting "import data." When doing so I've noticed that there are some responses that show a little bit of the answer but then there is this plus sign (+) and when I click on it, it allows me to see the rest of the response(by scrolling over).
    My problem is when I print off the form, it still has this plus sign on there and it doesn't show the complete answer. The only way to see the entire response is if you scroll over on the form on the computer. I was wondering how you get it to show the entire response and get rid of the plus sign???
    Any help would be appreciated.

    The + signs are appearing to indicate to you that there is more data in the field than there is visible on the screen. There are two solutions to this.
    1. Make the fields so that they can dynamically grow to fit the content that is entered into them. This involves re-engineering the form. There is a sample of this that ships with the product and is located at this location from the root of the designer install:
    EN\Samples\Forms\Purchase Order\Dynamic Interactive\Forms
    Have a look at the comments field at the bottom of the form. If you put in too much info then it will grow to show all data after you tab out of the field.
    2. You can have it so that the text that is inserted into the field can shrink to fit the visible area. This is the easier of the solutions. To do this, set the field up to allow multi-line and limit length to visible area. Then on the Font palette, click on the right arrow below the Font tab (beside the text "currently editing caption and value"). Choose the Edit Value option. The text will update to say "currently editing Value properties. Change the font size to 0 (you will have to type in a 0. Now when the amount of text exceeds the visible area the font size will drop a value to allow you to see all text. This can be a negative as well for if we put too much text in then the font becomes so small that we connot read it.....but it is easier.
    Hope this helps

  • Is it possible to chroma key a moving laptop/phone screen in Motion 5?

    Hi, I recently downloaded Motion 5, and I've been experimenting with it. What I'd like to know is if it's possible to chroma key the screen of a phone (the screen will be green.) I've managed to chroma key out the green, and it works perfectly, except I don't know how to make the "screen" follow the phone or stay on the phone if the camera moves. Also, is it possible to make the "screen" dynamically grow/shrink as the camera zooms in/out. Is such a thing even possible with Motion?
    Thanks in advance!

    a color-key isn't needed for such an effect…
    What you like to accomplish is something like that:
    http://youtu.be/Mml8uqeB0MU
    This is called 4-corner motion tracking, advice in the Manual
    http://help.apple.com/motion/mac/5.0/en/motion/usermanual/#chapter=22%26section= 8%26hash=apple_ref:doc:uid:Motion-UserManual-90919TRK-1139924

  • 10g ASM on Logical Volumes vs. Raw devices and SAN Virtualization

    We are looking at setting up our standards for Oracle 10g non-rac systems. We are looking at the value of Oracle ASM in our environment.
    As per the official Oracle documentation, raw devices are preferred to using Logical Volumes when using ASM.
    From here: http://download.oracle.com/docs/cd/B19306_01/server.102/b15658/appa_aix.htm#sthr
    ef723
    "Note: Do not add logical volumes to Automatic Storage Management disk groups. Automatic Storage Management works best when you add raw disk devices to disk groups. If you are using Automatic Storage Management, then do not use LVM for striping. Automatic Storage Management implements striping and mirroring."
    Also, as per Metalink note 452924.1:
    "10) Avoid using a Logical Volume Manager (LVM) because an LVM would be redundant."
    The issue is: if we use raw disk devices presented to ASM, the disks don't show up as used in the unix/AIX system tools (i.e. smit, lspv, etc.). Hence, when looking for raw devices on the system to add to filesystems/volume groups/etc., it's highly possible that a UNIX admin will grab a raw device that is already in use by Oracle ASM.
    Additionally, we are using a an IBM DS8300 SAN with IBM SAN Volume Controller (SVC) in front of it. Hence, we already have storage virtualization and I/O balancing at the SAN/hardware level.
    I'm looking for a little clarification to the following questions, as my understanding of their responses seem to confict:
    QUESTION #1: Can anyone clarify/provide additional detail as to why Logical volumes are not preferred when using Oracle ASM? Does the argument still hold in a SAN Virtualized environment?
    QUESTION #2: Does virtualization at the software level (ASM) make sense in our environment? As we already have I/O balancing provided at the hardware level via our SVC, what do we gain by adding yet another level of I/O balancing at the ASM level? Or as in the
    arguments the Oracle documentation makes against using Lvm, is this an unnecessary redundant striping (double-striped or in our case triple-striped/plaid)?
    QUESTION #3: So does SAN Virtualization conflict or compliment the virtualization provided by ASM?

    After more research/discussions/SR's, I've come to the following conclusion.
    Basically, in an intelligent storage environment (i.e. SVC), you're not getting a 100% bang for the buck by using ASM. Which is the cat's meow in a commodity hardware/unintelligent storage environment.
    Using ASM in a SVC environment potentially wastes CPU cycles having ASM balance i/o that is already balanced on the backend (sure if you shuffle a deck of cards that are already shuffled you're not doing any harm, but if they're already shuffled - then why are you shuffling them again??).
    That being said, there may still be some value for using ASM from the standpoint of storage management for multiple instances on a server. For example, one could better minimize space wastage by being able to share a "pool" of storage between mulitiple instances, rather than having to manage space on an instance-by-instance (or filesystem by filesystem) level.
    Also, in the case of having a unfriendly OS where one is unable to dynamically grow a filesystem (i.e. database outage required), there would be a definite benefit provided by ASM in being able to dynamically allocate disks to the "pool". Of course, with most higher-end end systems, dynamic filesystem growth is pretty much a given.
    In the case of RAC, regardless of the backend, ASM with raw is a no-brainer.
    In the case of a standalone instance, it's a judgement call. My vote in the case of intelligent storage where one could dynamically grow filesystems, would be to keep ASM out of the picture.
    Your vote may be different....just make sure you're putting in a solution to a problem and not a solution that's looking for a problem(s).
    And there's the whole culture of IT thing as well (i.e. do your storage guys know what you're doing and vice versa).....which can destroy any technological solution, regardless of how great it is.

Maybe you are looking for

  • Doly Audio driver cannot start after upgrading to Windows 8.1

    Upgrade to Windows 8.1 went flawlessly, but when I restart I get this message: I can't find any reference to Dolby Theater or Audio in any app or Device management. I can't find any drivers for Windows 8 64 bit  on the Lenovo site either. Can anyone

  • How do I remove download links/button redirect to accurate download

    When I go to some sites that have a download link underscored in blue or a button next to text or any other part of the page, I was able to click and download the file. When you point at the link or button you would see the path it will take to downl

  • How can I batch save my adjusted raw images as jpgs in Lightroom 4

    I have a job that I imported to Lightroom 4.  I made adjustments to 40 of the images and would like to batch save these as jpgs with the LR adjustments saved.  So far I know I can save the raws as jpgs but the adjustments are not being saved.  I woul

  • A Headphone is Not A Speaker

    This is so amazingly silly. When I plug the headphone in, it not only announces that I have plugged in a headphone, it originally expected me to acknowledge that I'd plugged in a headphone. Given that, why does it then blast sound in my ears at the l

  • Request mapping is struck in ICO

    Hi Experts,    I am working on a XML file to SAP PROXY scenario in SAP PI 7.4 single stack. SAP PI is picking a XML file from a location and fetches to SAP proxy. I am getting a weird error while testing. The message is in delivering status. I mean m