Repeating JList

i having problem when press add button.. instate of adding a new list with the same element.. i want the quantity to become 2..
//listModel is the DefaultListModel
if (e.getSource() == addBtn) {   //when press add button
            for (int i = 0; i < listModel.getSize(); i++){
                if (listModel.elementAt(i) == listModel.lastElement()){   //a loop to check all the list with the last list element
                    listModel.removeElementAt(i);   // if equal delete the list
                    quantity++;
                    listModel.addElement("bla, bla" + quantity);    // then add a new list
}sry, just learn java a few month ago and i cant get other help.. this is the best method i can think of.. if got other method can post the link to it.. Thanx alot

if (listModel.elementAt(i) == listModel.lastElement())Don't use "==" to compare Objects. Use the equals(...) method.

Similar Messages

  • Moving items up and down in a JList

    Hello I posted this query in the wrong forum and so now I am trying to correct the problem Here is the link
    http://forum.java.sun.com/thread.jspa?threadID=5267663&tstart=0
    Hi-
    I have a problem with moving selected items up and down in a JList..
    When I select an item in the JList and press ctrl + (the up or down arrow key),
    I want the selected item to move up (or down).
    My code works. That is to say it does what I want, only the highlighted item does not correspond to the selected item.
    When I move an item up I would like it to remain selected, which I guess it is as repeated moves will move the item.
    But it does not appear to be working. because the highlight is above the selected item when moving up and below the selected item when moving down.
    Here is my code:
    public class MyClass  implements MouseListener,KeyListener
    private JList linkbox;
    private DefaultListModel dlm;
    public List<String> Links= new ArrayList<String>();
    private String Path;
    private JScrollPane Panel;
        public MyClass  (String path,JScrollPane panel){
        super();
            Path=path;
            Panel=panel;
    //Populate the ArrayList "Links" etcetera.
         dlm = new DefaultListModel();
            linkbox = new JList(dlm);
            for(int k=0;k<Links.size();k++){
                dlm.addElement(Links.get(k));
        public void keyPressed(KeyEvent e) {
        System.out.println("You pressed "+e.getKeyCode());
           if(e.getKeyCode()==38&&e.getModifiers()==KeyEvent.CTRL_MASK){
            Link sellink =linkbox.getSelectedValue();
                MoveUP(sellink);
            if(e.getKeyCode()==40&&e.getModifiers()==KeyEvent.CTRL_MASK){
                Link sellink =get(linkbox.getSelectedValue();
                MoveDown(sellink);
    private void MoveUP(Link link){
        int pos=-1;
        for(int p=0;p<Links.size();p++){
            Link l=Links.get(p);
            if(l.indexOf(link)==0){
            pos=p;
            break;
        if(pos!=-1&&pos>0){
            Links.remove(link);
            Links.add(pos-1,link);
            dlm.removeAllElements();
            for(int k=0;k<Links.size();k++){
            dlm.addElement(Links.get(k));
            Panel.setViewportView(linkbox);
            linkbox.setSelectedIndex(pos-1);
        private void MoveDown(Link link){
            int pos=-1;
            for(int p=0;p<Links.size();p++){
                Link l=Links.get(p);
                if(l.indexOf(link)==0){
                pos=p;
                break;
            if(pos!=Links.size()-1&&pos>0){
            System.out.println("pos= "+pos);
                Links.remove(link);
                Links.add(pos+1,link);
                dlm.removeAllElements();
                for(int k=0;k<Links.size();k++){
                dlm.addElement(Links.get(k));
                Panel.setViewportView(linkbox);
                linkbox.setSelectedIndex(pos+1);
        }And here is a compileable version...
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.util.ArrayList;
    import java.util.List;
    import javax.swing.DefaultListModel;
    import javax.swing.JFrame;
    import javax.swing.JList;
    import javax.swing.JScrollPane;
    import javax.swing.UIManager;
    class MoveableItems  implements KeyListener
         private JList jlist;
         private List<String> items = new ArrayList<String>();
         private DefaultListModel dlm;
         private JScrollPane sp;
         public MoveableItems(){
             JFrame f = new JFrame();
           items.add("Fox");
           items.add("Hounds");
           items.add("Cart");
           items.add("Horse");
           items.add("Chicken");
           items.add("Egg");
             dlm = new DefaultListModel();
            jlist = new JList(dlm);
             KeyListener[] kls=jlist.getKeyListeners();
             for(int k=0;k<kls.length;k++){
                 jlist.removeKeyListener(kls[k]); 
             jlist.addKeyListener(this);
             for(int k=0;k<items.size();k++){
                dlm.addElement(items.get(k));
              sp = new JScrollPane();
                sp.setViewportView(jlist);
             f.getContentPane().add(sp);
             f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             f.setSize(650, 250);
             f.setVisible(true);
         public static void main(String[] args)
             try{
                UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
                }catch(Exception e){System.out.println(e.getMessage());}
             new     MoveableItems();
        public void keyPressed(KeyEvent e) {
        System.out.println("You pressed "+e.getKeyCode());
            if(e.getKeyCode()==38&&e.getModifiers()==KeyEvent.CTRL_MASK){
            String selString =(String)jlist.getSelectedValue();
                MoveUP(selString);
            if(e.getKeyCode()==40&&e.getModifiers()==KeyEvent.CTRL_MASK){
                String selString =(String)jlist.getSelectedValue();
                MoveDown(selString);
        public void keyReleased(KeyEvent e) {
         public void keyTyped(KeyEvent e) {
    private void MoveUP(String link){
        int pos=-1;
        for(int p=0;p<items.size();p++){
            String l=items.get(p);
            if(l.indexOf(link)==0){
            pos=p;
            break;
        if(pos!=-1&&pos>0){
            items.remove(link);
            items.add(pos-1,link);
            dlm.removeAllElements();
            for(int k=0;k<items.size();k++){
            dlm.addElement(items.get(k));
            sp.setViewportView(jlist);
            jlist.setSelectedIndex(pos-1);
            jlist.requestFocus();
        private void MoveDown(String link){
            int pos=-1;
            for(int p=0;p<items.size();p++){
                String l=items.get(p);
                if(l.indexOf(link)==0){
                pos=p;
                break;
            if(pos<items.size()){
            System.out.println("pos= "+pos);
                items.remove(link);
                items.add(pos+1,link);
                dlm.removeAllElements();
                for(int k=0;k<items.size();k++){
                dlm.addElement(items.get(k));
                sp.setViewportView(jlist);
                jlist.setSelectedIndex(pos+1);
                jlist.requestFocus();
    }Now for some reason this works better.
    I notice that the highlight does follow the selection but there is also something else there.
    Still in my original version the highlight seems to appear where the dotted lines are?
    There seems to be dotted lines around the item above or below the selected item (depending on whether you are going up or down).
    Any thoughts at this point would be appreciated.
    -Reg.
    Can anyone explain to me why this is so and if it can be fixed?
    If any one can help I would be grateful,
    -Reg

    You seem to be making a genuine effort. Key Bindings like anything else involves getting familiar with the code and the idiosyncrasies involved and just playing with the code yourself. To get you started, if the JList were called myList I'd do something like this for the up key:
            KeyStroke ctrlUp = KeyStroke.getKeyStroke(KeyEvent.VK_UP, InputEvent.CTRL_DOWN_MASK);
            myList.getInputMap().put(ctrlUp, "Control Up");
            myList.getActionMap().put("Control Up", new AbstractAction()
                public void actionPerformed(ActionEvent e)
                    // do stuff to move your item up
            });Please read the tutorial for details, explanation, etc...

  • Can I Add a memo in the E61i calendar that repeats...

    Can I Add a memo in the E61i calendar that repeats weekly?

    Try this it worked, I not sure if this is what you want. a few ke things worth noticing, setPreferred size on the JPanel. That might be the reason it was not showing up, anyway here it is.
    import javax.swing.*;
    import java.awt.*;
    import java.util.Vector;
    public class temp extends JFrame{
         public temp(){
              super("Scroll Test");
              Vector myVector = new Vector();
              JPanel contentPane = new JPanel(new BorderLayout());
              for(int j = 0; j < 40; j++)
                   myVector.add(new String(j + ""));
              JList theList = new JList(myVector);
              JScrollPane sp = new JScrollPane(theList);
              JPanel p = new JPanel(new BorderLayout());
              p.setPreferredSize(new Dimension(100, 100));
              JMenuBar menuBar = new JMenuBar();
              JMenu menu = new JMenu("Scroll");
              p.add(sp, BorderLayout.CENTER);
              menu.add(p);
              menuBar.add(menu);
              this.setJMenuBar(menuBar);
              this.setContentPane(contentPane);
              this.setSize(300, 300);
         public static void main(String [] args){
              JFrame j = new temp();
              j.show();
    Good luct write back and tell me if this is what you were looking for!
    Late jason

  • Since installing LTR 5.4, which I've now upgraded to 5.6, I've encountered repeated slowness and malfunctions in operations, especially when using the Compare View function and the Tab key to open and close the right and left side panels.  Such problems n

    Since installing LTR 5.4, which I've now upgraded to 5.6, I've encountered repeated slowness and malfunctions in operations, especially when using the Compare View function and the Tab key to open and close the right and left side panels.  Such problems never arose during two years of using LTR-4 and nothing else has changed on my computer.  I have a pretty simple system with only a few plug-ins, which are usually not in operation.  I have 12GB of RAM in my Windows 7 PC.  I could illustrate these problems with screen shots if you would tell me how to submit screen shots.  Otherwise I will try to describe the problems in words.
    The problem is clearly cumulative, growing worse as usage time passes.  Compare View feature gradually slows down and eventually seems to choke as my work session proceeds. If I Exit LTR and re-enter and start all over, things will work normally for maybe 30 minutes, but then the Compare View feature begins to become very slow to respond.   In a recent example with my screen full of thumbnails in Library mode I highlighted two images to compare. LTR started to open the Compare View screen by first having the top row of thumbnails disappear to be replaced by the "SELECT" and "CANDIDATE" words in their spaces  (but no images), but Compare View never succeeded in gaining control of the screen. After some seconds the top row of thumbnails reasserted its position and the Compare View windows disappeared. But LTR kept trying to bring them back. Again the top row of thumbnails would go away, Select and candidate would reappear, try again, and give up. This went on for at least 2-3 minutes before I tried to choose File and Exit, but even that did not initially want to respond. It doesn't like to accept other commands when it's trying to open Compare View. Finally it allowed me to exit.
    To experiment I created a new catalog of 1100 images.  After 30-40 minutes, the Compare View function began to operate very slowly. With left and right side panels visible and two thumbnails highlighted, hitting Compare View can take half a minute before the two mid-size  images open in their respective SELECT and CANDIDATE windows. When the side panels are open and two images are in the Select/Candidate spaces, hitting the Tab button to close the side panels produces a very delayed response--25-30 seconds to close them, a few more seconds to enlarge the two images to full size. To reverse the process (i.e., to recall the two side panels), hitting Tab would make the two sides of the screen go black for up to a minute, with no words visible. Eventually the info fields in the panels would open up.
    I also created a new user account and imported a folder of 160 images. After half an hour Compare View began mis-placing data.  (I have a screen shot to show this.)  CANDIDATE appears on the left side of SELECT, whereas it should be on the right. The accompanying camera exposure data appears almost entirely to the left of the mid-screen dividing line. Although the Candidate and Select headings were transposed, the image exposure data was not, but the data for the image on the right was almost entirely to the left of the line dividing the screen in two.
    Gurus in The Lightroom Forum have examined Task Manager data showing Processes running and Performance indicators and they see nothing wrong.  I could also send screen shots of this data.
    At this point, the only way I can process my images is to work 30-40 minutes and then shut down everything, exit, and re-start LTR.  This is not normal.  I hope you can find the cause, and then the solution.  If you would like to see my screen shots, tell me how to submit them.
    Ollie
    [email protected]

    Since installing LTR 5.4, which I've now upgraded to 5.6, I've encountered repeated slowness and malfunctions in operations, especially when using the Compare View function and the Tab key to open and close the right and left side panels.  Such problems never arose during two years of using LTR-4 and nothing else has changed on my computer.  I have a pretty simple system with only a few plug-ins, which are usually not in operation.  I have 12GB of RAM in my Windows 7 PC.  I could illustrate these problems with screen shots if you would tell me how to submit screen shots.  Otherwise I will try to describe the problems in words.
    The problem is clearly cumulative, growing worse as usage time passes.  Compare View feature gradually slows down and eventually seems to choke as my work session proceeds. If I Exit LTR and re-enter and start all over, things will work normally for maybe 30 minutes, but then the Compare View feature begins to become very slow to respond.   In a recent example with my screen full of thumbnails in Library mode I highlighted two images to compare. LTR started to open the Compare View screen by first having the top row of thumbnails disappear to be replaced by the "SELECT" and "CANDIDATE" words in their spaces  (but no images), but Compare View never succeeded in gaining control of the screen. After some seconds the top row of thumbnails reasserted its position and the Compare View windows disappeared. But LTR kept trying to bring them back. Again the top row of thumbnails would go away, Select and candidate would reappear, try again, and give up. This went on for at least 2-3 minutes before I tried to choose File and Exit, but even that did not initially want to respond. It doesn't like to accept other commands when it's trying to open Compare View. Finally it allowed me to exit.
    To experiment I created a new catalog of 1100 images.  After 30-40 minutes, the Compare View function began to operate very slowly. With left and right side panels visible and two thumbnails highlighted, hitting Compare View can take half a minute before the two mid-size  images open in their respective SELECT and CANDIDATE windows. When the side panels are open and two images are in the Select/Candidate spaces, hitting the Tab button to close the side panels produces a very delayed response--25-30 seconds to close them, a few more seconds to enlarge the two images to full size. To reverse the process (i.e., to recall the two side panels), hitting Tab would make the two sides of the screen go black for up to a minute, with no words visible. Eventually the info fields in the panels would open up.
    I also created a new user account and imported a folder of 160 images. After half an hour Compare View began mis-placing data.  (I have a screen shot to show this.)  CANDIDATE appears on the left side of SELECT, whereas it should be on the right. The accompanying camera exposure data appears almost entirely to the left of the mid-screen dividing line. Although the Candidate and Select headings were transposed, the image exposure data was not, but the data for the image on the right was almost entirely to the left of the line dividing the screen in two.
    Gurus in The Lightroom Forum have examined Task Manager data showing Processes running and Performance indicators and they see nothing wrong.  I could also send screen shots of this data.
    At this point, the only way I can process my images is to work 30-40 minutes and then shut down everything, exit, and re-start LTR.  This is not normal.  I hope you can find the cause, and then the solution.  If you would like to see my screen shots, tell me how to submit them.
    Ollie
    [email protected]

  • Repeating a group element on each page of a report.

    I have a report where I need to repeat a group element on each page. The element is from the first group in the data. It is in the center group. Currently, the values from this group only print when the group changes. Everything I try does not work. Does anyone have any ideas. I am attaching a sample of the data. Along with the rtf document. I am using the BI Publisher plug in in Word to create the template.
    Data
    <?xml version="1.0" encoding="UTF-8"?>
    <POLLEDTICKETRPT>
    <USERCD>klockhar</USERCD><POLLDATE>03/24/2009</POLLDATE>
    <LIST_CENTER>
    <CENTER>
    <CENTER_CD>0039</CENTER_CD>
    <CENTER_NAME>CROSS PLAINS QUARRY</CENTER_NAME>
    <LIST_TRANSDATE>
    <TRANSDATE>
    <TRANS_DATE>03/11/2009</TRANS_DATE>
    <LIST_CUSTOMER>
    <CUSTOMER>
    <CUSTOMER_NBR>33221477</CUSTOMER_NBR>
    <CUST_NAME>TDOT DISTRICT 32-GALLATIN</CUST_NAME>
    <LIST_JOB>
    <JOB>
    <JOB_CUST>33221477</JOB_CUST>
    <JOB_CUST_NAME>TDOT DISTRICT 32-GALLATIN</JOB_CUST_NAME>
    <RGI_JOB_NBR>2008</RGI_JOB_NBR>
    <QUOTE_ID>0</QUOTE_ID>
    <LIST_COSTCODE>
    <COSTCODE>
    <COSTCODING/>
    <COST_CNTR/>
    <COST_ACCT/>
    <PROJECT_NBR/>
    <PROJECT_TASK/>
    <LIST_TICKET>
    <TICKET>
    <TICKET_NBR>5000021</TICKET_NBR>
    <ORIGIN_CD>TSCC</ORIGIN_CD>
    <REFERENCE_NBR>254510</REFERENCE_NBR>
    <VOID_IND>N</VOID_IND>
    <STATE_CD>TN</STATE_CD>
    <MEASURE_SYSTEM>S</MEASURE_SYSTEM>
    <LOCATION>THANK YOU</LOCATION>
    <PO_NBR>POS-254510-C</PO_NBR>
    <TAX_CODE>4</TAX_CODE>
    <PRODUCT_CD>000003</PRODUCT_CD>
    <HAUL_ZONE_CD/>
    <INVENTORY_STATUS>PR</INVENTORY_STATUS>
    <HAULER_NBR/>
    <RGI_TRANSPORT_CD>FU96</RGI_TRANSPORT_CD>
    <HAUL_RATE> .00</HAUL_RATE>
    <MAT_RATE> 8.50</MAT_RATE>
    <NET_TONS> -7.96</NET_TONS>
    <MAT_SALES_AMT> -67.66</MAT_SALES_AMT>
    <HAUL_AMT>0</HAUL_AMT>
    <TAX_AMT>0</TAX_AMT>
    <SEV_TAX_AMT>0</SEV_TAX_AMT>
    <SEV_TAX_IND>N</SEV_TAX_IND>
    <VALID_NET_TONS> -7.96</VALID_NET_TONS>
    <VALID_SALES_AMT> -67.66</VALID_SALES_AMT>
    <VALID_HAUL_AMT> .00</VALID_HAUL_AMT>
    <VALID_TAX_AMT> .00</VALID_TAX_AMT>
    <VALID_SEV_TAX_AMT> .00</VALID_SEV_TAX_AMT>
    <CASH_TONS> .00</CASH_TONS>
    <CASH_SALES_AMT> .00</CASH_SALES_AMT>
    <CASH_TAX_AMT> .00</CASH_TAX_AMT>
    <CASH_SEVTAX_AMT> .00</CASH_SEVTAX_AMT>
    <CASH_HAUL_AMT> .00</CASH_HAUL_AMT>
    <TRADE_TONS> -7.96</TRADE_TONS>
    <TRADE_SALES_AMT> -67.66</TRADE_SALES_AMT>
    <TRADE_TAX_AMT> .00</TRADE_TAX_AMT>
    <TRADE_SEVTAX_AMT> .00</TRADE_SEVTAX_AMT>
    <TRADE_HAUL_AMT> .00</TRADE_HAUL_AMT>
    <INTRA_TONS> .00</INTRA_TONS>
    <INTRA_SALES_AMT> .00</INTRA_SALES_AMT>
    <INTRA_TAX_AMT> .00</INTRA_TAX_AMT>
    <INTRA_SEVTAX_AMT> .00</INTRA_SEVTAX_AMT>
    <INTRA_HAUL_AMT> .00</INTRA_HAUL_AMT>
    <INTER_TONS> .00</INTER_TONS>
    <INTER_SALES_AMT> .00</INTER_SALES_AMT>
    <INTER_TAX_AMT> .00</INTER_TAX_AMT>
    <INTER_SEVTAX_AMT> .00</INTER_SEVTAX_AMT>
    <INTER_HAUL_AMT> .00</INTER_HAUL_AMT>
    <CASH_PR_TONS> .00</CASH_PR_TONS>
    <CASH_NP_TONS> .00</CASH_NP_TONS>
    <CASH_MI_TONS> .00</CASH_MI_TONS>
    <TRADE_PR_TONS> -7.96</TRADE_PR_TONS>
    <TRADE_NP_TONS> .00</TRADE_NP_TONS>
    <TRADE_MI_TONS> .00</TRADE_MI_TONS>
    <INTER_PR_TONS> .00</INTER_PR_TONS>
    <INTER_NP_TONS> .00</INTER_NP_TONS>
    <INTER_MI_TONS> .00</INTER_MI_TONS>
    <INTRA_PR_TONS> .00</INTRA_PR_TONS>
    <INTRA_NP_TONS> .00</INTRA_NP_TONS>
    <INTRA_MI_TONS> .00</INTRA_MI_TONS>
    </TICKET>
    </LIST_TICKET>
    </COSTCODE>
    </LIST_COSTCODE>
    </JOB>
    </LIST_JOB>
    </CUSTOMER>
    </LIST_CUSTOMER>
    </TRANSDATE>
    RTF Template
    DISPLAY CENTER
    S M
    FOR EACH CENTER
    SET CENTER
    CENTER: CENTER_CD CENTER_NAME
    FOR EACH TRANSDATE
    TRANSACTION DATE: TRANS_DATE
    FOR EACH CUSTOMER
    FOR EACH JOB
    Customer: JOB_CUST JOB_CUST_NAME
    Job: RGI_JOB_NBR Quote Id: QUOTE_ID
    FCC
    group COSTCODE by COSTCODING
    Cost Center: COST_CNTR Cost Acct: COST_ACCT Project: PROJECT_NBR Task: PROJECT_TASK
    Ticket Nbr     ORGCD     OrigTck     V     ST     Location     Po Nbr     Tax Cd     Prod Code     ZN     Hauler      Truck     Haul Rate     UnitPrice     Tons     SalesAmount
    F TCK#M     CODE     OTCK#     V     ST     LOCATION     PO_NBR      TC     PROD     HZ     HAULER     TRUCK     0.00     0.00     0.00 *      0.00 E

    Post Author: Guy
    CA Forum: General
    Hi,
    You should add a first level of grouping in your subreport on a fake formula field with a constant value.  Put your header and footer information in this group header and footer.  In the group option make sure to check the "repeat group header on each page option".
    This group will act as a page header + footer within your subreport.
    good luck!
    Guy

  • XML INVOICE Report RAXINV, Taxline is repeating for each invoice line

    Hi Tim
    Thanks a lot for your blog
    Greeting !!
    I have successfully created XML report for AR invoice Printing learning from your blog but stuck to a problem , whenever Invoice is having multiple lines ,say 20, then for each invoice line there is tax line printing 20 times like this:
    PART NO.| CUSTOMER PART#/DESCRIPTION | UNIT PRICE | QUNTITY|
    A123 | 34 WELD-ROD | 52 | 22 |
    Tax Exempt @ 0.00
    A234 | 238-AL WIER | 63 | 55 |
    Tax Exempt @ 0.00
    ........ Assume there are 20 lines then tax line also repeating 20 times which i don't want .It should get printed only once if it is same
    pls help me to achieve this
    Thanks
    Rahul

    Thanks Tim for Your Instant reply.
    I have gone through your duplicate line elimination but my requirement is not this
    I'll explain it, I am using LINE_DESCRIPTION tag for printing item description and this tag have two value for it, when the LINE_TYPE =LINE then LINE_DESCRIPTION tag is printing the line description and if LINE_TYPE =TAX
    then LINE_DESCRIPTION tag is printing the taxline information. Now if I have 20 lines in Invoice then the tax line will also repeat for 20 times, and if i use duplicate line elimination logic and I have same item it'll not print that item, some times whole invoice become blank.
    So I want to print 20 lines and out of that 15 lines are have same tax rate then it should print once at the end of 15th line and for remaining 5 lines if tax rate is different for each line then it should print at the end of each line (5lines)
    In the linetreevariable i used <xsl:variable xdofo:ctx="incontext" name="invLines" select=".//G_LINES [LINE_TYPE!='FREIGHT']"/> i.e. I want only line type=LINE and TAX
    Thanks
    Rahul

  • [bdb bug]repeatly open and close db may cause memory leak

    my test code is very simple :
    char *filename = "xxx.db";
    char *dbname = "xxx";
    for( ; ;)
    DB *dbp;
    DB_TXN *txnp;
    db_create(&dbp,dbenvp, 0);
    dbenvp->txn_begin(dbenvp, NULL, &txnp, 0);
    ret = dbp->open(dbp, txnp, filename, dbname, DB_BTREE, DB_CREATE, 0);
    if(ret != 0)
    printf("failed to open db:%s\n",db_strerror(ret));
    return 0;
    txnp->commit(txnp, 0);
    dbp->close(dbp, DB_NOSYNC);
    I try to run my test program for a long time opening and closing db repeatly, then use the PS command and find the RSS is increasing slowly:
    ps -va
    PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND
    1986 pts/0 S 0:00 466 588 4999 980 0.3 -bash
    2615 pts/0 R 0:01 588 2 5141 2500 0.9 ./test
    after a few minutes:
    ps -va
    PID TTY STAT TIME MAJFL TRS DRS RSS %MEM COMMAND
    1986 pts/0 S 0:00 473 588 4999 976 0.3 -bash
    2615 pts/0 R 30:02 689 2 156561 117892 46.2 ./test
    I had read bdb's source code before, so i tried to debug it for about a week and found something like a bug:
    If open a db with both filename and dbname, bdb will open a db handle for master db and a db handle for subdb,
    both of the two handle will get an fileid by a internal api called __dbreg_get_id, however, just the subdb's id will be
    return to bdb's log region by calling __dbreg_pop_id. It leads to a id leak if I tried to open and close the db
    repeatly, as a result, __dbreg_add_dbentry will call realloc repeatly to enlarge the dbentry area, this seens to be
    the reason for RSS increasing.
    Is it not a BUG?
    sorry for my pool english :)
    Edited by: user9222236 on 2010-2-25 下午10:38

    I have tested my program using Oracle Berkeley DB release 4.8.26 and 4.7.25 in redhat 9.0 (Kernel 2.4.20-8smp on an i686) and AIX Version 5.
    The problem is easy to be reproduced by calling the open method of db handle with both filename and dbname being specified and calling the close method.
    My program is very simple:
    #include <stdlib.h>
    #include <stdio.h>
    #include <sys/time.h>
    #include "db.h"
    int main(int argc, char * argv[])
    int ret, count;
    DB_ENV *dbenvp;
    char * filename = "test.dbf";
    char * dbname = "test";
    db_env_create(&dbenvp, 0);
    dbenvp->open(dbenvp, "/home/bdb/code/test/env",DB_CREATE|DB_INIT_LOCK|DB_INIT_LOG|DB_INIT_TXN|DB_INIT_MPOOL, 0);
    for(count = 0 ; count < 10000000 ; count++)
    DB *dbp;
    DB_TXN *txnp;
    db_create(&dbp,dbenvp, 0);
    dbenvp->txn_begin(dbenvp, NULL, &txnp, 0);
    ret = dbp->open(dbp, txnp, filename, dbname, DB_BTREE, DB_CREATE, 0);
    if(ret != 0)
    printf("failed to open db:%s\n",db_strerror(ret));
    return 0;
    txnp->commit(txnp, 0);
    dbp->close(dbp, DB_NOSYNC);
    dbenvp->close(dbenvp, 0);
    return 0;
    DB_CONFIG is like below:
    set_cachesize 0 20000 0
    set_flags db_auto_commit
    set_flags db_txn_nosync
    set_flags db_log_inmemory
    set_lk_detect db_lock_minlocks
    Edited by: user9222236 on 2010-2-28 下午5:42
    Edited by: user9222236 on 2010-2-28 下午5:45

  • Repeated Timeouts and "Lost" Interruptus

    Hello,
    At the risk of repeating an often-asked question, has anyone noticed particularly bad download speeds over the last two days? I have been attempting to download a single standard-definition episode of a TV show over a total of approximately seven hours. I've ruled out network problems; I am on a good DSL line and can download from other sources without difficulty. I have also been able to download much larger files from iTunes in a fraction of the time.
    Thanks...
    Benjamin Haag
    http://www.cbenjaminhaag.com

    Oh, and don't even get me started on SEARCH for text within a message. This has never worked, from Day One.
    All I ever get is "We were unable to perform your request. Please try again." SEARCH on header text, like Sender and Subject works fine, but apparently Verizon QA has never tested the other options on large mail inboxes.
    I'm pretty forgiving and undersrtanding of minor glitches and shortcomings in software, but Verizon Webmail is one of the most unreliable utilities that I've ever encountered from a large company with a huge customer base.

  • How can I delete repeats in my iPhoto library without going one at a time?

    I have been trying to clean up my iphoto library, and find that many of my imports have been repeated in different places. Is there a way to clean out repeat photos so there aren't so many of the same ones without having to do so one at a time?

    You can use any one of these applications to identify and remove duplicate photos from an iPhoto Library:
    iPhoto Library Manager - $29.95
    Duplicate Cleaner for iPhoto - free - was able to recognize the duplicated HDR and normal files from an iPhone shooting in HDR. 
    Duplicate Annihilator - $7.95 - only app able to detect duplicate thumbnail files or faces files when an iPhoto 8 or earlier library has been imported into another.
    PhotoSweeper - $9.95 - This app can search by comparing the image's bitmaps or histograms thus finding duplicates with different file names and dates.
    PhotoDedupo  - $4.99 (App Store) - this app has a "similar" search feature which is like PhotoSweeper's bitmap comparison.  It found all duplicates.
    DeCloner - $19.95 - can find dupicates in iPhoto Libraries or in folders on the HD.
    Some users have reported that PhotoSweeper did the best in finding all of the dups in their library: i photo has duplicated many photos, how...: Apple Support Communities.
    If you have an iPhone and have it set to keep the normal photo when shooting HDR photos the two image files that are created will be duplicates in a manner of speaking (same image) but the only diplicate finder app that detected the iPhone HDR and normal photos as being duplicates was PhotoSweeper.  None of the other apps detected those two files as being duplicates as they look for file name as well as other attributes and the two files from the iPhone have diffferent file names.
    iPLM, however, is the best all around iPhoto utility as it can do so much more than just find duplicates.  IMO it's a must have tool if using iPhoto.
    OT

  • How can I repeat a for loop, once it's terms has been fulfilled???

    Well.. I've posted 2 different exceptions about this game today, but I managed to fix them all by myself, but now I'm facing another problem, which is NOT an error, but just a regular question.. HOW CAN I REPEAT A FOR LOOP ONCE IT HAS FULFILLED IT'S TERMS OF RUNNING?!
    I've been trying many different things, AND, the 'continue' statement too, and I honestly think that what it takes IS a continue statement, BUT I don't know how to use it so that it does what I want it too.. -.-'
    Anyway.. Enought chit-chat. I have a nice functional game running that maximum allows 3 apples in the air in the same time.. But now my question is: How can I make it create 3 more appels once the 3 first onces has either been catched or fallen out the screen..?
    Here's my COMPLETE sourcecode, so if you know just a little bit of Java you should be able to figure it out, and hopefully you'll be able to tell me what to do now, to make it repeat my for loop:
    Main.java:
    import java.applet.*;
    import java.awt.*;
    @SuppressWarnings("serial")
    public class Main extends Applet implements Runnable
         private Image buffering_image;
         private Graphics buffering_graphics;
         private int max_apples = 3;
         private int score = 0;
         private GameObject player;
         private GameObject[] apple = new GameObject[max_apples];
         private boolean move_left = false;
         private boolean move_right = false;
        public void init()
            load_content();
            setBackground(Color.BLACK);
         public void run()
              while(true)
                   if(move_left)
                        player.player_x -= player.movement_speed;
                   else if(move_right)
                        player.player_x += player.movement_speed;
                   for(int i = 0; i < max_apples; i++)
                       apple.apple_y += apple[i].falling_speed;
                   repaint();
                   prevent();
                   collision();
              try
              Thread.sleep(20);
              catch(InterruptedException ie)
              System.out.println(ie);
         private void prevent()
              if(player.player_x <= 0)
              player.player_x = 0;     
              else if(player.player_x >= 925)
              player.player_x = 925;     
         private void load_content()
         MediaTracker media = new MediaTracker(this);
         player = new GameObject(getImage(getCodeBase(), "Sprites/player.gif"));
         media.addImage(player.sprite, 0);
         for(int i = 0; i < max_apples; i++)
         apple[i] = new GameObject(getImage(getCodeBase(), "Sprites/apple.jpg"));
         try
         media.waitForAll();     
         catch(Exception e)
              System.out.println(e);
         public boolean collision()
              for(int i = 0; i < max_apples; i++)
              Rectangle apple_rect = new Rectangle(apple[i].apple_x, apple[i].apple_y,
    apple[i].sprite.getWidth(this),
    apple[i].sprite.getHeight(this));
              Rectangle player_rect = new Rectangle(player.player_x, player.player_y,
    player.sprite.getWidth(this),
    player.sprite.getHeight(this));
              if(apple_rect.intersects(player_rect))
                   if(apple[i].alive)
                   score++;
                   apple[i].alive = false;
                   if(!apple[i].alive)
                   apple[i].alive = false;     
         return true;
    public void update(Graphics g)
    if(buffering_image == null)
    buffering_image = createImage(getSize().width, getSize().height);
    buffering_graphics = buffering_image.getGraphics();
    buffering_graphics.setColor(getBackground());
    buffering_graphics.fillRect(0, 0, getSize().width, getSize().height);
    buffering_graphics.setColor(getForeground());
    paint(buffering_graphics);
    g.drawImage(buffering_image, 0, 0, this);
    public boolean keyDown(Event e, int i)
         i = e.key;
    if(i == 1006)
    move_left = true;
    else if(i == 1007)
         move_right = true;
              return true;     
    public boolean keyUp(Event e, int i)
         i = e.key;
    if(i == 1006)
    move_left = false;
    else if(i == 1007)
         move_right = false;
    return true;
    public void paint(Graphics g)
    g.drawImage(player.sprite, player.player_x, player.player_y, this);
    for(int i = 0; i < max_apples; i++)
         if(apple[i].alive)
              g.drawImage(apple[i].sprite, apple[i].apple_x, apple[i].apple_y, this);
    g.setColor(Color.RED);
    g.drawString("Score: " + score, 425, 100);
    public void start()
    Thread thread = new Thread(this);
    thread.start();
    @SuppressWarnings("deprecation")
         public void stop()
         Thread thread = new Thread(this);
    thread.stop();
    GameObject.java:import java.awt.*;
    import java.util.*;
    public class GameObject
    public Image sprite;
    public Random random = new Random();
    public int player_x;
    public int player_y;
    public int movement_speed = 15;
    public int falling_speed;
    public int apple_x;
    public int apple_y;
    public boolean alive;
    public GameObject(Image loaded_image)
         player_x = 425;
         player_y = 725;
         sprite = loaded_image;
         falling_speed = random.nextInt(10) + 1;
         apple_x = random.nextInt(920) + 1;
         apple_y = random.nextInt(100) + 1;
         alive = true;
    And now all I need is you to answer my question! =)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    package forums;
    import java.util.Random;
    import javax.swing.Timer;
    import javax.imageio.ImageIO;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.io.*;
    public class VimsiesRetardedAppleGamePanel extends JPanel implements KeyListener
      private static final long serialVersionUID = 1L;
      private static final int WIDTH = 800;
      private static final int HEIGHT = 600;
      private static final int MAX_APPLES = 3;
      private static final Random RANDOM = new Random();
      private int score = 0;
      private Player player;
      private Apple[] apples = new Apple[MAX_APPLES];
      private boolean moveLeft = false;
      private boolean moveRight = false;
      abstract class Sprite
        public final Image image;
        public int x;
        public int y;
        public boolean isAlive = true;
        public Sprite(String imageFilename, int x, int y) {
          try {
            this.image = ImageIO.read(new File(imageFilename));
          } catch (IOException e) {
            e.printStackTrace();
            throw new RuntimeException("Bailing out: Can't load images!");
          this.x = x;
          this.y = y;
          this.isAlive = true;
        public Rectangle getRectangle() {
          return new Rectangle(x, y, image.getWidth(null), image.getHeight(null));
      class Player extends Sprite
        public static final int SPEED = 15;
        public Player() {
          super("C:/Java/home/src/images/player.jpg", WIDTH/2, 0);
          y = HEIGHT-image.getHeight(null)-30;
      class Apple extends Sprite
        public int fallingSpeed;
        public Apple() {
          super("C:/Java/home/src/images/apple.jpg", 0, 0);
          reset();
        public void reset() {
          this.x = RANDOM.nextInt(WIDTH-image.getWidth(null));
          this.y = RANDOM.nextInt(300);
          this.fallingSpeed = RANDOM.nextInt(8) + 3;
          this.isAlive = true;
      private final Timer timer = new Timer(200,
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            repaint();
      public VimsiesRetardedAppleGamePanel() {
        this.player = new Player();
        for(int i=0; i<MAX_APPLES; i++) {
          apples[i] = new Apple();
        setBackground(Color.BLACK);
        setFocusable(true); // required to generate key listener events.
        addKeyListener(this);
        timer.setInitialDelay(1000);
        timer.start();
      public void keyPressed(KeyEvent e)  {
        if (e.getKeyCode() == e.VK_LEFT) {
          moveLeft = true;
          moveRight = false;
        } else if (e.getKeyCode() == e.VK_RIGHT) {
          moveRight = true;
          moveLeft = false;
      public void keyReleased(KeyEvent e) {
        moveRight = false;
        moveLeft = false;
      public void keyTyped(KeyEvent e) {
        // do nothing
      public void paintComponent(Graphics g) {
        super.paintComponent(g);
        //System.err.println("DEBUG: moveLeft="+moveLeft+", moveRight="+moveRight);
        if ( moveLeft ) {
          player.x -= player.SPEED;
          if (player.x < 0) {
            player.x = 0;
        } else if ( moveRight ) {
          player.x += player.SPEED;
          if (player.x > getWidth()) {
            player.x = getWidth();
        //System.err.println("DEBUG: player.x="+player.x);
        Rectangle playerRect = player.getRectangle();
        for ( Apple apple : apples ) {
          apple.y += apple.fallingSpeed;
          Rectangle appleRect = apple.getRectangle();
          if ( appleRect.intersects(playerRect) ) {
            if ( apple.isAlive ) {
              score++;
              apple.isAlive = false;
        g.drawImage(player.image, player.x, player.y, this);
        for( Apple apple : apples ) {
          if ( apple.isAlive ) {
            g.drawImage(apple.image, apple.x, apple.y, this);
        g.setColor(Color.RED);
        g.drawString("Score: " + score, WIDTH/2-30, 10);
      private static void createAndShowGUI() {
        JFrame frame = new JFrame("Vimsies Retarded Apple Game");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(new VimsiesRetardedAppleGamePanel());
        frame.pack();
        frame.setSize(WIDTH, HEIGHT);
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);
      public static void main(String[] args) {
        SwingUtilities.invokeLater(
          new Runnable() {
            public void run() {
              createAndShowGUI();
    }Hey Vimsie, try resetting a dead apple and see what happens.

  • Can I switch calendars (Ex. "night shift" to "day shift" cal) with a repeating event, but ONLY for that one event??  It asks "for all events or only this event" if i change the time.  But it changes ALL events when i try and switch calendars.  Any help??

    I have 2 calendars set up for my work schedule, a "night shift" and "day shift" calendar.  I've set up repeating events fro Fri/Sat/Sun 3-11pm "night shifts" and Mon/Tues 7am-3pm "day shifts".  But lets say for example that I swap shifts and instead of working nights on Saturday like I normally would, I am now working days.  I want to change that in my calendar.  When I go to change the event, if i change the TIME it asks if i want to change all event or ONLY this event.  no problem....just this single event.  but when i go to change the event from the "night shift" calendar to the "day shift" calendar, it changes ALL the repeating events, and not just that one single event.   can anyone help with this???  am i doing something wrong?  is there a way to do this or not with the new iCal program???  i used to do this and never had any problems.    Thank you!

    You need to follow iPhoto terms since we only know what you tell us
    what are you calling folders - in iPhoto folders can not hold photos - albums hold photos and folders hold albums or other folders
    The basic default view of photo is by event (iPhoto '08 and later)
    Exactly what you you trying to do?
    LN

  • High school block schedule repeating events

    I'm a high school teacher looking forward to the upcoming fall schedule. I teach at a school where even period and odd period classes are taught on alternate days and I teach only odd schedule classes. So, one week the class is taught on Mon, Wed, Fri and the next week it is Tu and Th except for weeks that have holidays. What is the best way to use repeating events and make up the schedule for this semester (ending 1/28/08 so I also know at a glance what days I'm available to substitute for other instructors?

    I'm a high school teacher looking forward to the upcoming fall schedule. I teach at a school where even period and odd period classes are taught on alternate days and I teach only odd schedule classes. So, one week the class is taught on Mon, Wed, Fri and the next week it is Tu and Th except for weeks that have holidays. What is the best way to use repeating events and make up the schedule for this semester (ending 1/28/08 so I also know at a glance what days I'm available to substitute for other instructors?

  • How can I set an event to repeat on a week day rather than a numerical day of each month?

    How can I set an event to repeat on a week day rather than a numerical day of each month? I see an option at the bottom of the repeat window .... but I cannot use it. Actually, when I try it freezes up my Calendar.
    Lorrene Baum Davis

    These scrrenshots are from Snow Leopard - I would think that Lion wouldn't be too much different.

  • Standard def STB repeatedly blacks out for a second or 2

    A site search on "black out" does not turn up a similar issue, of course it may be my search skills are lacking. 
    New subsciber since Sep 2010.   I have 3 boxes, 2 standard QIP2500 phase 3 (basement/MBR) and 1 hi-def (LR). Hi def TV in MBR, standard in other 2.  Both standards would on occassion 'black out' for just a second or 2 ever since original install. No problem with the hi-def. One standard is wired with coax, one with s-video, the hi-def with HDMI.  When the black out occurs, the screen will freeze for an instant, then the screen goes black, then it comes back. The information on the box does not black out, the TVs don't power-off and restart. It's just the screen goes blank and then comes back. It happens without any seeming warning, and will happen at any time of day. Sometimes it will happen repeatedly, sometimes it won't happen for a long time.  Both boxes have been repeatedly reset and rebooted with no improvement.  During one tech call the tech had me relocate one of the standard boxes to the hi-def location to isolate that it wasn't a location (in-house cable) problem. I thought it curious since it was happening at 2 different locations but went through the drill anyway.  The relocated standard worked for a few minutes, then went black for a second as the problem does.  Plugging the high-def back in resolved the issue at that location. The tech said he would send 2 new standard boxes. The replacement boxes have not resolved the issue.  Any suggestions? 

    if it's doing that on two different boxes using both coax and s-video then I think that leaves a possibility of the coax.  that would be a unusual symptom of a bad coax/splitter but try this.  
    Wait for it to start acting up - when it starts acting up, stay tuned to that station, and hit your menu > customer support > in home agent > network diagnostics and click ok to start.
    check the video signal using that menu selection.  after it's done running it will give you a general message like "you're video signals are not in the optimal range"     after you see that, hit info and then look at the SNR DB   it should give you a number.
    32-36 is optimal, below that is questionable.
    If it is below that then it's probably going to be a problem with the splitter at your house, and you would either replace it yourself, or call verizon to replace it.  be sure to tell them the DB

  • Hi. I am building a website with the White template. Does anyone know which typeface was used by Apple on the heading index? (I would like to repeat the index at the bottom of my pages).

    Hi I am building a website using iWeb's white template. I can't write HTML, so can't change the index, but would like to repeat it at the bottom of my pages. Does anyone know which typeface Apple used? Presumably it would be 'web friendly' for use as described above?

    Arial
    PS. You can see it in the source of the published page where it says new NavBar etc...
    ".navbar {\n\tfont-family: Arial, sans-serif;\n\tfont-size: 1em;\n\tcolor: #666;\

Maybe you are looking for

  • Networking dilemma

    I have an Actiontec GT-701-WG Wireless router for my DSL connection.  My main PC is running XP-Pro, and I have 2-laptops running Vista (Premium Home & Office).  I went to my local Best Buy and purchased a Dynex DX-E402 Router (their recommendation) t

  • Pb communication TCP/IP avec un oscillo Lecroy 6100 et librairie Visa

    Hello, I am trying to communicate with a remote Lecroy 6100 scope through TCP/IP, using the visa library. I have configured my device with MAX but it can not open an INSTR session. I have check the IP address, my device respond to a ping. I have inst

  • Bussines rules problems using Struts + BC4J

    Hi, I'm using struts + bc4j and I have some problems with the validations made on the entities. Looks like sometimes, struts didn't shows the error message until the commit is made. But the problem is that on the navigator shows me the stack trace of

  • ORA-29532: It Works with JDeveloper and fails under Database

    Hello, We have a web service client. It works fine under JDeveloper but when we upload it to the database and we excute a procedure calling it. Exception message "ORA-29532: llamada Java terminada por una excepción Java no resuelta: java.lang.Error:

  • UK Nokia Service Centre

    I have phoned the 4 nearest Nokia service centres (up to 50 miles away!) and NONE of them say they can do the firmware upgrade on the Nokia N70, the excuses are either they don't have the hardware or don't have the firmware file. What is going on? Ho