Need help in Account class

Hello
I am new to Java and am taking my first course on it. This question deals with the Account class. I have to create an Account.java program that applies the deposit method to a balance. A second testAccount.java program tests the first. It's not working and I was wondering if anyone had some ideas for me. Here is a sample of my code:
testAccount.java
// enter deposit
     String depositString = JOptionPane.showInputDialog (null, "Enter Deposit", "TME 2 - 6.3", JOptionPane.QUESTION_MESSAGE);
     double deposit = Double.parseDouble(depositString);
//create the account object
     Account account = new Account (id, balance, annualInterestRate, deposit);
Account.java
// reurn the balance
     public double getBalance() {
          return balance;
     // set a new balance
     public void setBalance(double balance) {
          this.balance = balance;
     // return the deposit
     public double getDeposit() {
          return deposit;
     // Deposit
     public void deposit (double deposit){
          this.balance += deposit;
public class Account {
     private int id;
     private double balance;
     private double annualInterestRate;
     private double deposit;
     // constructor
     public Account () {
          this (1122, 20000, 4.5, 0);
     // construct an account with specified id, balance, annual interest rate
     public Account(int id, double balance, double annualInterestRate, double deposit) {
          this.id = id;
          this.balance = balance;
          this.annualInterestRate = annualInterestRate;
          this.deposit = deposit;
Thanks very much
Craig

Ok, sorry for the disjointed question. This my first time seeking help on the forum. Below are my two programs. The testAccount.jave runs but returns a balance that has not been modified by the deposit / withdraw. It is how to use the deposit/withdraw methods that is throwing me for a loop.
TestAccount.java
import javax.swing.JOptionPane;
public class TestAccount {
     public static void main (String [] args) {
     // enter id
     String idString = JOptionPane.showInputDialog (null, "Enter Account ID", "TME 2 - 6.3", JOptionPane.QUESTION_MESSAGE);
     int id = Integer.parseInt(idString);
     // enter balance
     String balanceString = JOptionPane.showInputDialog (null, "Enter Account Balance", "TME 2 - 6.3", JOptionPane.QUESTION_MESSAGE);
     double balance = Double.parseDouble(balanceString);
     // enter annual interest rate
     String annualInterestRateString = JOptionPane.showInputDialog (null, "Enter Account Annual Interest Rate", "TME 2 - 6.3", JOptionPane.QUESTION_MESSAGE);
     double annualInterestRate = Double.parseDouble(annualInterestRateString);
     // enter deposit
     String depositString = JOptionPane.showInputDialog (null, "Enter Deposit", "TME 2 - 6.3", JOptionPane.QUESTION_MESSAGE);
     double deposit = Double.parseDouble(depositString);
     // enter withdraw
     String withdrawString = JOptionPane.showInputDialog (null, "Enter Withdraw", "TME 2 - 6.3", JOptionPane.QUESTION_MESSAGE);
     double withdraw = Double.parseDouble(withdrawString);
     //create the account object
     Account account = new Account (id, balance, annualInterestRate);
     //print results
     String output = "The Balance is " + account.getBalance() + "\nThe monthly interest is " + account.monthlyInterest();
     JOptionPane.showMessageDialog (null, output, "TME 2 - 6.3", JOptionPane.INFORMATION_MESSAGE);
     System.exit(0);
And here is the Account.java program
public class Account {
     private int id;
     private double balance;
     private double annualInterestRate
     // constructor
     public Account () {
          this (1122, 20000, 4.5);
     // construct an account with specified id, balance, annual interest rate
     public Account(int id, double balance, double annualInterestRate, double deposit) {
          this.id = id;
          this.balance = balance;
          this.annualInterestRate = annualInterestRate;
     // return the id
     public int getID() {
          return id;
     // set a new id
     public void setID(int id) {
          this.id = id;
     // reurn the balance
     public double getBalance() {
          return balance;
     // set a new balance
     public void setBalance(double balance) {
          this.balance = balance;
     // Deposit
     public void deposit (double deposit){
          balance += deposit;
     // Withdraw
     public void withdraw ( double withdraw) {
          this.balance -= withdraw;
     // return the annual interest rate
     public double getAnnualInterestRate() {
          return annualInterestRate;
     // set a new annual interest rate
     public void setAnnualInterestRate(double annualInterestrate) {
          this.annualInterestRate = annualInterestRate;
     // convert annual interest rate into monthly
     public double monthlyInterest() {
          double monthlyInterest = annualInterestRate / 1200 * balance;
          return monthlyInterest;
Thanks very much in advance
Craig

Similar Messages

  • Need help in Creating classes for my assignment

    Hi ,
    I just started learning Java and have the following requirement
    1)     Create the following classes/interfaces using descriptions:
    a)     Account � data members : id:String, type:String, balance:BigDecimal, methods : Account, Account with String parameter, getId, getType, getBalance, setId, setType, setBalance, deposit, withdraw, compareTo, toString
    b)     Bank � data members: instance:Bank, accountsMap:Map, customersMap:Map, customersAccount:Map, transactionMap:Map, methods: getAccountsMap, getCustormersMap, getCustomersAccounts, getTransactionMap, associate, addTransaction, getAccount, getCustomer, getAccounts, getTransactions, deposit, withdraw, transfer
    c)     AccountDoesNotExistException, BankException, CustomerDoesNotExistException, InsufficientFundsException, InvalidAmountException, ZeroAmountException
    2)     Create the util package using the following class
    a)     AmountConverter � methods: fromDecimal(BigDecim     al), fromString(String)
    In 1 b how to Create Instance:bank in the class .Also how to do part2.If possible can you help me with all the parts.Based on these I've some more to do.

    Here is what I've come with
    ACCOUNT.JAVA
    import java.math.*;
    public class Account {
    private String Id;
    private String Type;
    private BigDecimal balance;
    public Account( ) {
    public Account(String Id,String Type,BigInteger balance) {
    this.Id = Id;
    this.Type = Type;
    this.balance = balance;
    public String getId( ) {
    return Id;
    public void setId(String Id) {
    this.Id = Id;
    public String getType( ) {
    return Type;
    public void setType(String Title) {
    this.Title = Type;
    public String getBalance( ) {
    return id;
    public void setBalance(String balance) {
    this.balance = balance;
    public String withdraw( ) {
    public String deposit( ) {
    public void setLastName(String LastName) {
    this.id = id;
    CUSTOMER.JAVA
    public class Customer {
    private String Id;
    private String Title;
    private String firstName;
    private String lastName;
    /** Construct a Customer with no data -- must be a no-argument */
    public Customer( ) {
    /** Construct a Customer with String Parameter */
    public Customer(String Id,String Title,String firstName,String lastName) {
    this.Id = Id;
    this.Title = Title;
    this.firstName = firstName;
    this.lastName = lastName;
    /** Return the Id. */
    public String getId( ) {
    return Id;
    /** Set the Id */
    public void setId(String Id) {
    this.Id = Id;
    /** Return the Title */
    public String getTitle( ) {
    return Title;
    /** Set the Title */
    public void setTitle(String Title) {
    this.Title = Title;
    /** Return the Firstname. */
    public String getFirstName( ) {
    return id;
    /** Set the Firstname. */
    public void setFirstName(String FirstName) {
    this.id = id;
    /** Return the Lastname. */
    public String getLastName( ) {
    return LastName;
    /** Set the Lastname. */
    public void setLastName(String LastName) {
    this.id = id;
    TRANSRECORD.JAVA
    import java.util.*;
    import java.math.*;
    public class TransRecord implements Comparable{
    private Date timeStamp;
    private String transType;
    private BigDecimal transAmt;
    /** Construct a Trans Record with no data -- must be a no-argument */
    public TransRecord( ) {
    /** Construct a Customer with String Parameter */
    public Customer(String transType,String transAmt) {
    this.transType = transType;
    this.transAmt = transAmt;
    /** Return the timeStamp. */
    public String gettimeStamp( ) {
    return timeStamp;
    /** Set the timeStamp */
    public void settimeStamp(Date timeStamp) {
    this.timeStamp = timeStamp;
    /** Return the TransType */
    public String getTransType( ) {
    return TransType;
    /** Set the TransType */
    public void setTransType(String TransType) {
    this.TransType = TransType;
    /** Return the TransAmt */
    public String getTransAmt( ) {
    return TransAmt;
    /** Set the TransAmt */
    public void setTransAmt(String TransAmt) {
    this.TransAmt = TransAmt;
    /** Return a String representation. */
    public String toString( ) {
    /** CompareTo method */
    public int compareTo(Object argument)
    ===============
    ACCOUNTDOESNOTEXISTEXCEPTION.JAVA
    public class AccountDoesNotExistException
                   extends Exception
         public AccountDoesNotExistException()
              super();
         public AccountDoesNotExistException(String message)
              super(message);
    =================
    BANKEXCEPTION.JAVA
    public class BankException
                   extends Exception
         public BankException()
              super();
         public BankException(String message)
              super(message);
    CUSTOMERDOESNOTEXISTEXCEPTION.JAVA
    public class CustomerDoesNotExistException
                   extends Exception
         public CustomerDoesNotExistException()
              super();
         public CustomerDoesNotExistException(String message)
              super(message);
    ACCOUNTDOESNOTEXISTEXCEPTION.JAVA
    public class AccountDoesNotExistException
                   extends Exception
         public AccountDoesNotExistException()
              super();
         public AccountDoesNotExistException(String message)
              super(message);
    INSUFFICIENTFUNDSEXCEPTION.JAVA
    public class InsufficientFundsException
                   extends Exception
         public InsufficientFundsException()
              super();
         public InsufficientFundsException(String message)
              super(message);
    INVALIDAMOUNTEXCEPTION.JAVA
    public class InvalidAmountException
                   extends Exception
         public InvalidAmountException()
              super();
         public InvalidAmountException(String message)
              super(message);
    ZEROAMOUNTEXCEPTION.JAVA
    public class ZeroAmountException
                   extends Exception
         public ZeroAmountException()
              super();
         public ZeroAmountException(String message)
              super(message);
    I need help with Bank Class and the util class.Correct me If I've missed any exceptions or if any syntax is wrong
    THanks
    AKsh

  • Need Help with new Classes / methods

    Hi, I need to create a class called Proposition. It include a Proposition object with 3 variables
    Name, Description, Value
    This is the constructor I wrote:
    private String name;
    private String description;
    private boolean value;
    public Proposition(){
              name = "name";
              description = "description";
              value = false;
    }Now I need a method that give values to the 3 variables in the proposition object:
         public Proposition setProp(String line){
              StringTokenizer ST1 = new StringTokenizer(line, ".");
              String ValidLine = ST1.nextToken()+".";
              StringTokenizer ST2 = new StringTokenizer(ValidLine, "=");
              name = CutSpace(ST2.nextToken());
              description = (ST2.nextToken()).trim();
              value = false;
              return name;
              return description;
              return value;
         }An example of String line is: v = we are in Vancouver.
    When I run the program, I got error message with the 3 return statements saying found String/Boolean while Proposition is needed. I'm not quite sure how to write the return statements. Can any1 help?
    Thx!

    Your setProp() method should not be returning anything. After all it is setting not getting. So just declare it as
    public void setProp(String line){and remove the return statements.

  • Need help with a Class.

    Ok hey guys i got A project for school and i need help. I asked my teacher and he num so yea. here it is
    this is my blog class
    /* Project Name: .java
                 Name:
                Class: Programing 2 #0047-02 Pds 5&6
      Variable List:
                   Info:
    import java.util.Scanner;
    import java.util.Date;
    import java.text.DateFormat;
    import java.text.SimpleDateFormat;
    public class blog
         String date2;
         String user;
         String Entry;
         public void GetInfo(String Iuser,String IEntry)
              DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
              Date date = new Date();
              date2 = dateFormat.format(date);
              user = Iuser;
              Entry = IEntry:
         public void ShowInfo()
              System.out.println(date2 + " " + user + " Said: " + Entry);
    }This is my test class
    /* Project Name: .java
                 Name: Josh
                Class: Programing 2 #0047-02 Pds 5&6
      Variable List:
                   Info:
    import java.util.Scanner;
    public class test
         String user;
         String Entry;
         public static void main (String[] args)
         {     System.out.println("Welcome Please Eneter UserName");
              Scanner kb = new Scanner(System.in);
              user = kb.next();
              System.out.println("Please Enter Your Entry");
              Entry = kb.next();
              blog info = new blog();
              blog.GetInfo(user,Entry);
              blog.ShowInfo();
    }So what is sopost to do in the test it ask user to import user name and entery. It send it to blog Class, then it send it out. Here is my errors
    G:\VOC T2\Java\Chap4\test.java:21: non-static variable user cannot be referenced from a static context
              user = kb.next();
              ^
    G:\VOC T2\Java\Chap4\test.java:25: non-static variable Entry cannot be referenced from a static context
              Entry = kb.next();
              ^
    G:\VOC T2\Java\Chap4\test.java:29: non-static variable user cannot be referenced from a static context
              blog.GetInfo(user,Entry);
                           ^
    G:\VOC T2\Java\Chap4\test.java:29: non-static variable Entry cannot be referenced from a static context
              blog.GetInfo(user,Entry);
                                ^
    G:\VOC T2\Java\Chap4\test.java:29: GetInfo(java.lang.String,java.lang.String,java.lang.String) in blog cannot be applied to (java.lang.String,java.lang.String)
              blog.GetInfo(user,Entry);
                  ^
    G:\VOC T2\Java\Chap4\test.java:31: non-static method ShowInfo() cannot be referenced from a static context
              blog.ShowInfo();
                  ^
    6 errors
    Tool completed with exit code 1 Plez help

    -- "non-static X cannot be referenced from a static context" --
    You get this error because static members don't require an instance of the object to be accessed; they belong to the class. But a non-static member belongs to an instance (an individual object). There's no way for the static method to know which instance's variable to use or method to call, and thus, the compiler happily tells you that you can't access an instance member (non-static) from a class context (static).
    [The Java? Tutorial - Understanding Instance and Class Members|http://java.sun.com/docs/books/tutorial/java/javaOO/classvars.html]
    ~

  • Need Help Bank Account balances-Urgent

    Hi Masters,Can anyone help me to identify if we have any concurrent programme availaible (report) to obtain the daily opening and Closing balances for bank accounts for a SPECIFIED PERIOD
    I looked around but no luck..Even though I found a report in Cash management as 'Bank statement Summary Report' but in that the opening and closing balances are just Net Movements or say amont reconcilled and unreconcilled.My requirement is to have the opening and closing balances at a given point of time.
    It had been almost a week researching but no luck please HELP
    Message was edited by:
    A007

    Also I'll apprecaite if you can tell me which table stores the opening or closing balances if in case I need to develop a customised report for my requirement..
    Thanks
    A
    Still waiting as on Jan 16 2008..I blv it is very easy for you guys..pls respond
    Message was edited by:
    A007

  • Need help : mail account settings crashes !

    I've been looking around the forums for a while but can't seem to find a topic covering this.
    Can anyone plz help me with the following problem :
    I've got several mail accounts set-up on my iphone.
    Yesterday i added another account (5th account), specific a Gmail account.
    (at least i think this is when the problem started).
    After this, i noticed my other (regular popmail and hotmail) accounts didn't seem to be working.
    so i thought let me check out the settings...
    to my suprise i cannot seem to edit or delete these accounts !!
    everytime i want to go to settings, the phone crashes into home screen
    i've been trying to resolve this al nght now, even tried factory reset with backup twice (i need to keep my backup... ) but the mail settings still crash to home.
    I'm really desperate by now ...
    all i can find online is some resolutions on how to do it with a jailbroken phone..
    can anyone help ?
    grt.
    ron.

    sorry i seem to have put this topic in the wrong forum
    (enterprise io regular iphone )
    can someone move it ?

  • Need help making this class Runnable.

    Hello,
    This class (see below) is working fine the way it is but I have a little problem, I need to execute aprox 500+ commands and each command takes between 30sec to 3 minutes to complete which translate into hours for the job to finish.
    I want to speed the process by multi-tasking and executing (possibly) all commands simultaniously by somehow making this class Threaded/Runnable (miltitasking). There must be something tricky about Runtime class and cannot figured it out.
    Your help would be highly appreciated.
    Regards,
    Ulises
    public class CmdTest {     
    public static void main(String[] args) throws java.io.IOException {
    String outFile = "./ds8300/lsvogrp.txt";
    PrintWriter bout = null;
    try {
    bout     = new PrintWriter(                         new FileWriter(new File(outFile)));     
    } catch (IOException e) {
         e.printStackTrace();
    Runtime run = Runtime.getRuntime();
    run.traceMethodCalls(true);
    Process proc2 = run.exec("cmd /c dscli -user user -passwd psw" + "lsvolgrp -l");
    BufferedWriter ot = new BufferedWriter(
    new OutputStreamWriter(proc2.getOutputStream()));
    BufferedReader br = new BufferedReader(
    new InputStreamReader(proc2.getInputStream()));
    BufferedReader er = new BufferedReader(
    new InputStreamReader(proc2.getErrorStream()));
    try {
    String s;
    while((s=br.readLine())!=null) {
         System.out.println(""+s);
         bout.println(s);
    while((s=er.readLine())!=null) System.out.println("ERR:"+s);
    bout.close();
    System.exit(0);
    }catch (Exception ie) { //catch (InterruptedException ie) {
    System.out.println("Interrupted:"+ie.getMessage());}
    }

    Seems like the same question you asked last year.
    http://forum.java.sun.com/thread.jspa?threadID=5181153&messageID=9705196#9705196
    The proper way to design software is to start at the beginning and design Classes. Not try to butcher that which is working.
    You're running work outside the JVM and this work might interfere with other, similar work (the multi-threading issue.)
    I'd start with paper and pencil and see what conflicts might arise.

  • Need help w/ created classes and objects

    I am having a difficult time understanding what is wrong w/ my classes and objects. I've looked in two books and have messed around a bit. Here is what I am -attempting- to do.
    I want to make a class called CLOTHING. In this class i want objects such as shirt and pants (for now).
    these are the errors im getting:
    .\Shirt.java:6: invalid method declaration; return type required
         public Shirt(int size){
                   ^
    .\Shirt.java:3: class Clothing is public, should be declared in a file named Clothing.java
    public class Clothing {
           ^
    MyClassHW.java:10: cannot resolve symbol
    symbol  : constructor Shirt  (int,int)
    location: class Shirt
              myShirt = new Shirt(1,1);
                              ^
    3 errors------------------------------------------------------------
    This is the code for my Clothing class:
    import java.awt.*;
    public class Clothing {
         private int shirtSize;
         private void Shirt(Graphics s, int h, int v){
         Polygon shirts;
              shirts = new Polygon();
              shirts.addPoint(5+h,8+v); // 1
              shirts.addPoint(17+h,12+v); // 2
              shirts.addPoint(19+h,13+v); // 3
              shirts.addPoint(33+h,8+v); // 4
              shirts.addPoint(37+h,13+v); // 5
              shirts.addPoint(25+h,20+v); // 6
              shirts.addPoint(25+h,28+v); // 7
              shirts.addPoint(15+h,28+v); // 8
              shirts.addPoint(15+h,20+v); // 9
              shirts.addPoint(1+h,12+v); //10
              s.fillPolygon(shirts);
    }from what i understand each object is essentially a method...
    Here is the code for the java applet I'm making:
    import java.awt.event.*;
    import java.awt.*;
    import java.applet.*;
    public class MyClassHW extends Applet { // implements ActionListener, AdjustmentListener {
         Shirt myShirt;
         int size;
         public void init(){
              myShirt = new Shirt(1,1);
    // <applet code = "MyClassHW.class" height = 300 width=300> </applet>thank you for your time and help. as always, your efforts are appriciated.

    .\Shirt.java:6: invalid method declaration; return type required     public Shirt(int size){
    I guess, public Shirt(int size) is constructor in class shirt. You have one int in this constructor. Shirt(int size)
    Here you initialize your shirt with two int:
    MyClassHW.java:10: cannot resolve symbolsymbol : constructor Shirt (int,int)location: class Shirt          myShirt = new Shirt(1,1);
    Shirt(int size, int what?)
    It's why it show such message.
    But even if you fix it seems like you have very vague ideas about what you are doing.
    As far as I understood you need three classes.
    First applet Clothing:
    public class Clothing extends Applet{
    Shirt myShirt;
    Pants myPants;
    public void init() {
    myShirt = new Shirt(1); // small shirt
    myPants = new Pants(32, 40); // medium waist and long legs
    Second and third your classes Shirt and Pants:
    public class Shirt extends Object {
    int size;
    public Shirt(int s) {
    size = s;
    public int getSize () {
    return size;
    same for Pants, only you need two parameters for it or whatever you want.
    You could design it diffrently if you want derive your Shirts and Pants from Clothing and then to use them in your applet. But, indeeed, you desperately have to do some serious reading, where authors are accurate in they definitions and stuff, because it's kind of complicated.

  • Need help recovering account; can't sign in

    please help me to recover my skype account i cant sign in to my skype
     Post transferred to create its own new thread (topic); subject/title edited accordingly.

    Hi, Rabigh, and welcome to the Community,
    I arranged to transfer your post to create a new discussion, as where you posted was not truly related to your enquiry.
    The only way to recover access to your Skype account is to contact Skype Customer Service.  We here in the Community do not have access to the tools to do this.  Here is a link to the instruction on how to contact Skype Customer Service via their secure portal: Contact Customer Service
    Here are a few extra notes to guide you along the way:
    You will need to proceed through each step, one at a time. Sign on to the Skype website as requested. Choose the subject and topic which most closely matches the item you need assistance with. Then, continue past Step 2 of the instruction where several articles from the FAQ library will appear for you to review, and proceed to Step 3, Continue Support Request (the blue "button" appears at the lower right corner of the website page). You may also skip through Step 4 where you will be referred back here to the Community; no need to do this as the Community is where you started. When you complete the webform and click Submit, your information is relayed to Skype and you will receive a reply via e-mail.
    Regards,
    Elaine
    Was your question answered? Please click on the Accept as a Solution link so everyone can quickly find what works! Like a post or want to say, "Thank You" - ?? Click on the Kudos button!
    Trustworthy information: Brian Krebs: 3 Basic Rules for Online Safety and Consumer Reports: Guide to Internet Security Online Safety Tip: Change your passwords often!

  • Need Help in Inner Classes

    Hi
    I joined as a faculty last week in an institution. To take class I need some information about inner classes in java.
    Basically i need where we use this concept in real time application. Now it is used by the developer or not? Moreover how it is working in java?
    Please somebody help me out...
    thanks in advance
    Chithrakumar

    I once wrote the following example class showing a bit of inner classes"public class Star {
         private String name;
         public Star(String name) { this.name= name; }
         public class Planet {
              private String name;
              public Planet(String name) { this.name= name; }
              public class Moon {
                   private String name;
                   public Moon(String name) { this.name= name; }
                   public String toString() { return name+" (orbiting "+Planet.this+")"; }
              public String toString() { return name+" (orbiting "+Star.this+")"; }
         public String toString() { return name; }
         public static void main(String[] args) {
              System.out.println(new Star("sun").new Planet("earth").new Moon("moon"));
    }Study it, run it and see if you understand what this is all about.
    kind regards,
    Jos

  • Need help with Runtime class in UNIX

    I am attempting to kick off a C++ executable from within java. This class is called through a UI.
    The executable runs in the form of the exec followed by name=value pairs, ie [path/exec] [n=v] [n=v] ... and runs fine from the command line.
    Examples: These don't kick it off, but don't error either.
    String cmd[] = {"/bin/sh","-c","[path]/[exec] [n=v]};
    String cmd[] = new String[3];
    cmd[0] = "[path]/[exec]";
    cmd[1] = "[n=v]";
    cmd[2] = "[n=v]";
    Process p = Runtime.getRuntime().exec(cmd);
    I'm thinking it may be an environment issue, ie env vars not set because the only way I can get this to work is to put the command in a shell script that sets the env vars and kicks off the executable. Like:
    String cmd[] = {"/bin/sh","-c","/[path]/test.sh"};
    I'd prefer to kick this off from the java code. It sounds like I need to find a way to shell out, run our script to set env vars, then kick off the exec. This is my first attempt w/ using Runtime, so maybe I'm missing something.
    Thanks in advance for the help.

    I think this sort of thing will depend upon the shell you're in. When you use Runtime.exec you (might) lose your "parent" shell's environment variables - this question shows up here now and again, here's one thread that might help:
    http://forum.java.sun.com/thread.jspa?threadID=468648&messageID=2172572
    You might find some enlightenment on Roedy's Java Glossary here: http://mindprod.com/jgloss/exec.html
    Hope that helped
    Lee

  • Need help with JComponent class

    Hi,
    I'm trying to create a class that has all the characteristics of several GUI components such as JButton, JLabel, JRadioButton .... combined into one big class. But when I run the codes, the object of this new class is not visible on a frame like a JButton or a JLabel would be. Someone, please give me some hints. Thanks.
    The ButtonWrapper class extends JButton and the CheckBoxWrapper class extends JCheckBox and they both work without any problems. The GuiWrapper class (listed below) is the class that has the visibility problem when added to a container of a frame.
    import java.awt.*;
    import javax.swing.*;
    public class GuiWrapper extends JComponent{
      public GuiWrapper(String ptype, String p2, String p3) {
         if(ptype.toLowerCase() == "button"){
           ButtonWrapper b = new ButtonWrapper(p2, p3);
         if(ptype.toLowerCase() == "checkbox"){
           CheckBoxWrapper c = new CheckBoxWrapper(p2, p3);
    }

    Okay, so, for starters, I think this is a Really Bad Idea. If your developers can't handle using the API/tutorial to learn how the components work, your project will fail. This UberClass will not help in the long run. It will also almost certainly turn into a maintainence nightmare for you.
    Of course, since you're going to do it anyway... I suspect your issue lies with paintComponent. If I recall correctly, paintComponent doesn't render anything by default for a JComponent. You'll need to override paintComponent and have it invoke the renderer for the relevant child component.

  • Need help with a class project

    I'm new to Java and I'm having problems converting a small program to be more functional. Here is my original codeimport java.util.Arrays;
    public class Product
    // initialize arrays
       private int cdNums[] = { 0,0,0,0 };
       private String cdNames[] = { "null", "null", "null", "null" };
       private int cdUnits[] = { 0,0,0,0 };
       private double cdValue[] = { 0.0, 0.0, 0.0, 0.0 };
       private double inventoryValue[] = { 0.0, 0.0, 0.0, 0.0 };
    // initialize instance variable
       private double totalValue = 0;
       private int count;
       public Product( int invNumber[], String albumName[], int invUnits[], double invValue[] )
             cdNums = invNumber;  // store inventory number
             cdNames = albumName;  //store album name
             cdUnits = invUnits;  //store number of units
             cdValue = invValue; // store unit price
       public double calcInventoryValue()
             // calculate Inventory value
                for ( int count = 0; count < cdNums.length; count++ )
                       totalValue =0; // initialize totalValue
                       totalValue =( cdUnits[ count ] * cdValue [ count ] );
               System.out.printf( "%s%d%s%s%s%d%s%.2f%s%.2f\n", "Item #", cdNums[ count ], " is: ", cdNames[ count ], " with ", cdUnits [ count ], " units priced at $", cdValue [ count ], " gives value of $", totalValue );
             return totalValue;
          } // end calcinventoryValue method
    } // end classand the test application: import java.util.Arrays;
    public class ProductTest
       public static void main( String args[] )
            int invNumber [] = { 1,2,3,4 };
            String albumName[] = { "Wish You Were Here", "Abacab", "Animals", "Security" };
            int invUnits[] = { 200, 150, 50, 500 };
            double invValue[] = { 14.99, 9.99, 23.49, 12.99 };
         Product myProduct = new Product (invNumber, albumName, invUnits, invValue );       
            myProduct.calcInventoryValue();
         } // end main
    } // end class ProductTestWhat I want to do is convert it to read in user input instead of static lists. Here is what I have so far:
    import java.util.Arrays;
    public class Product
    // initialize arrays
       private int cdNums[];
       private String cdNames[];
       private int cdUnits[];
       private double cdValue[];
       private double inventoryValue[];
    // initialize instance variable
       private double runValue = 0;
       private double totalValue = 0;
       private int count;
       public Product( int invNumber[], String albumName[], int invUnits[], double invValue[] )
             cdNums = invNumber;  // store inventory number
             cdNames = albumName;  //store album name
             cdUnits = invUnits;  //store number of units
             cdValue = invValue; // store unit price
       public double calcInventoryValue()
             // calculate Inventory value
                totalValue = 0; // Initialize totalValue variable
                for ( int count = 0; count < cdNums.length; count++ )
                       runValue =0; // initialize runValue
                       runValue =( cdUnits[ count ] * cdValue [ count ] );
               System.out.printf( "%s%d%s%s%s%d%s%.2f%s%.2f\n", "Item #", cdNums[ count ], " is: ", cdNames[ count ], " with ", cdUnits [ count ], " units priced at $", cdValue [ count ], " gives value of $", runValue );
                     totalValue = totalValue += runValue;
              calcTotalValue( totalValue );
             return totalValue;
          } // end calcinventoryValue method
        public double calcTotalValue( double totalValue )
             System.out.printf( "%s%.2f\n", "The total value of the inventory is: $", totalValue );
              return totalValue;
           } // end calcTotalValue method
    } // end classand the new test application:
    import java.util.Arrays;
    import java.util.Scanner;
    public class ProductTest
       public static void main( String args[] )
            double totalValue = 0;
          do 
            { //  open dowhile
             int count = 0; // initialize counter
             Scanner input = new Scanner( System.in ); // call scanner to get input
             for ( int count = 0; count > 0; count++ )
               {  // open for loop
                         System.out.printf ( "%s%d%s\n", "Please enter the inventory # of Item ", count, " or 0 to quit: " );  // prompt for inventory number or sentinel value
                          int invNumber[ count ] = input.nextInt();  // get user input of Item Number
                 if ( invNumber[ count ] != 0 )  // check for sentinel
                   {  // open if
                         System.out.printf ( "%s%d\n","Please enter the album name of Item #", invNumber[ count ] );  // prompt for album name
                         String albumName[ count ] = input.nextLine();  // get input album name
                         System.out.printf ( "%s%d\n", "Please enter the number of units in stock for Item #", invNumber[ count ] );  // prompt for number of units in stock
                         int invUnits[ count ] = input.nextint();  // input rate of payment
                         System.out.printf ( "%s%.2f\n", "Please enter the unit price for Item #", invNumber[ count ] );  // prompt for unit price
                         double unitValue = input.nextDouble();  // input rate of payment
                         System.out.println();  // print blank line for readability
                   } // close if
                else
                   {  // open else
                      Product myProduct = new Product (invNumber, albumName, invUnits, invValue );       
                         myProduct.calcInventoryValue();
                   } // close else
               } // close for loop           
           } while ( invNumber != 0 );  // loop back to inputting employee name and close dowhile
        } // end main
    } // end class ProductTestthe compiler is telling me for ProductTest that it is expecting "]" for the following line: int invNumber[ count ] = input.nextInt();Do I need to store the data in a variable first and then feed it into the array? What do I need to do to complete this code?

    OK, yeah. Change the Product constructor so that it takes scalar values (as opposed to arrays) -- a single int for units in stock, and single String for name, etc.
    Then you can create multiple objects of that class, one for each CD or whatever.
    It makes sense to hardcode values in the ProductTest class, but not really in the Product class. Your ProductTest class is almost there. You know how in the main method you create a single Product object with those arrays? Change it so that you have a loop. Loop through the prices, album names, etc., and create a Product for each set of values. Then put the Product objects in an array, or better yet (and if you've covered it in class) into a Collection like a java.util.HashSet or a java.util.ArrayList.
    You said you wanted to make it take values from user input, rather than hardcoded lists. Once you've made the above change, move on to doing that. You can read user input with a java.util.Scanner. Or you can use a java.io.BufferedReader. Did the prof say to use one particular method or another?

  • Urgent Need help on DATE Class

    i have written the code
    <page language="java">
    <%@page import="java.util.Date" %>
    <%
         String mydate="10/25/03";
         Date d=new Date(mydate);
         int mon=d.getMonth();
         int day=d.getDay();
         int year=d.getYear();
         out.println(d+","+mon+","+day+","+year);
    %>
    when i execute
    Sat Oct 25 00:00:00 GMT+05:30 2003,9,6,103
    can some one help me, why i am getting different month day and year

    Be aware that you're using deprecated methods of the Date class. If you read the javadoc for those methods you'll discover that the results are correct. The getMonth method returns a zero-offset month with zero representing January. The getDay method returns a zero-offset day of the week (0 = Sunday...6 = Saturday) not the day of the month. Use the getDate method to return day of the month. The getYear method returns a value that is the result of subtracting 1900 from the year.

  • Need help Adding Account (dDocAccount) programmatically with Java API

    Using Content Server Version:10.1.3.3.3 (080807) (Build:7.2.2.188)
    I am trying to create a routine using the the CIS JavaDoc as a reference, to create a programmatic way to add security Accounts. Here is a code snippet that I have:
    // Get the user API
    ISCSUserAPI api = getClient().getUCPMAPI().getActiveAPI().getUserAPI();
    ISCSUserAccount ua = api._createAccount();
    ua.setName("MY-TEST");
    I thought this would work. I don't get an error, but the dDocAccount is not created in the DOCUMENTACCOUNTS table? Is the better solution to simply add entries directly into the table?
    Thanks, Ken

    I had also posted a similar question on the intradoc group in Yahoo and received several helpful replies. The document services_reference_10gr3en.pdf provides the references to all the services, and a little bit of java code was used to call these services.
    For those interested in the code:
              // Get the Administrative API
              // ISCSUserAPI api = getClient().getUCPMAPI().getActiveAPI().getUserAPI();
              ISCSAdministrativeAPI api = getClient().getUCPMAPI().getActiveAPI().getAdministrativeAPI();
              // ISCSServerResponse sr = api.executeIDCService(ISCSContext SCSContext, java.lang.String serviceName, java.util.Map arguments);
              ISCSServerResponse sr = api.executeIDCService(getSCSContext(), commandName, arguments);
    Basically using the same base from the examples available in the CIS SDK.
    Thanks, Ken

Maybe you are looking for

  • How do i use an alredy open HTTP connection belong to aother class

    When my apps logs in the User by checking that the username and password are correct against the server then there has been a connection opened to perform this task. Then the user is returned to the Main Menu. After that they can send some data to th

  • Is there a way to change the highlight color for buttons?

    I swear, iDVD has got to be the most counter-intuitive program Apple has made in recent memory. I'm a huge Apple fan but this program makes me want to throw my computer at the freaking wall. All I want to do is change the ugly yellow highlight color

  • HELP NEEDED RUNTIME ERROR

    x emac   Mac OS X (10.3.9)   im tryin to access my myspace profile. ive done it before on my mac no probs. all of a sudden when i try and get to my profile come up with runtime error message Description: An application error occurred on the server. T

  • Data Modeler Logical Data Type confusion!

    I don't get it. When defining a logical model, I want to assign data types to the attributes in my model. I understand a logical datatype like money, and that a logical datatype might be implemented differently in different databases. The concept mak

  • ORA-12541: TNS:no listener after upgrading from 11.1.0.6 to 11.1.0.7

    After upgrading from 11.1.0.6 to 11.1.0.7, I get the error: ORA-12541: TNS:no listener. I have attached my tnsnames.ora, listener.ora and my sqlnet.log. I have tried deleting the listener and re-adding it and I get the same error. I have tried adding