Some help with counter

I am very new to java and would like a little assistance with the following code. The problem is in the iCount, it is supposed to count to 30 and then exit the program. Program fails to exit. Any clue as to where to look would be appreciated.
Thanks!!
// Program Name:Mortgage Payment Calculator
// Date Written:04-09-06
// Student Name: XXXXXXXX
// Facilitator: XXXXXXXX     
// Purpose of Program:Calculate mortgage payments
// Modified 04-21-06:Revision 1.1 added Amortized payment data.
// Write the program in Java (without a graphical user
// interface) using a loan amount of $200,000 with an
// interest rate of 5.75% and a 30 year term. Display
// the mortgage payment amount and then list the loan
// balance and interest paid for each payment over the
// term of the loan. If the list would scroll off the
// screen, use loops to display a partial list, hesitate,
// and then display more of the list.
// Modified 04-28-06: Revision 1.2, Write the program in Java
//                    (without a graphicaluser interface) and have it 
//                    calculate the payment amount for 3 mortgage loans:
//                         7 year at 5.35%
//                         15 year at 5.5%
//                         30 year at 5.75%
// Use an array for the different loans. Display the mortgage
// payment amount for each loan.
// Modified 05-01-06: Revision 1.3, Write the program in Java
//                           (without a graphical user interface) and
//                           have it calculate the payment amount for
//                            3 mortgage loans:
//                         7 year at 5.35%
//                         15 year at 5.5%
//                         30 year at 5.75%
// Use an array for the different loans. Display the
// mortgage payment amount for each loan and then list the
// loan balance and interest paid for each payment over the
// term of the loan. Use loops to prevent lists from
// scrolling off the screen.
// load API's needed to perform the formatting ofvariables
import java.io.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.Locale;
// Here we declare our class
public class MortgageCalculatorwk5
    // Declaration of the main method
    public static void main (String[] args)throws IOException
        // Used to format the outputs
           NumberFormat currency = NumberFormat.getCurrencyInstance(Locale.US);
         DecimalFormat percentage = new DecimalFormat("0.00%");
          DecimalFormat decimalPlaces = new DecimalFormat("0.00");
          BufferedReader keyboardInput = new BufferedReader (new InputStreamReader (System.in));
               //Declaration of variables used **Restructured Variable block in Revision 1.1**
               //Revision 1.3 Variables restructured for Arrays
              double monthlyPayment[];
              double loanAmount;
              //double yearlyInterest;     //changed to an array in Revision 1.2
              double monthlyPrinciple[];
              double calcPrinciple[];          //Not Needed in 1.2**added back in Revision 1.3 as an array**
              double calcInterest[];          //Not Needed in 1.2**added back in Revision 1.3 as an array**
              double calcBalance[];          //Not Needed in 1.2**added back in Revision 1.3 as an array**
              int iCount;                         //Not Needed in 1.2**added back in Revision 1.3**
              //int termYears;                     //changed to an array in Revision 1.2
              int termMonths = 360;
              int Amortized;                    //Not Needed in 1.2**added back in Revision 1.3**
              String keyPress;               //Added in Revision 1.3 for keyboard input
                  // Assigned variables declared above.**Updated variable block in Rev. 1.1 to match declarations**
                  // Revision 1.3, variables to match declarations
                  loanAmount = 200000;
                  //yearlyInterest = .0575;             //Revised in 1.2
                  monthlyPayment = new double[3];       //Changed to Array in Revision 1.3
                  Amortized = 0;                            //Not needed in 1.2**added back in Revision 1.3**
                  //termYears = 30;                      //Not needed in 1.2
                  calcPrinciple = new double[3];        //Not Needed in 1.2**added back in Revision 1.3**
                  calcBalance = new double[3];        //Not Needed in 1.2**added back in Revision 1.3**
                      calcInterest = new double[3];       //Not Needed in 1.2**added back in Revision 1.3**
                      monthlyPrinciple = new double[3]; //Added in Revision 1.3
                      keyPress = "";                           //Added in Revision 1.3
                      iCount = termMonths;
                 //Array for yearly interest rates     
                 double[] yearlyInterest = {.0535,.055,.0575}; //added in Revision 1.2
                 //Array for loans in years
                 int[] termYears = {7,15,30};//added in Revision 1.2
        //Output to the display**Revision 1.1 added rev level and title        
        System.out.println ();     
          System.out.println ("\t\t\t McBride Financial Services ");
          System.out.println ();
          System.out.println ("\t\t\t     Mortgage Calculator");
          System.out.println ("\t\t\t         Version 1.3     ");
          System.out.println ();
     for (int a = 0; a < yearlyInterest.length; a++)
               //Calculations for yearly interest rate and 
               //total number of months for each loan
               calcBalance[a] = loanAmount;//Added in Revision 1.3
               termMonths = termYears[a] * 12;
               monthlyPrinciple[a] = yearlyInterest[a] / 12;
     if      (iCount < (termYears[a] * 12))
          iCount = (termYears[a] * 12);
          // Here is the Calculator Algorithm**Revision1.1 updated variables and caclulations
             monthlyPayment[a] = (loanAmount * (Math.pow((1 + monthlyPrinciple[a]), termMonths)) * monthlyPrinciple[a]) / (Math.pow((1 + monthlyPrinciple[a]), termMonths)-1);
                  //calcBalance = loanAmount; //Not Needed in Revision 1.2
                  //iCount = termMonths; //Not Needed in Revision 1.2
          System.out.println("For " + termYears[a] + " years: ");
          System.out.print(currency.format(loanAmount));
          System.out.print(" at a yearly rate of ");
          System.out.print(percentage.format(yearlyInterest[a]) + ", ");
          System.out.print("Monthly Payment is " + currency.format(monthlyPayment[a]) + ".");
          System.out.println("\n\n");
          //System.out.println(decimalPlaces.format(monthlyPayment)); Revision 1.2 changed to currency format
}// end for loop
     System.out.print ("Press ~Enter~ to Continue");
     keyPress = keyboardInput.readLine();
     System.out.println("\n\n\n");
/***THE FOLLOWING BLOCK OF CODE HAS BEEN REMOVED PER REVISION 1.2************
*Added and slightly modified the following block of code for Revision 1.3*/     
     //try
          //Thread.sleep(2000);  //2 second hesitation **Removed on Revision 1.3
     // This checks to see if an interruption
     // has occured in the count sequence.
     //The braces are empty because we will
     //not have any other code call for an interruption.
     //catch (InterruptedException e) {}
        System.out.println("\n\n             7 Years\t            15 Years\t\t    30 Years");     
          System.out.println("Pmnt\tInterest/Balance\tInterest/Balance\tInterest/Balance");
        System.out.println("=============================================================================");       
        System.out.println();      
    for (; iCount>0;)//This loop will run as long as iCount is greater than 0.
             Amortized++;
             System.out.print("\n " + Amortized);
    for
              (int a = 0; a < yearlyInterest.length; a++)
             calcInterest[a] = calcBalance[a] * monthlyPrinciple[a];
             calcPrinciple[a] = monthlyPayment[a] - calcInterest[a];
             calcBalance[a] = calcBalance[a] - calcPrinciple[a];
     switch (a)
          case 0:
                  if (calcBalance[a] <= 0.0)
                       calcBalance[a] = 0.0;
               if
                    (calcInterest[a] <= 0.0)
                    System.out.print("\t\t\t    ");     
               else
                    System.out.print("\t  " + currency.format(calcInterest[a]) + "\t\t");
} //end if statment
                 else //calcBalance[a] is NOT <= 0
             if (calcInterest[a] < 1000.0) //Used for alignment
                      System.out.print("\t" + currency.format(calcInterest[a]) + "\t");
                 else
                      System.out.print("\t" + currency.format(calcInterest[a]));
                      System.out.print(currency.format(calcBalance[a]));
} //end else statment
             break;
} //end case
          case 1:
                  if
                       (calcBalance[a] <= 0.1)
                   calcBalance[a] = 0.0;
             if
                  (calcInterest[a] <= 0.0)
                   System.out.print("\t\t\t");     
             else
                   System.out.print("\t" + currency.format(calcInterest[a]) + "\t\t");
} //end if statment
              else
             if
                  (calcInterest[a] < 1000.0) //For alignment
                      System.out.print("\t" + currency.format(calcInterest[a]) + "\t");
                 else
                      System.out.print("\t" + currency.format(calcInterest[a]));
                      System.out.print(currency.format(calcBalance[a]));
} //end else
             break;
} //end case
            case 2:
             if
                  (calcBalance[a] <= 0.0)
                   calcBalance[a] = 0.0;
             if
                  (calcInterest[a] <= 0.0)
                   System.out.print("\t\t\t    ");     
              else
                   System.out.print("\t" + currency.format(calcInterest[a]) + "\t\t");
} //end if
              else //calcBalance[a] is not <= 0
              if
                   (calcInterest[a] < 1000.0) //For alignment
                      System.out.print("\t" + currency.format(calcInterest[a]) + "\t");
                 else
                      System.out.print("\t" + currency.format(calcInterest[a]));
                      System.out.print(currency.format(calcBalance[a]));
} //end else
             break;
} //end case
} //end switch
} //end loop                    
    if (Amortized % 12 ==0 ) { //Screen prints 12 (1 year) lines then waits for input from keyboard
               System.out.println();
               System.out.print("=============================================================================\n");       
     for
          (int a = 0; a<yearlyInterest.length; a++)
               System.out.print("  At " + (Amortized/12) + " year(s) ");
              System.out.print("Balance on Loan " + (a+1) + " is $");
              System.out.println(currency.format(calcBalance[a]) + ".");          
                 //Thread.sleep(2000); //2 second hesitation Replaced with Keyboard input on Revision 1.3
                 System.out.print ("Press ~Enter~ to Continue");
               keyPress = keyboardInput.readLine();
     if
               (calcBalance[2] > 0.1 )
               System.out.println("\n\n             7 Years\t            15 Years\t\t    30 Years");     
               System.out.println("Pmnt\tInterest/Balance\tInterest/Balance\tInterest/Balance");
               System.out.println("===========================================================================");
     // This checks to see if an interruption
     // has occured in the count sequence.
     //The braces are empty because we will
     //not have any other code call for an interruption.
     //catch (InterruptedException e) { }
     iCount = iCount-1;//counter
}//end if
}//end if
}//end loop
}//end main
}//end class

Have you ever heard of methods? How about Objects? How about Classes?
Your solution looks better suited for basic or qbasic.
I for one am not even going to look at your spagetti code to try to figure out where your counter went astray.....
http://java.sun.com/docs/books/tutorial/getStarted/index.html
http://java.sun.com/docs/books/tutorial/java/nutsandbolts/index.html
http://java.sun.com/docs/books/tutorial/java/index.html
You should study before you do..
Im sorry if I'm blunt, I dont mean to be disrespectful, but in the short time I have been a member in these forums, this truely qualifies as the wosrt code I have ever seen. You dont even make an attempt at being object oriented.
I highly suggest you do some of the tutorials, at a minimum cover the language basics, object basics, methods, and classes. Then really think about the the problem you are trying to solve, describing the objects involved.
Good luck.
JJ

Similar Messages

  • Need some help with count query

    Hello,
    I'm terrible @ oracle, so bear with me. I am trying to use the count function with my query but it counts rows from different tables.
    I want my query to basically add a column from another table but have it not be a part of the count.
    Say, table1 table2 table3. My count is right between the first two tables (Buyers,5).But since in table3 there are duplicate values(or accounts in this case(3), the count multiples by that many (15).
    I need it to read Buyers,5,account #. I've tried distinct and a union but to no avail.
    Help me please.

    If I understand you correctly, you want to count the records in table1 and table2 which have a one-to-one relationship, but you need to display additional data from table3 which has a one-to-many relationship. If this is correct, you need to use an in-line view to join table1 and table2 then join that in-line view to table3 to display the data from it. Something along the lines of:
    SELECT v.col1, v.col2, v.col3, v.col4, v.cnt, t3.col1 t3col1, t3.col2 t3col2
    FROM (SELECT t1.col1, t1.col2, t2.col1 col3, t2.col2 col4, COUNT(*) cnt
          FROM table1 t1, table2 t2
          WHERE <join conditions between t1 and t2> and
                <other conditions if required>
          GROUP BY t1.col1, t1.col2, t2.col1, t2.col2) v,
         table3 t3
    WHERE <join conditions between v and t3>
          <other conditions if required>John

  • I'm moving to college soon, and would appreciate some help with my library.

    I am moving to college in just over a week and a half and was needing some help with my iTunes library. Currently, at home, I use iTunes as my main source of music entertainment. I purchase music through the iTues Store and upload older music from CDs onto the library as well. I have made several smart playlists based off of information such as play counts and last played dates. Unfortunately, this is all on a desktop that I will be unable to bring with me to school. So I have recently purchased a laptop that I will be taking with me to school. I have already downloaded iTunes and have activated the laptop to my Apple ID. The desktop currently runs on Windows 7, while the laptop runs on Windows 8. Both are up-to-date with iTunes.
    With all of that background information, here comes my question. Is there a way to have the same library on both PCs? I don't just mean the same songs, but rather have the same play counts, last played dates, playlists, etc. on both computers. Is this something that can be accomplished through the cloud or iTunes Match?

    Copy the ENTIRE /Music/iTunes folder from the old computer to the new computer.
    Sync only with the new computer going forward.
    Nothing will be updated on the old computer, but if you are not going to be at home using the desktop is that really relevant?

  • Error 1603: Need some help with this one

    When installing iTunes I first get an error box saying
    "Error 1406: Could not write value to key \Software\classes\.cdda\OpenWithList\iTunes.exe. Verify that you have sufficient access to that key, or contact your support personnel."
    The second one (after I click on Ignore on the last box) I get it this one:
    "Error: -1603 Fatal error during installation.
    Consult Windows Installer Help (Msi.chm) or MSDN for more information"
    Strange thing is that I do have full access to my computer (or atleast in all other cases I have had since I am the only one with an account on it).
    I have done my best in trying to solve it myself but I'm running out of ideas. I have downloaded latest versions from the website and tried installing Quicktime separately. I have also tried removing Quicktime using add/or remove programs though I just I didn't dare to take full removal because it said something about system files.
    Anyway I really need some help with this, anyone got any ideas?
    Greets,
    Sixten
      Windows XP Pro  

    Do you know how to count backwards? Do you know how to construct a loop? Do you know what an autodecrementor is? Do you know how to use String length? Do you know Java arrays start with index 0 and run to length-1? Do you know you use length on arrays too? Do you know what System.out.println does?
    Show us what you have, there isn't anything here that isn't easily done the same as it would be on paper.

  • Hoping for some help with a very frustrating issue!   I have been syncing my iPhone 5s and Outlook 2007 calendar and contacts with iCloud on my PC running Vista. All was well until the events I entered on the phone were showing up in Outlook, but not

    Hoping for some help with a very frustrating issue!
    I have been syncing calendar and contacts on my iPhone 5 and Outlook 2007 using iCloud  2.1.3 (my PC is running Vista). All was well until the events I entered on the phone were showing up in Outlook, but not the other way around. I’ve tried the usual recommended steps: deselecting calendar and contacts in the iCloud control panel and then re-selecting, signing out of the panel and back in, and repairing the Outlook installation in control panel.  I even uninstalled iCloud on the PC and downloaded it again (same version). 
    The furthest I’ve gotten is step 2 (and once, step 3) of 7 while performing “Outlook Setup For iCloud.” At that point I get, “Your setup couldn’t be started because of an unexpected error.”  After the first attempt at all this, all my calendar events disappeared from Outlook, although they are still in iCloud calendar and on my phone.
    Sound familiar?  Any ideas on how to solve this iCloud/Outlook issue?  Thanks much in advance!

    Hoping for some help with a very frustrating issue!
    I have been syncing calendar and contacts on my iPhone 5 and Outlook 2007 using iCloud  2.1.3 (my PC is running Vista). All was well until the events I entered on the phone were showing up in Outlook, but not the other way around. I’ve tried the usual recommended steps: deselecting calendar and contacts in the iCloud control panel and then re-selecting, signing out of the panel and back in, and repairing the Outlook installation in control panel.  I even uninstalled iCloud on the PC and downloaded it again (same version). 
    The furthest I’ve gotten is step 2 (and once, step 3) of 7 while performing “Outlook Setup For iCloud.” At that point I get, “Your setup couldn’t be started because of an unexpected error.”  After the first attempt at all this, all my calendar events disappeared from Outlook, although they are still in iCloud calendar and on my phone.
    Sound familiar?  Any ideas on how to solve this iCloud/Outlook issue?  Thanks much in advance!

  • Can some help with CR2 files ,Ican`t see CR2 files in adobe bridge

    can some help with CR2 files ,I can`t see CR2 files in adobe bridge when I open Adobe Photoshop cs5- help- about plugins- no camera raw plugins. When i go Edit- preference and click on camera raw  shows message that Adobe camera raw plugin cannot be found

    That's strage. Seems that the Camera Raw.8bi file has been moved to different location or has gone corrupt. By any chance did you try to move the camera raw plugin to a custom location?
    Go To "C:\Program Files (x86)\Common Files\Adobe\Plug-Ins\CS5\File Formats" and look for Camera Raw.8bi file.
    If you have that file there, try to download the updated camera raw plugin from the below location.
    http://www.adobe.com/support/downloads/thankyou.jsp?ftpID=5371&fileID=5001
    In case  you ae not able to locate the Camera Raw.8bi file on the above location, then i think you need to re-install PS CS5.
    [Moving the discussion to Photoshop General Discussions Forum]

  • Hello everyone, hoping for some help with my new Apple Cinema Display 20"

    Hi everyone, I bought an Apple Cinema Display 20 inch LCD monitor, just about 3 weeks ago. I have two issues I am hoping to get some help with.
    1) I am using the screen on a PC with Windows XP, and I was very disappointed at the lack of PC support. I have no on screen display (OSD), so I can't see what percentage I have my brightness set to, and I can't alter the colour or contrast of the display, etc. Luckily it defaulted to very good settings, but I would really like to be able to use the (fan made?) program called "WinACD". If I would be best asking somewhere else, please direct me there. If not, my problem is that I installed it added the "Controls" tab, but it just says, Virtual Control Panel "None Present". I have tried googling for an answer, and I have seen many suggestions, but none of them worked. I installed the WinACD driver without my USB lead plugged in, and someone said that was important. So I have tried uninstalling, rebooting, then reinstalling it again with the USB plugged in, and a device plugged in to my monitor to be sure. It didn't seem to help. I have actually done this process a few times, just to be sure. So I would really like to get that working if possible.
    2) I am disappointed at the uniformity of the colour on the display. I have seen other people mention this (again, after a google search), and that someone seemed to think it is just an issue we have to deal with, with this generation of LCD monitors. Before I bought this screen, I had an NEC (20wgx2), and it had a very similar issue. Most of the time, you cannot see any problem at all, but if you display an entire screen with a dark (none prime) colour, like a dark blue green colour, you can see areas where it is slightly darker than others. It was more defined on the NEC screen, and that is why I returned it. I now bought this Apple Cinema Display, because it was the only good alternative to the NEC. (It has an 8bit S-IPS / AS-IPS panel, which was important to me). But the problem exists in this screen too. It isn't as bad thankfully, but it still exists... I have actually tried a third monitor just to be sure, and the problem existed very slightly in that one, so I think I am probably quite sensitive in that I can detect it.
    It is most noticable to me, because I do everything on this PC. I work, I watch films, and I play games. 99% of the time, I cannot see this problem. But in some games (especially one)... the problem is quite noticeable. When you pan the view around, my eyes are drawn to the slight areas on my screen which are darker, and it ruins my enjoyment. To confirm it wasn't just the game, like I said, I can use a program to make the entire screen display one solid colour, and if you pick the right type of colour (anything that isn't a bright primary colour), I can see the problem - albeit fairly faintly.
    I am pretty positive that it is not my graphics card or any other component of my PC, by the way, because everything is brand new and working perfectly, and the graphics card specifically, I have upgraded and yet the problem remains - even on the new card. Also, the areas that are darker, are different on this screen than on the other screens I have used.
    So basically, I would like to register my disappointment at the lack of perfect uniformity on a screen which cost me £400 (over double what most 20 inch LCD screens cost), and I would like to know if anybody could possibly suggest a way to fix it?
    It is upsetting, becuase although this problem exists on other screens too, this is, as far as I know, the most expensive 20" LCD monitor available today, and uses the best technology available too.
    p.s. If anyone would like to use the program that lets you set your entire PC screen a specific colour, it is called "Dead Pixel Buddy", and it is a free piece of software, made by somebody to check for dead pixels. But I found it useful for other things too, including looking at how uniform the colour of the screen is. That's not to say I was specifically looking for this problem by the way... the problem cought my eye.
    Thanks in advance!
    Message was edited by: telelove

    I've been talking about this on another forum too, and I made some pictures in photoshop to describe the problem. Here is what I posted on the other forum:
    Yes, "brightness uniformity" definitely seems to be the best description of my issue.
    Basically it just seems like there are very faint lines down the screen, that are slightly darker than the other areas on the screen. They aren't defined lines, and they aren't in a pattern. It's just slight areas that are darker, and the areas seem like narrow bands/lines. Usually you can't see it, but in some cases, it is quite noticeable. It is mainly when I'm playing a game. The slightly darker areas are not visible, and then when the image moves (because I am turning in a car, or turning a plane, or turning in a shooter etc.) the image moves, but these slightly darker areas stay still, and that makes them really stand out.
    As for how it looks, I tried to make an example in photoshop:
    Original Image:
    http://img340.imageshack.us/img340/3045/td1ja9.jpg
    Then imagine turning the car around a bend, and then it looks like this:
    http://img266.imageshack.us/img266/959/td2hq7.jpg
    It's those lines in the clouds. If you can tab between the two images, you can see the difference easily. Imagine seeing those lines appear, every single time you move in a game. (I haven't tested this in movies yet, but I am assuming it's the same).
    It isn't very clear on a static image. But when the image moves, the darker areas stay in the same place and it draws your eyes towards them. It isn't terrible, but it is annoying, especially consider how much this screen cost.
    Message was edited by: telelove

  • Please I need some help with a table

    Hi All
    I need some help with a table.
    My table needs to hold prices that the user can update.
    Also has a total of the column.
    my question is if the user adds in a new price how can i pick up the value they have just entered and then add it to the total which will be the last row in the table?
    I have a loop that gets all the values of the column, so I can get the total but it is when the user adds in a new value that I need some help with.
    I have tried using but as I need to set the toal with something like total
        totalTable.setValueAt(total, totalTable.getRowCount()-1,1); I end up with an infinite loop.
    Can any one please advise on some way I can get this to work ?
    Thanks for reading
    Craig

    Hi there camickr
    thanks for the help the other day
    this is my full code....
    package printing;
    import java.awt.*;
    import java.awt.event.*;
    import java.awt.print.*;
    import javax.swing.*;
    import javax.swing.table.*;
    import java.text.DecimalFormat;
    public class tablePanel
        extends JDialog  implements Printable {
      BorderLayout borderLayout1 = new BorderLayout();
      private boolean printing = false;
      private Dialog1 dialog;
      JPanel jPanel = new JPanel();
      JTable table;
      JScrollPane scrollPane1 = new JScrollPane();
      DefaultTableModel model;
      private String[] columnNames = {
      private Object[][] data;
      private String selectTotal;
      private double total;
      public tablePanel(Dialog1 dp) {
        dp = dialog;
        try {
          jbInit();
        catch (Exception exception) {
          exception.printStackTrace();
      public tablePanel() {
        try {
          jbInit();
        catch (Exception exception) {
          exception.printStackTrace();
      private void jbInit() throws Exception {
        jPanel.setLayout(borderLayout1);
        scrollPane1.setBounds(new Rectangle(260, 168, 0, 0));
        this.add(jPanel);
        jPanel.add(scrollPane1, java.awt.BorderLayout.CENTER);
        scrollPane1.getViewport().add(table);
        jPanel.setOpaque(true);
        newTable();
        addToModel();
        addRows();
        setTotal();
    public static void main(String[] args) {
      tablePanel tablePanel = new  tablePanel();
      tablePanel.pack();
      tablePanel.setVisible(true);
    public void setTotal() {
      total = 0;
      int i = table.getRowCount();
      for (i = 0; i < table.getRowCount(); i++) {
        String name = (String) table.getValueAt(i, 1);
        if (!"".equals(name)) {
          if (i != table.getRowCount() - 1) {
            double dt = Double.parseDouble(name);
            total = total + dt;
      String str = Double.toString(total);
      table.setValueAt(str, table.getRowCount() - 1, 1);
      super.repaint();
      public void newTable() {
        model = new DefaultTableModel(data, columnNames) {
        table = new JTable() {
          public Component prepareRenderer(TableCellRenderer renderer,
                                           int row, int col) {
            Component c = super.prepareRenderer(renderer, row, col);
            if (printing) {
              c.setBackground(getBackground());
            else {
              if (row % 2 == 1 && !isCellSelected(row, col)) {
                c.setBackground(getBackground());
              else {
                c.setBackground(new Color(227, 239, 250));
              if (isCellSelected(row, col)) {
                c.setBackground(new Color(190, 220, 250));
            return c;
        table.addMouseListener(new MouseAdapter() {
          public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
            if (e.getClickCount() == 1) {
              if (table.getSelectedColumn() == 1) {
       table.setTableHeader(null);
        table.setModel(model);
        scrollPane1.getViewport().add(table);
        table.getColumnModel().getColumn(1).setCellRenderer(new TableRenderDollar());
      public void addToModel() {
        Object[] data = {
            "Price", "5800"};
        model.addRow(data);
      public void addRows() {
        int rows = 20;
        for (int i = 0; i < rows; i++) {
          Object[] data = {
          model.addRow(data);
      public void printOut() {
        PrinterJob pj = PrinterJob.getPrinterJob();
        pj.setPrintable(tablePanel.this);
        pj.printDialog();
        try {
          pj.print();
        catch (Exception PrintException) {}
      public int print(Graphics g, PageFormat pageFormat, int pageIndex) throws PrinterException {
        Graphics2D g2 = (Graphics2D) g;
        g2.setColor(Color.black);
        int fontHeight = g2.getFontMetrics().getHeight();
        int fontDesent = g2.getFontMetrics().getDescent();
        //leave room for page number
        double pageHeight = pageFormat.getImageableHeight() - fontHeight;
        double pageWidth =  pageFormat.getImageableWidth();
        double tableWidth = (double) table.getColumnModel().getTotalColumnWidth();
        double scale = 1;
        if (tableWidth >= pageWidth) {
          scale = pageWidth / tableWidth;
        double headerHeightOnPage = 16.0;
        //double headerHeightOnPage = table.getTableHeader().getHeight() * scale;
        //System.out.println("this is the hedder heigth   " + headerHeightOnPage);
        double tableWidthOnPage = tableWidth * scale;
        double oneRowHeight = (table.getRowHeight() +  table.getRowMargin()) * scale;
        int numRowsOnAPage = (int) ( (pageHeight - headerHeightOnPage) / oneRowHeight);
        double pageHeightForTable = oneRowHeight *numRowsOnAPage;
        int totalNumPages = (int) Math.ceil( ( (double) table.getRowCount()) / numRowsOnAPage);
        if (pageIndex >= totalNumPages) {
          return NO_SUCH_PAGE;
        g2.translate(pageFormat.getImageableX(), pageFormat.getImageableY());
    //bottom center
        g2.drawString("Page: " + (pageIndex + 1 + " of " + totalNumPages),  (int) pageWidth / 2 - 35, (int) (pageHeight + fontHeight - fontDesent));
        g2.translate(0f, headerHeightOnPage);
        g2.translate(0f, -pageIndex * pageHeightForTable);
        //If this piece of the table is smaller
        //than the size available,
        //clip to the appropriate bounds.
        if (pageIndex + 1 == totalNumPages) {
          int lastRowPrinted =
              numRowsOnAPage * pageIndex;
          int numRowsLeft =
              table.getRowCount()
              - lastRowPrinted;
          g2.setClip(0,
                     (int) (pageHeightForTable * pageIndex),
                     (int) Math.ceil(tableWidthOnPage),
                     (int) Math.ceil(oneRowHeight *
                                     numRowsLeft));
        //else clip to the entire area available.
        else {
          g2.setClip(0,
                     (int) (pageHeightForTable * pageIndex),
                     (int) Math.ceil(tableWidthOnPage),
                     (int) Math.ceil(pageHeightForTable));
        g2.scale(scale, scale);
        printing = true;
        try {
        table.paint(g2);
        finally {
          printing = false;
        //tableView.paint(g2);
        g2.scale(1 / scale, 1 / scale);
        g2.translate(0f, pageIndex * pageHeightForTable);
        g2.translate(0f, -headerHeightOnPage);
        g2.setClip(0, 0,
                   (int) Math.ceil(tableWidthOnPage),
                   (int) Math.ceil(headerHeightOnPage));
        g2.scale(scale, scale);
        //table.getTableHeader().paint(g2);
        //paint header at top
        return Printable.PAGE_EXISTS;
    class TableRenderDollar extends DefaultTableCellRenderer{
        public Component getTableCellRendererComponent(
          JTable table,
          Object value,
          boolean isSelected,
          boolean isFocused,
          int row, int column) {
            setHorizontalAlignment(SwingConstants.RIGHT);
          Component component = super.getTableCellRendererComponent(
            table,
            value,
            isSelected,
            isFocused,
            row,
            column);
            if( value == null || value .equals("")){
              ( (JLabel) component).setText("");
            }else{
              double number = 0.0;
              number = new Double(value.toString()).doubleValue();
              DecimalFormat df = new DecimalFormat(",##0.00");
              ( (JLabel) component).setText(df.format(number));
          return component;
    }

  • Need some help with a Macally enclosure and a spare internal drive

    Need some help with a Macally enclousure
    Posted: Oct 1, 2010 10:55 AM
    Reply Email
    Aloha:
    I have a Macally PHR-S100SUA enclousure that does not recognise,my WD 1001fals hard drive. It has worked just fine with other internal drives, but not this one?
    This is a spare internal drive that I am trying to make an external drive to store back ups for a lot of data. But so far I can not get it recognized by the computer. Maybe I need different drivers?
    Any suggestions?
    Dan Page

    Hi-
    Drivers aren't typically needed for external enclosures.
    Macally has none listed for that enclosure.
    The same is true for the WD drive, internal or external; no drivers.
    With the exception of high end PM multi drive enclosures, I can't think of any that use drivers.
    How is the external connected?
    Have you tried different cables, different ports?
    Bad/damaged cables are fairly common.
    Have you verified connections inside of the enclosure?

  • Need some help with putting a folder in users directory

    I'm not sure how to do this, but what I want to do is put this file in C:/My Documents, but I need to be able to verify that C://My Documents exists, if not put it in C:/Program Files.
    Can any one help me out?
    try {
                        String[] contactArray = parseDatFile(fc.getSelectedFile());
                        Document document = createXMLDocument(contactArray);
                        saveToXMLFile(
                        document,
                        new File(
                        "C:/Program Files/xxx/",// looks for directory for list
                        "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"));
                    } catch (Exception exc) {
                        File f = new File("C:/Program Files/xxx/");// setting directory for list if not there
                        boolean yes = true;
                        yes = f.mkdir();// creating directory
                        try {
                            String[] contactArray = parseDatFile(fc.getSelectedFile());
                            Document document = createXMLDocument(contactArray);
                            saveToXMLFile(
                            document,
                            new File(
                            "C:/Program Files/xxx/",// used only if the directory didn't exist
                            "xxxxxxxxxxxxxxxxxxxxxxx"));

    Need some help with putting a folder in users directoryI recomend using System.getProperty( "user.home" ) not a hard-coded value.
    This will use the users home folder ( C:\My Documents ) on Win9X (I guess), C:\Documents and Settings\<current user> on Win2K +, and ~ on Unix-a-likes.

  • Need some help with downloading PDF's from the net.

    need some help with downloading PDF's from the net.  Each time I try to click on a link from a website, if it takes me to a new screen to view a pdf, it just comes up as a blank black screen?  any suggestions?

    Back up all data.
    Triple-click the line of text below to select it, the copy the selected text to the Clipboard (command-C):
    /Library/Internet Plug-ins
    In the Finder, select
    Go ▹ Go to Folder
    from the menu bar, or press the key combination shift-command-G. Paste into the text box that opens (command-V), then press return.
    From the folder that opens, remove any items that have the letters “PDF” in the name. You may be prompted for your login password. Then quit and relaunch Safari, and test.
    The "Silverlight" web plugin distributed by Microsoft can also interfere with PDF display in Safari, so you may need to remove it as well, if it's present.
    If you still have the issue, repeat with this line:
    ~/Library/Internet Plug-ins
    If you don’t like the results of this procedure, restore the items from the backup you made before you started. Relaunch Safari again.

  • Powerpoint presentation I have stored in icloud until recently were syncing to Keynote on my iPad with no problem.  Now when I open Keynote on my iPad there is nothing.  I could use some help with this problem.

    powerpoint presentation I have stored in icloud until recently were syncing to Keynote on my iPad with no problem.  Now when I open Keynote on my iPad there is nothing.  I could use some help with this problem.

    Morning AndreD86,
    Thanks for using Apple Support Communities.
    These articles explain exactly what is backed up by using their method.
    iTunes: About iOS backups
    http://support.apple.com/kb/ht4946
    and
    iCloud: Backup and restore overview
    http://support.apple.com/kb/ht4859
    Also we want to double-click the Home button and swipe the Task Bar to the right.
    Then make sure the button on the far left of Task Bar is not muted.
    Best of luck,
    Mario

  • Need some help with the Select query.

    Need some help with the Select query.
    I had created a Z table with the following fields :
    ZADS :
    MANDT
    VKORG
    ABGRU.
    I had written a select query as below :
    select single vkorg abgru from ZADS into it_rej.
    IT_REJ is a Work area:
    DATA : BEGIN OF IT_REJ,
            VKORG TYPE VBAK-VKORG,
            ABGRU TYPE VBAP-ABGRU,
           END OF IT_REJ.
    This is causing performance issue. They are asking me to include the where condition for this select query.
    What should be my select query here?
    Please suggest....
    Any suggestion will be apprecaiated!
    Regards,
    Developer

    Hello Everybody!
    Thank you for all your response!
    I had changes this work area into Internal table and changed the select query. PLease let me know if this causes any performance issues?
    I had created a Z table with the following fields :
    ZADS :
    MANDT
    VKORG
    ABGRU.
    I had written a select query as below :
    I had removed the select single and insted of using the Structure it_rej, I had changed it into Internal table 
    select vkorg abgru from ZADS into it_rej.
    Earlier :
    IT_REJ is a Work area:
    DATA : BEGIN OF IT_REJ,
    VKORG TYPE VBAK-VKORG,
    ABGRU TYPE VBAP-ABGRU,
    END OF IT_REJ.
    Now :
    DATA : BEGIN OF IT_REJ occurs 0,
    VKORG TYPE VBAK-VKORG,
    ABGRU TYPE VBAP-ABGRU,
    END OF IT_REJ.
    I guess this will fix the issue correct?
    PLease suggest!
    Regards,
    Developer.

  • Why is it ok for a verizon wireless service representative to lie to a customer? I went over my monthly data and i called to ask for some help with the overage because i was barely over. They told me they would take care of it and sold me on a shared data

    why is it ok for a verizon wireless service representative to lie to a customer? I went over my monthly data and i called to ask for some help with the overage because i was barely over. They told me they would take care of it and sold me on a shared data plan that would result in 2gb less data but told me i would save 20$ a month. I agreed and recieved my next statement and to my suprise my bill actually went up 15$ a month and i talked to several people and they all told me there is nothing that can be done to get back on the plan i was on and they can not even give me a discount to get me back to what i was paying. They can only offer me a convenience credit. I will be cancelling service.

    ajwest101,
    We do not want to see you go. I truly apologize for any misinformation regarding your plan. Let's investigate into this a little further. What plan were you on? What plan were you switched to? If you look at the detailed billing online of your previous bill do you see any additional charges other then the plan?
    LindseyT_VZW
    Follow us on Twitter @VZWSupport

  • I recently updated my computer to 10.6 and now I can't get my printer MX340 (canon ) to work. I have installed the new drivers both from Canon's website and from an earlier post directly from apples website. I would surely appreciate some help with this.

    I recently updated my computer to 10.6 and now I can't get my printer MX340 (canon ) to work. I have installed the new drivers both from Canon's website and from an earlier post directly from apples website. I would surely appreciate some help with this.

    Try what Terence Devlin posted in this topic:
    Terence Devlin
    Apr 14, 2015 11:21 AM
    Re: Is Iphoto gone ? i want it back!
    in response to Johannes666
    Recommended
    Go to the App Store and check out the Purchases List. If iPhoto is there then it will be v9.6.1
    If it is there, then drag your existing iPhoto app (not the library, just the app) to the trash
    Install the App from the App Store.
    Sometimes iPhoto is not visible on the Purchases List. it may be hidden. See this article for details on how to unhide it.
    http://support.apple.com/kb/HT4928
    One question often asked: Will I lose my Photos if I reinstall?
    iPhoto the application and the iPhoto Library are two different parts of the iPhoto programme. So, reinstalling the app should not affect the Library. BUT you should always have a back up before doing this kind of work. Always.

Maybe you are looking for