Some help with a program

I have a program that basically simulates a parking meter.
It essentially contains a buffer - which holds the coins prior to processing
A hopper pack - Which contains a collection of 5 change hoppers
Ok - at the moment i have managed to get the system to add coins to the buffer - display the amount and lookup the relevant parking time.
What i am trying to do now is iterate through the buffer ArrayList coin by coin and check to see if the relevant change hopper needs filling up - i have got this to work for first element of the collection but then it doesn't seem to work for subsequent elements. I am not sure why.....
My class files are included below:
import java.util.*;
* Class to implement a facade controller for the ATM software
* (not complete)
* @author  Les Hazlewood
* @version 1.0 written on 23/11/05
public class ATM_System
    // Variables to represent Buffer, Hopper_Pack and Changes objects
    private static Buffer      buffer;
    private static Hopper_Pack hoppers;
    private static Charges     charges;
     * Constructor for objects of class ATM_System
    public ATM_System()
        // To create new Buffer, Hopper_Pack and Changes objects
        buffer  = new Buffer();
        hoppers = new Hopper_Pack();
        charges = new Charges();
        // To initialise the ATM Display and Change Light      
        Hardware.display("0.00");
        Hardware.setLightOff();
     * Method to perform the actions required for the use case :
     * "Insert a coin"
     * @param  coin   The coin inserted into the ATM
    public void insertCoin(Coin coin)
        System.out.println();
        // We need to verify the coin is of the right denomination / Legal coin
        if(coinDetector(coin))
             // We have a legal coin process
             // Add the coin to the buffer
             Hardware.sendDetectorToBuffer(); // Call method from hardware class to print to terminal
             buffer.add(coin);
        else
             // We have a fake/invalid/unrecognised coin - send to reject slot
             Hardware.sendDetectorToReject();
    public static void main(String args[])
         ATM_System atm = new ATM_System();
         Coin five = new Coin(5);
         Coin ten = new Coin(10);
         Coin twenty = new Coin(20);
         Coin pound = new Coin(100);
         atm.insertCoin(five);
        atm.insertCoin(five);
         atm.insertCoin(five);
         atm.pressPrintTicketButton();
         //atm.processBuffer(twenty);
         //System.out.println("Hopper Amount: " + hoppers.returnHopper(0).getHopperAmount());
     * Method to perform the actions required for the use case :
     * "Press the Return Coins Button"
    public void pressReturnCoinsButton()
          // We need to empty everything in the buffer
          buffer.emptyBuffer();
          // Send the coins to refund slot
          Hardware.sendBufferToRefund();
     * Method to perform the actions required for the use case :
     * "Press the Print Ticket Button"
    public void pressPrintTicketButton()
        System.out.println();
        System.out.println("Printing Ticket");
        // Get the relevant charge
        if(buffer.getBufferValue()>=10)
            ParkingPeriodFee thisCharge;
            thisCharge = (ParkingPeriodFee) charges.getCharge(buffer.getBufferValue());
            System.out.println("Minutes: " + thisCharge.getMinutes());
            System.out.println("Fee: " + thisCharge.getFee());
        else
            System.out.println("Not enough");
        // Process the buffer
        ArrayList bufferArray = (ArrayList)buffer.getBuffer();
        for(Iterator iter = bufferArray.iterator(); iter.hasNext();)
            Coin coin = (Coin)iter.next();
            processBuffer(coin);
    public void processBuffer(Coin coin)
         //ArrayList bufferArray = (ArrayList)buffer.getBuffer();
        //System.out.println("--------" + bufferArray.size());
        //int bufferSize = bufferArray.size();
         //for(Iterator iter = bufferArray.iterator(); iter.hasNext();)
            //Coin coin = (Coin)iter.next();
            if(coin.value() == 5)
                 // Process for 5p | Hopper Number 1     
                 if(hoppers.fillHopper(0,coin) == true)
                      // Then we filled the hopper - remove the coin from the buffer
                      buffer.remove(coin);
                 else
                      // Hopper was full so move the coin to the cash box
                      buffer.remove(coin);
                      Hardware.sendBufferToCashBox();
            else if(coin.value() == 10)
                 // Process for 10p Hopper | Hopper Number 2
            else if(coin.value() == 20)
                 // Process for 20p Hopper | Hopper Number 3
            else if(coin.value() == 50)
                 // Process for 50p Hopper | Hopper Number 4
            else if(coin.value() == 100)
                 // Process for �1 Hopper | Hopper Number 5
            else
                 // Something seriously wrong has occured.
                System.out.println("ERROR");
     * Method to perform the role of the coin detector
     *@param coin The coin to pass through the detector
     *@return boolean True if coin is valid false if coin reject
     public boolean coinDetector(Coin coin)
          boolean legal;
          if(coin.value() == 5 || coin.value() == 10 || coin.value() == 20 || coin.value() == 50 || coin.value() == 100)
               // We have a real coin
               legal = true;
          else
               // We have a reject coin
               legal = false;
          // Return our boolean value
          return legal;
     public void distributeCoins(Coin coin)
          // Method to either fill up the hoppers with change OR send to cashbox.
import java.util.*;
/* Hopper_Pack.java - Groups the hoppers into a unit
*@author The Hazelnuts
*@veriso 1.0
public class Hopper_Pack
     private ArrayList pack;
     //private static final int PACK_SIZE = 5; // Only 5 hoppers in each machine
     public Hopper_Pack()
          pack = new ArrayList();
          // Make 5p Hopper
          pack.add(new Hopper(5,1));
          // Make 10p Hopper
          pack.add(new Hopper(10,2));
          // Make 20p Hopper
          pack.add(new Hopper(20,3));
          // Make 50p Hopper
          pack.add(new Hopper(50,4));
          // Make �1 Hopper
          pack.add(new Hopper(100,5));
     public boolean fillHopper(int hopperNo, Coin coin)
          // Create a flag
          boolean flag;
          // We need to see if the required Hopper needs to be filled up
          Hopper workingHopper = (Hopper) pack.get(hopperNo);
          //System.out.println("Hopper 1 Size:" + workingHopper.getSize());
          if(workingHopper.getSize() < 10)
               // Then we will add the coin to the Hopper
               workingHopper.add(coin);
               flag = true; // We did fill the hopper
               System.out.println("Added to hopper: " + workingHopper.getHopperAmount());
          else
               flag = false; // We didn't need to fill the hopper
          return flag;
     public void processBuffer(Buffer buffer)
          // We need to process the buffer to see if the hopper should be filled or not
          ArrayList thisBuffer = buffer.getBuffer();
          for(Iterator iter = thisBuffer.iterator(); iter.hasNext(); )
            Coin coin = (Coin)iter.next();
            if(coin.value() == 5)
                 // Hopper Number for 5p     
            else if(coin.value() == 10)
                 // Process for 10p Hopper
            else if(coin.value() == 20)
                 // Process for 20p Hopper
            else if(coin.value() == 50)
                 // Process for 50p Hopper
            else if(coin.value() == 100)
                 // Process for �1 Hopper
            else
                 // Something seriously wrong has occured.
     public Hopper returnHopper(int hopperNo)
          return (Hopper) pack.get(hopperNo);
import java.util.*;
/* Hopper.java - Simulates a coin hopper
*@Author The Hazelnuts
*@version 1.0
public class Hopper
     private static final int HOPPER_SIZE = 10;
     private ArrayList hopper;
     private int hopperName; // The value of the coins it holds
     private int hopperNumber;
     private int hopperAmount;
     public Hopper(int hopperName, int hopperNumber)
          hopper = new ArrayList();
          this.hopperName = hopperName;
          this.hopperNumber = hopperNumber;
          this.hopperAmount = 0;
     public void add(Coin coin)
          // Add a coin to the hopper
          hopper.add(coin);
          hopperAmount = hopperAmount + coin.value();
     public int getHopperAmount()
          return hopperAmount;
     public int getSize()
          return hopper.size();
     public void remove(Coin coin)
          // Removes a coin from the hopper
          // Sends to refund slot
          hopper.remove(coin);
          hopperAmount = hopperAmount - coin.value();
import java.util.*;
import java.text.DecimalFormat;
* Buffer.java - Buffer Class
*@Author The Hazlenuts
*@Version 1.0
public class Buffer
     private static final int BUFFER_SIZE = 20;   // Maximum size of Array List
     private ArrayList buffer = new ArrayList(); // Holds coin objects
     private int bufferValue;
     public Buffer()
          bufferValue = 0;
     public void add(Coin coin)
          // Add a new coin to buffer
          // Check that the buffer isn't at its maximum size
          if(isEmpty() || buffer.size() < 20) // we are allowed 0-19
               // Then the buffer is ok to add another coin
               buffer.add(coin);
               bufferValue = bufferValue + coin.value();
               Hardware.display(valueString(bufferValue));
               //System.out.println(bufferValue);
               //System.out.println(coin.value());
               //System.out.println(valueString(bufferValue));
          else
               // THe buffer is already full - the coin gets sent to reject slot
               Hardware.sendDetectorToReject();
     public int getBufferValue()
          return bufferValue;
     public boolean isEmpty()
          // Is the ArrayList empty?
          boolean empty = false;
          if(buffer.isEmpty()){empty=true;}
          return empty;
     public void remove(Coin coin)
          // Remove a coin from the buffer
          buffer.remove(coin);
          bufferValue = bufferValue - coin.value();
          Hardware.display(valueString(bufferValue));               
          //System.out.println(bufferValue);
     public String valueString(int bufferAmount)
          double curr = ((double)bufferAmount / 100);
          DecimalFormat df = new DecimalFormat("0.00");
          String buffStr = df.format(curr);
          return buffStr;
     public void emptyBuffer()
          // Empty the buffer on call from System class
        for(Iterator iter = buffer.iterator(); iter.hasNext(); )
            Coin coin = (Coin)iter.next();
            buffer.remove(coin);
        // Set the Hardware Display to �0.00
        Hardware.display("0.00");     
     public ArrayList getBuffer()
          return buffer;
import java.util.*;
/* Charge.java - Holds
public class Charges
     ArrayList feeTable = new ArrayList();
     public Charges()
          // Create our fee table
          feeTable.add(new ParkingPeriodFee(10,15));   // 10p for 15 Minutes
          feeTable.add(new ParkingPeriodFee(20,30));   // 20p for 30 Minutes
          feeTable.add(new ParkingPeriodFee(30,45));   // 30p for 45 Minutes
          feeTable.add(new ParkingPeriodFee(40,60));   // 40p for 60 Minutes
          feeTable.add(new ParkingPeriodFee(80,120));  // 80p for 120 Minutes
          feeTable.add(new ParkingPeriodFee(120,180)); // �1.20 for 180 Minutes
          feeTable.add(new ParkingPeriodFee(160,240)); // �1.60 for 4 Hours
          feeTable.add(new ParkingPeriodFee(200,300)); // �2 for 5 Hours
          feeTable.add(new ParkingPeriodFee(240,360)); // �2.40 for 6 Hours
          feeTable.add(new ParkingPeriodFee(280,420)); // �2.80 for 7 Hours
          feeTable.add(new ParkingPeriodFee(320,480)); // �3.20 for 8 hours
          feeTable.add(new ParkingPeriodFee(360,540)); // �3.60 for 9 Hours
          feeTable.add(new ParkingPeriodFee(400,600)); // �4 for 10 hours
     public ParkingPeriodFee getCharge(int fee)
             // Return a ArrayList of the relevant charge
          //ArrayList thisFee = new ArrayList();
          ParkingPeriodFee highestFee = null;
          for(Iterator iter = feeTable.iterator(); iter.hasNext(); )
                    ParkingPeriodFee charge = (ParkingPeriodFee)iter.next();
                    // Check to see if the current cycle yields acceptable fee
                    if(charge.getFee() <= fee)
                        // We have a new highest fee
                        highestFee = charge;
          //thisFee.add(highestFee);
          return highestFee;
public class ParkingPeriodFee
     private int fee;     // The cost for the parking period
     private int minutes; // The time available for this fee
     public ParkingPeriodFee(int fee, int minutes)
          this.fee = fee;
          this.minutes = minutes;          
     public int getFee()
          // Return Fee
          return this.fee;
     public int getMinutes()
          // Return available minutes
          return this.minutes;
* CLass to simulate the behaviour of the ATM hardware for the purpose
* of testing the ATM Control System software
* @author  Les Hazlewood
* @version 1.0 written on 22/11/05
public class Hardware
     * Method to simulate the action of setting the value shown on the
     * Display by the ATM hardware
     * @param  amount   The value to be shown on the Display
    public static void display(String amount)
        System.out.println("Display shows : �" + amount);
     * Method to simulate the action of setting the Change Light to "OFF"
     * by the ATM hardware
    public static void setLightOff()
        System.out.println("Change Light is OFF");
     * Method to simulate the action of setting the Change Light to "ON"
     * by the ATM hardware
    public static void setLightOn()
        System.out.println("Change Light in ON");
     * Method to simulate the action of sending the coin in the Detector
     * to the coin Reject Slot by the ATM hardware
    public static void sendDetectorToReject()
        System.out.println("Detector coin sent to Reject Slot");
     * Method to simulate the action of sending the coin in the Detector
     * to the Buffer by the ATM hardware
    public static void sendDetectorToBuffer()
        System.out.println("Detector coin sent to Buffer");
     * Method to simulate the action of sending the bottom coin in the
     * Buffer to the coin Refund Slot by the ATM hardware
    public static void sendBufferToRefund()
        System.out.println("Buffer coin sent to Refund Slot");
     * Method to simulate the action of sending the bottom coin in the
     * Buffer to the Cash Box by the ATM hardware
    public static void sendBufferToCashBox()
        System.out.println("Buffer coin sent to Cash Box");
     * Method to simulate the action of sending the bottom coin in the
     * Buffer to a specified Hopper by the ATM hardware
     * @param  num   The number of the hopper
    public static void sendBufferToHopper(int num)
        System.out.println("Buffer coin sent to Hopper number " + num);
     * Method to simulate the action of sending the bottom coin from a
     * specified Hopper to the coin Refund Slot by the ATM hardware
     * @param  num   The number of the hopper
    public static void sendHopperToRefund(int num)
        System.out.println("Coin sent to Refund Slot from Hopper number " + num);
     * Method to simulate the actions of a ticket being printed by the
     * ATM hardware
     * @param  value        The fee paid for the ticket
     * @param  startTime    The clock time at the start of the parking,
     * @param  startDay        together with the corresponding date
     * @param  startMonth      (as day, month name and year) at the start
     * @param  startYear       of the parking period
     * @param  finishTime   The clock time at the end of the parking,
     * @param  finishDay       together with the corresponding date
     * @param  finishMonth     (as day, month name and year) at the end
     * @param  finishYear      of the parking period
    public static void printTicket(String value,
                                   String startTime, String finishTime,
                  String startDay, String startMonth, String startYear,
                  String finishDay, String finishMonth, String finishYear)
        System.out.println("---------------------------------------");
        System.out.println("Aston University Car Parks Ltd - Ticket");
        System.out.println("      Fee paid : �" + value);
        System.out.println("   Time and date      Time and date");
        System.out.println("   at start of        at end of");
        System.out.println("   parking period     parking period");
        System.out.print  ("   " + startTime + " " + startDay + " " +
                                   startMonth + " " + startYear);
        System.out.println("   " + finishTime + " " + finishDay + " " +
                                   finishMonth + " " + finishYear);
        System.out.println("---------------------------------------");
* Class to model a Coin.
* @author Les Hazlewood
* @version 1.0 written on 22/11/05
public class Coin
    // To hold the value of a coin
    private int coinValue;
     * Constructor for objects of class Coin
    public Coin(int value)
        // Valid coins are of 5, 10, 20, 50 and 100 pence denominations.
        // All other values are considered to correspond to an invalid
        // coin, and are represented with a coinValue of 0.
        if ( (value == 5) || (value == 10) || (value == 20) ||
             (value == 50) || (value == 100) )
              coinValue = value;
          else
              coinValue = 0;
     * Method to return the value of the coin
     * @return     The value of the coin
    public int value()
        return coinValue;
     * Method to return if this is a valid coin
     * @return     true if the coin is valid, and false otherwise
    public boolean isValid()
        return (coinValue != 0);
}

After some debugging it appears it is a problem with my loop not progressing...
Any ideas why?
    public void loopTest()
         ArrayList bufferArray = (ArrayList)buffer.getBuffer();
         System.out.println("---");
         System.out.println("Loop Test");
         int i=0;
         for(Iterator iter = bufferArray.iterator(); iter.hasNext();)
              //Print i
              Coin coin = (Coin)iter.next();
              System.out.println(i);
            if(coin.value() == 5)
                 // Process for 5p | Hopper Number 0     
                 if(hoppers.fillHopper(0,coin))
                      // Then we filled the hopper - remove the coin from the buffer
                      buffer.remove(coin);
                 else
                      // Hopper was full so move the coin to the cash box
                      buffer.remove(coin);
                      Hardware.sendBufferToCashBox();
                 //System.out.println(buffer.getBufferValue());
              i++;
    }

Similar Messages

  • Need some help with a program Please.

    Well, im new here, im new to java, so i need your help, i have to make a connect four program, my brother "Kind of" helped me and did a program for me, but the problem is i cant use some of those commands in the program and i have to replace them with what ive learned, so i will post the program and i will need your help to modify it for me.
    and for these programs, also i want help for:
    They have errors and i cant fix'em
    the commands that i've leaned:
    If statements, for loops, while loops,do while, strings, math classes, swithc statement, else if,logical operators,methods, one and two dimensional arrays.
    Thanx in advance,
    truegunner
    // Fhourstones 3.0 Board Logic
    // Copyright 2000-2004 John Tromp
    import java.io.*;
    class Connect4 {
    static long color[]; // black and white bitboard
    static final int WIDTH = 7;
    static final int HEIGHT = 6;
    // bitmask corresponds to board as follows in 7x6 case:
    // . . . . . . . TOP
    // 5 12 19 26 33 40 47
    // 4 11 18 25 32 39 46
    // 3 10 17 24 31 38 45
    // 2 9 16 23 30 37 44
    // 1 8 15 22 29 36 43
    // 0 7 14 21 28 35 42 BOTTOM
    static final int H1 = HEIGHT+1;
    static final int H2 = HEIGHT+2;
    static final int SIZE = HEIGHT*WIDTH;
    static final int SIZE1 = H1*WIDTH;
    static final long ALL1 = (1L<<SIZE1)-1L; // assumes SIZE1 < 63
    static final int COL1 = (1<<H1)-1;
    static final long BOTTOM = ALL1 / COL1; // has bits i*H1 set
    static final long TOP = BOTTOM << HEIGHT;
    int moves[],nplies;
    byte height[]; // holds bit index of lowest free square
    public Connect4()
    color = new long[2];
    height = new byte[WIDTH];
    moves = new int[SIZE];
    reset();
    void reset()
    nplies = 0;
    color[0] = color[1] = 0L;
    for (int i=0; i<WIDTH; i++)
    height[i] = (byte)(H1*i);
    public long positioncode()
    return 2*color[0] + color[1] + BOTTOM;
    // color[0] + color[1] + BOTTOM forms bitmap of heights
    // so that positioncode() is a complete board encoding
    public String toString()
    StringBuffer buf = new StringBuffer();
    for (int i=0; i<nplies; i++)
    buf.append(1+moves);
    buf.append("\n");
    for (int w=0; w<WIDTH; w++)
    buf.append(" "+(w+1));
    buf.append("\n");
    for (int h=HEIGHT-1; h>=0; h--) {
    for (int w=h; w<SIZE1; w+=H1) {
    long mask = 1L<<w;
    buf.append((color[0]&mask)!= 0 ? " @" :
    (color[1]&mask)!= 0 ? " 0" : " .");
    buf.append("\n");
    if (haswon(color[0]))
    buf.append("@ won\n");
    if (haswon(color[1]))
    buf.append("O won\n");
    return buf.toString();
    // return whether columns col has room
    final boolean isplayable(int col)
    return islegal(color[nplies&1] | (1L << height[col]));
    // return whether newboard lacks overflowing column
    final boolean islegal(long newboard)
    return (newboard & TOP) == 0;
    // return whether newboard is legal and includes a win
    final boolean islegalhaswon(long newboard)
    return islegal(newboard) && haswon(newboard);
    // return whether newboard includes a win
    final boolean haswon(long newboard)
    long y = newboard & (newboard>>HEIGHT);
    if ((y & (y >> 2*HEIGHT)) != 0) // check diagonal \
    return true;
    y = newboard & (newboard>>H1);
    if ((y & (y >> 2*H1)) != 0) // check horizontal -
    return true;
    y = newboard & (newboard>>H2); // check diagonal /
    if ((y & (y >> 2*H2)) != 0)
    return true;
    y = newboard & (newboard>>1); // check vertical |
    return (y & (y >> 2)) != 0;
    void backmove()
    int n;
    n = moves[--nplies];
    color[nplies&1] ^= 1L<<--height[n];
    void makemove(int n)
    color[nplies&1] ^= 1L<<height[n]++;
    moves[nplies++] = n;
    public static void main(String argv[])
    Connect4 c4;
    String line;
    int col=0, i, result;
    long nodes, msecs;
    c4 = new Connect4();
    c4.reset();
    BufferedReader dis = new BufferedReader(new InputStreamReader(System.in));
    for (;;) {
    System.out.println("position " + c4.positioncode() + " after moves " + c4 + "enter move(s):");
    try {
    line = dis.readLine();
    } catch (IOException e) {
    System.out.println(e);
    System.exit(0);
    return;
    if (line == null)
    break;
    for (i=0; i < line.length(); i++) {
    col = line.charAt(i) - '1';
    if (col >= 0 && col < WIDTH && c4.isplayable(col))
    c4.makemove(col);
    By the way im using Ready to program for the programming.

    You can't really believe that his brother did this
    for him...I did miss that copyright line at the beginning when
    I first looked it over, but you know, if it had been
    his brother, I'd be kinda impressed. This wasn't a
    25 line program. It actually would have required
    SOME thought. I doubt my brother woulda done that
    for me (notwithstanding the fact that I wouldn't need
    help for that program, and my brother isn't a
    programmer).I originally missed the comments at the top but when I saw the complexity of what was written then I knew that it was too advanced for a beginner and I relooked through the code and saw the comments.

  • Need some help with a program

    Can someone tell me what is correct way to reverse a number?
    This is my exact problem:
    I got a double (can't be changed) variable ie.) 0.85637. I am suppose to take the nearest 5 decimal places and reverse it like so: 73658. can somebody tell me what to do? I tried mutipling the number by 100000 and then use Math.mod and Math.round but when I round a number it doesn't fgive me what I want (ie. I want 3 from 3.869... but if I use Math.round it gives me 4). Please help.

    Try this :
    public class Reverse {
         public static void main(String[] args ){
              double      dVal = 0.85637;          
              String      sVal = Double.toString(dVal);
              int      nDotPos = sVal.indexOf('.');
              try {
                   if ( nDotPos != -1 ) {               
                        int nNum = (sVal.length()-nDotPos >= 5 )?nDotPos+6:sVal.length();                    
                        nDotPos++;
                        String sNewVal = sVal.substring(nDotPos, nNum);
                        System.out.println( sNewVal );
                        // Reversing the value
                        int      nReversedVal;
                        String      sReversedVal = "";
                        for ( int i = (sNewVal.length()-1); i >=0 ; i-- ) {
                             sReversedVal += sNewVal.charAt(i);
                        nReversedVal = Integer.parseInt(sReversedVal);
                        System.out.println( nReversedVal );
              } catch ( Exception ex ) {
                   ex.printStackTrace();
    }No Math methods in there.

  • 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

  • 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 help with basic program.....!

    I've to write a program that generates a random number, which the user has to try and guess, after each guess they're told whether it's too high or too low etc., I've gotten this far, however, the user has only 10 guesses.... In my program I've used a while loop and the user gets an infinite number of guesses, I know I'm supposed to use a for loop, but can't seem to get it to work properly. Also, when the user guesses the number, the program then has to print out how many guesses it took, and I have no idea how to get it to do this AT ALL!!! I'd really appreciate some help with this, thanks v. much!!!!

    I've to write a program that generates a random
    number, which the user has to try and guess, after
    each guess they're told whether it's too high or too
    low etc., I've gotten this far, however, the user has
    only 10 guesses.... In my program I've used a while
    loop and the user gets an infinite number of guesses,
    I know I'm supposed to use a for loop, but can't seem
    to get it to work properly. Also, when the user
    guesses the number, the program then has to print out
    how many guesses it took, and I have no idea how to
    get it to do this AT ALL!!! I'd really appreciate some
    help with this, thanks v. much!!!!Hey not every book covers every aspect of Java (if you haven't got a book and don't want to buy 1 i recommend an online tutorial) If u want the user to have an infinate number of guesses, use an infinate while loop. Put this in a file called app.java:
    import java.applet.Applet;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class app extends Applet implements ActionListener
         JLabel lbl=new JLabel("Guess a number between 0 and 10:");
         JTextField txtfield=new JTextField(20);
         JButton button=new JButton("Guess...");
         JLabel lbl2=new JLabel();
         int randomnumber=Math.round((float)Math.random()*10);
         public void init()
              add(lbl);
              add(txtfield);
              add(button);
              button.addActionListener(this);
         public void actionPerformed (ActionEvent e)
              String s=new String("");
              s+=randomnumber;
              if (e.getSource().equals(button) && txtfield.getText().equals(s))
                   setBackground(Color.white);
                   setForeground(Color.black);
                   lbl2.setText("Got it!");
                   add(lbl2);
                   validate();
              else
                   setBackground(Color.white);
                   setForeground(Color.black);
                   if (Integer.parseInt(txtfield.getText())>randomnumber)
                   lbl2.setText("Too High!");
                   else
                   lbl2.setText("Too Low!");
                   add(lbl2);
                   validate();
    Then create a HTML document in the classes folder:
    <HTML>
    <HEAD>
    <TITLE>APPLET</TITLE>
    </HEAD>
    <BODY>
    <HR>
    <CENTER>
    <APPLET
         CODE=app.class
         WIDTH=400
         HEIGHT=200 >
    </APPLET>
    </CENTER>
    <HR>
    </BODY>
    </HTML>
    It will do what you wish. If you want to have more then 10 numbers to guess, for example 100, do this:
    int randomnumber=Math.round((float)Math.random()*100);
    Does that answer your question?

  • Need some help with threads...

    Hello all,
    I am working on a project at work, and I am not the best programmer in the world. I have been trying to get my head around this for a couple of days and just cannot get it to work.
    I am writing an instrumentation control program that will have three threads. One is the GUI, one will receive control information and set up the hardware, and one will check the hardware status and report it to the GUI periodically. I plan on using the invokeLater() method to communicate the status to the GUI and change the status display in the GUI. Communication from the GUI to the controller thread and from the status thread to the controller thread I had planned on being piped input/output stream as appropriate. I have a control class and a status class that need to be communicated over these piped streams. In some trial code I have been unable to wrap the piped input/output streams with object input/output streams. I really need some help with this. Here is the main thread code:
    package playingwiththreads1;
    import java.io.*;*
    *public class PlayingWithThreads1 {*
    public static void main(String[] args) {*
    * PipedOutputStream outputPipe = new PipedOutputStream();*
    * ObjectOutputStream oos = null;*
    * ReceiverThread rt = new ReceiverThread(outputPipe);*
    // Start the thread -- First try*
    * Thread t = new Thread(rt);*
    t.start();*
    // Wrap the output pipe with an ObjectOutputStream*
    try*
    oos = new ObjectOutputStream(outputPipe);*
    catch (IOException e)*
    System.out.println(e);*
    // Start the thread -- Second try*
    //Thread t = new Thread(rt);*
    //t.start();*
    /** Send an object over the pipe. In reality this object will be a
    class that contains control or status information */
    try
    if (!oos.equals(null))
    oos.writeObject(new String ("Test"));
    catch (IOException e)
    try
    Thread.sleep(5000);
    catch (InterruptedException e)
    I read somewhere that it matters where you start the thread relative to where you wrap piped streams with the object streams. So, I tried the two places I felt were obvious to start the thread. These are noted in the comments. Here is the code for the thread.
    package playingwiththreads1;
    import java.io.*;
    public class ReceiverThread implements Runnable {
    private PipedInputStream inputPipe = new PipedInputStream();
    private ObjectInputStream inputObject;
    ReceiverThread (PipedOutputStream outputPipe)
    System.out.println("Thread initialization - start");
    try
    inputPipe.connect(outputPipe);
    inputObject = new ObjectInputStream(inputPipe);
    catch (IOException e)
    System.out.println(e);
    System.out.println("Thread initialization - complete");
    public void run()
    System.out.println("Thread started");
    try
    if (inputObject.available() > 0)
    System.out.println(inputObject.read());
    catch (IOException e)
    System.out.println(e);
    Through testing I have determined that no matter where I start the thread, the thread never gets past the "inputObject = new ObjectInputStream(inputPipe);" assignment.
    Could someone please help me with this? There are other ways for me to write this program, but this is the one that I would like to make work.
    Many thanks in advance,
    Rob Hix
    Edited by: RobertHix on Oct 6, 2009 3:54 AM

    Thanks for the help, but that did not work. I tried flushing the ObjectOutputStream and it is still hanging when initializing the thread.
    Here is a better look at the code since I was helped to figure out how to insert it:
    The main method:
    package playingwiththreads1;
    import java.io.*;
    public class PlayingWithThreads1 {
        public static void main(String[] args) {
            PipedOutputStream outputPipe = new PipedOutputStream();
            ObjectOutputStream oos = null;
            ReceiverThread rt = new ReceiverThread(outputPipe);
            // Start the thread -- First try
            //Thread t = new Thread(rt);
            //t.start();
            // Wrap the output pipe with an ObjectOutputStream
            try
                oos = new ObjectOutputStream(outputPipe);
                oos.flush();
            catch (IOException e)
                System.out.println(e);
            // Start the thread -- Second try
            Thread t = new Thread(rt);
            t.start();
            /* Send an object over the pipe.  In reality this object will be a
             * class that contains control or status information */
            try
                if (!oos.equals(null))
                    oos.writeObject(new String ("Test"));
                    oos.flush();
            catch (IOException e)
                System.out.pringln(e);
            try
                Thread.sleep(5000);
            catch (InterruptedException e)
    }The thread code:
    package playingwiththreads1;
    import java.io.*;
    public class ReceiverThread implements Runnable {
        private PipedInputStream inputPipe = new PipedInputStream();
        private ObjectInputStream inputObject;
        ReceiverThread (PipedOutputStream outputPipe)
            System.out.println("Thread initialization - start");
            try
                inputPipe.connect(outputPipe);
                inputObject = new ObjectInputStream(inputPipe);
            catch (IOException e)
                System.out.println(e);
            System.out.println("Thread initialization - complete");
        public void run()
            System.out.println("Thread started");
            try
                if (inputObject.available() > 0)
                    System.out.println(inputObject.read());
            catch (IOException e)
                System.out.println(e);
    }Does anyone else have and ideas?

  • Need some help with guitar setup...

    jeez, never thought i'd be asking a question like this after playing for like 20 years, but i need some help with a guitar setup for mac. i'm gonna list out a lot of crap here that prolly doesn't affect anything at all, but here goes.
    Imac 17inch G4 - latest updated OS X... 10.4, or 5, or whatever. garageband 3.0
    digitech gnx-3
    alesis sr-16
    sure mic's
    yamaha e203 keyboard
    here's the setup:
    yamaha is on its own on a usb uno midi interface, sure's connected to gnx's xlr port, alesis connected to gnx's jam-a-long input, '87 kramer vanguard connected to gnx's guitar input. currently running headphones out on gnx to line in on mac.
    here's the problem:
    everything works beautifully, but my guitar sounds like crap. if i plug headphones into the gnx, it sounds beautiful. that makes me think its some kind of level issue between the gnx's output, and the mac's input, but nothing seems to fix it.
    by sounding like crap, i mean way too much bass. sound is muddy, blurry, not crisp... aka crap. i've tried altering both output and input on mac and gnx, and i cant get a combination that works. the gnx has a s/pdif out, can the mac accept that as input? might that help? short of running the gnx to my marshal half stack and mic'ing that, anyone have any suggestions, or use a similar setup?
    any help would be greatly appreciated!

    anyone? ... any suggestions? I think it might be an issue with the gnx pre-amping the signal as it goes out, and then the mac amping it on the way in, giving me a buttload more signal than i need, but since i cant find a happy level, i'm not really sure. i really dont want to resort to mic'ing my marshall... even with the volume almost off, my jcm900 is WAY too loud for apartment use. its not like i really NEED the guitar to sound perfect, i only use garageband to sketch out ideas for songs between myself and bandmates, but its really annoying to not have my customary crisp distortion. my bass player keeps telling me to use the built in amps, but, not to dis a practically free program, but the built in amps blow, at least after 10 years of marshall tube amplification they do. if anyone has any suggestions that might be helpfull on how i might resolve this, i would be your best friend for life and go to all your birthday parties

  • 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.

  • I Need Some Help With My Dreamweaver

    Hello, there i need some help with my dreamweaver i already made a forum about this but that one i maded didnt make sense soo i will make it more details in it soo i will tell you what i did i tell you what i downloed and all that just now but i tell you the things what it does i downloaded Adobe Design and Web Premium CS6 its a 30 day trial then and now i will tell you the details look below please
    Details
    Soo i opened my start menu then went on all programs then clicked on Adobe Design and Web Premium CS6 then i clicked on the dreamweaver CS6 then when i clicked on it i heard my computer shut down then it shuted down when i opened it straight away then it turns it self back on
    What did i do about this when it happened?
    I made a question so please can telll me what to do or what ever
    Why did i download it?
    i downloaded it because i am making a website and i want to use dreamweaver CS6 because i use notepad++ i do not like the notepad++ its harder and dreamweaver helps a bit i think because i watched a video of it
    What if you dont have an answer?
    Well, i will be very angry because i am making a good website its gonna be my frist publish website ever i made 20 websites but i never published them i deleted them because i wiped my computer
    What kind of Computer Do You have?
    System:
    Micfosoft windows xp
    Media Center Edition
    Version 2002
    Service Pack 2
    Computer
    ei-system
            intel(R)
    pentium(R) 4 CPU 3.20ghz
    3.20 ghz, 960 MB of RAM
    Btw i am using dreamweaver CS6 if you fogot and dont say add more details because there is alot off details there and if you help me i will show u the whloe code when i am done but leave ur emaill address below
    (C) Connor McIntosh

    No.
    Service Pack 3 just updates your OS. All of your files, folders and programs will still be there.
    You will start running into more problems like this the longer you stick with XP though. That particular OS is over 11 years old, service pack 3 hs been out for over 4 years.
    It may be time for a system upgrade. I personally went from XP to Windows 7 and I haven't looked back one bit.

  • 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!

  • 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?

  • Help with Paint program.

    Hello. I am somewhat new to Java and I was recently assigned to do a simple paint program. I have had no trouble up until my class started getting into the graphical functions of Java. I need help with my program. I am supposed to start off with a program that draws lines and changes a minimum of 5 colors. I have the line function done but my color change boxes do not work and I am able to draw inside the box that is supposed to be reserved for color buttons. Here is my code so far:
    // Lab13110.java
    // The Lab13 program assignment is open ended.
    // There is no provided student version for starting, nor are there
    // any files with solutions for the different point versions.
    // Check the Lab assignment document for additional details.
    import java.applet.Applet;
    import java.awt.*;
    public class Lab13110 extends Applet
         int[] startX,startY,endX,endY;
         int currentStartX,currentStartY,currentEndX,currentEndY;
         int lineCount;
         Rectangle red, green, blue, yellow, black;
         int numColor;
         Image virtualMem;
         Graphics gBuffer;
         int rectheight,rectwidth;
         public void init()
              startX = new int[100];
              startY = new int[100];
              endX = new int[100];
              endY = new int[100];
              lineCount = 0;
              red = new Rectangle(50,100,25,25);
              green = new Rectangle(50,125,25,25);
              blue = new Rectangle(50,150,25,25);
              yellow = new Rectangle(25,112,25,25);
              black = new Rectangle(25,137,25,25);
              numColor = 0;
              virtualMem = createImage(100,600);
              gBuffer = virtualMem.getGraphics();
              gBuffer.drawRect(0,0,100,600);
         public void paint(Graphics g)
              for (int k = 0; k < lineCount; k++)
                   g.drawLine(startX[k],startY[k],endX[k],endY[k]);
              g.drawLine(currentStartX,currentStartY,currentEndX,currentEndY);
              g.setColor(Color.red);
              g.fillRect(50,100,25,25);
              g.setColor(Color.green);
              g.fillRect(50,125,25,25);
              g.setColor(Color.blue);
              g.fillRect(50,150,25,25);
              g.setColor(Color.yellow);
              g.fillRect(25,112,25,25);
              g.setColor(Color.black);
              g.fillRect(25,137,25,25);
              switch (numColor)
                   case 1:
                        g.setColor(Color.red);
                        break;
                   case 2:
                        g.setColor(Color.green);
                        break;
                   case 3:
                        g.setColor(Color.blue);
                        break;
                   case 4:
                        g.setColor(Color.yellow);
                        break;
                   case 5:
                        g.setColor(Color.black);
                        break;
                   case 6:
                        g.setColor(Color.black);
                        break;
              g.setColor(Color.black);
              g.drawRect(0,0,100,575);
         public boolean mouseDown(Event e, int x, int y)
              currentStartX = x;
              currentStartY = y;
              if(red.inside(x,y))
                   numColor = 1;
              else if(green.inside(x,y))
                   numColor = 2;
              else if(blue.inside(x,y))
                   numColor = 3;
              else if(yellow.inside(x,y))
                   numColor = 4;
              else if(black.inside(x,y))
                   numColor = 5;
              else
                   numColor = 6;
              repaint();
              return true;
         public boolean mouseDrag(Event e, int x, int y)
              int Rectheight = 500;
              int Rectwidth = 900;
              currentEndX = x;
              currentEndY = y;
              Rectangle window = new Rectangle(0,0,900,500);
              //if (window.inside(Rectheight,Rectwidth))
                   repaint();
              return true;
         public boolean mouseUp(Event e, int x, int y)
              int Rectheight = 500;
              int Rectwidth = 900;
              startX[lineCount] = currentStartX;
              startY[lineCount] = currentStartY;
              endX[lineCount] = x;
              endY[lineCount] = y;
              lineCount++;
              Rectangle window = new Rectangle(0,0,900,500);
              if (window.inside(Rectheight,Rectwidth))
                   repaint();
              return true;
         public void Rectangle(Graphics g, int x, int y)
              g.setColor(Color.white);
              Rectangle screen = new Rectangle(100,0,900,600);
    }If anyone could point me in the right direction of how to go about getting my buttons to work and fixing the button box, I would be greatly appreciative. I just need to get a little bit of advice and I think I should be good after I get this going.
    Thanks.

    This isn't in any way a complete solution, but I'm posting code for a mouse drag outliner. This may be preferable to how you are doing rectangles right now
    you are welcome to use and modify this code but please do not change the package and make sure that you tell your teacher where you got it from
    MouseDragOutliner.java
    package tjacobs.ui;
    import java.awt.BasicStroke;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Container;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.Point;
    import java.awt.Stroke;
    import java.awt.event.*;
    import java.util.ArrayList;
    import java.util.Iterator;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.SwingUtilities;
    * See the public static method addAMouseDragOutliner
    public class MouseDragOutliner extends MouseAdapter implements MouseMotionListener {
         public static final BasicStroke DASH_STROKE = new BasicStroke(1.0f, BasicStroke.CAP_SQUARE, BasicStroke.JOIN_BEVEL, 10.0f, new float[] {8, 8}, 0);
         private boolean mUseMove = false;
         private Point mStart;
         private Point mEnd;
         private Component mComponent;
         private MyRunnable mRunner= new MyRunnable();
         private ArrayList mListeners = new ArrayList(1);
         public MouseDragOutliner() {
              super();
         public MouseDragOutliner(boolean useMove) {
              this();
              mUseMove = useMove;
         public void mouseDragged(MouseEvent me) {
              doMouseDragged(me);
         public void mousePressed(MouseEvent me) {
              mStart = me.getPoint();
         public void mouseEntered(MouseEvent me) {
              mStart = me.getPoint();
         public void mouseReleased(MouseEvent me) {
              Iterator i = mListeners.iterator();
              Point end = me.getPoint();
              while (i.hasNext()) {
                   ((OutlineListener)i.next()).mouseDragEnded(mStart, end);
              //mStart = null;
         public void mouseMoved(MouseEvent me) {
              if (mUseMove) {
                   doMouseDragged(me);
         public     void addOutlineListener(OutlineListener ol) {
              mListeners.add(ol);
         public void removeOutlineListener(OutlineListener ol) {
              mListeners.remove(ol);
         private class MyRunnable implements Runnable {
              public void run() {
                   Graphics g = mComponent.getGraphics();
                   if (g == null) {
                        return;
                   Graphics2D g2 = (Graphics2D) g;
                   Stroke s = g2.getStroke();
                   g2.setStroke(DASH_STROKE);
                   int x = Math.min(mStart.x, mEnd.x);
                   int y = Math.min(mStart.y, mEnd.y);
                   int w = Math.abs(mEnd.x - mStart.x);
                   int h = Math.abs(mEnd.y - mStart.y);
                   g2.setXORMode(Color.WHITE);
                   g2.drawRect(x, y, w, h);
                   g2.setStroke(s);
         public void doMouseDragged(MouseEvent me) {
              mEnd = me.getPoint();
              if (mStart != null) {
                   mComponent = me.getComponent();
                   mComponent.repaint();
                   SwingUtilities.invokeLater(mRunner);
         public static MouseDragOutliner addAMouseDragOutliner(Component c) {
              MouseDragOutliner mdo = new MouseDragOutliner();
              c.addMouseListener(mdo);
              c.addMouseMotionListener(mdo);
              return mdo;
         public static interface OutlineListener {
              public void mouseDragEnded(Point start, Point finish);
         public static void main(String[] args) {
              JFrame f = new JFrame("MouseDragOutliner Test");
              Container c = f.getContentPane();
              JPanel p = new JPanel();
              //p.setBackground(Color.BLACK);
              c.add(p);
              addAMouseDragOutliner(p);
              f.setBounds(200, 200, 400, 400);
              f.addWindowListener(new WindowClosingActions.Exit());
              f.setVisible(true);
    }

Maybe you are looking for

  • MS Visual Studio 2005 + Oracle 10g = Cannot connect to ODBC error: 12154

    Hi there! I've read so many threads of same kind of problems but always some key elements seems to be missing so I cannot solve my problem with the solutions in those threads. So, I'll do my own. Our environment is... We have Oracle 8 database with a

  • OS X Mountain Lion Deleted

    Hi, I just sent my 21' iMac to service as it required a hard drive change as the other one got damaged. The IT guys that help me in an authorized MacStore here in my hometown just replace the hard drive and did some back up only for my information. T

  • Not Reading 400 or dual channel

    I have been one of the lucky/unlucky ones to successfully flash to 1.4...however...still does not seem to be reading 400. Have manually adjusted settings to 2-2-2-5-8 and 2.7V and still no 400 (only 333)...With 1.2 would read 333 Dual Memory Channel

  • Subtitle forced

    Hello boys, I need your help with the subtitle forced in blu-ray authoring. The case is simple I need forced subtitle, but this subtitle shouldn´t delete, even with the button of control remote, don´t should desappear this subtitle of any form. Becau

  • IE shows code from dreamweaver CS3 after uploading

    Hi guys Need help. I have coded a site in Dreamweaver CS3 and after I upload through the automatic upload everything goes perfectly fine until I view the site online through Internet Explorer. Through all other browsers the website comes through fine