Do week-long java courses help to understand java &  get a job?

i tried searching for this topic before posting, but "courses" "classes" & "instruction" come up with a lot that has nothing to do with the topic at hand. :)
like many others, i'm teaching myself out of a book (Deitel). so far i've been able to understand the material and create programs based on the exercises. however, i'm now into the meat of OOP with superclass, subclasses, how they interact and the like and i'm having a rough go of it. i can diagram and understand the abstract concept, but when i'm faced with an actual program example i have a difficult time following the interactions between classes.
i'm considering taking one of those 5 day classes, but am wary of how much they will actually be able to cover in detail (not to mention the $$). has anyone here taken one of those classes and found them to be of great benefit to learning the OOP portion of Java? did it give you enough understanding to obtain an entry-level job?
btw, i'm doing a pro bono project for a small company to get some real world experience. (i've heard that suggestion many times in regards to obtaining one's "experience" w/o a job)
thank you all very much for your help.

I took a week long course to learn Java. It worked I did learn the basics of Java but I did already know how to program in C and VB at the time. I found the AWT section of the class to be very valuable,cosidering I mostly write GUI. And the concepts of AWT mostly all apply to swing so that didn't set me back at all. Depending on the school it may help you to understand OOP. But be careful because most schools progress the class at the skill level of the majorty. So if you have 15 people in the class and 9 of them know nothing about programing your probably going to spend the week learning what a variable and a while loop do, you all pay the same tuition and they would rather 6 of you leave then 9 of you leave. If you have some prior programming knowledge I would recomend finding a class that caters to that.

Similar Messages

  • Making animation using java, need help, image doesn't get painted

    I was trying to make some sort of animation and it is done by painting a head and a body at a time. The problem is the body never gets painted but the head is perfect. Unless I replace the int variable within imgBodypics[int variable] with a variable at counts from 0 to N or an integer , the body doesn't get painted, that is not what i want, as the images that make up the animation consists of 8 frames starting from the image006.gif ~ image014.gif
    import java.awt.Image;
    import java.awt.Graphics;
    import java.awt.Color;
    public class Knight extends java.applet.Applet implements Runnable {
         Image imgBodypics[]= new Image[115];
         Image imgHeadpics[]= new Image[15];
         Image imgCurrentbody, imgCurrenthead;
         int intBodyposx,intBodyposy,intHeadposx,intHeadposy;
         int brainwalkxpos,brainwalkypos,bodywalkxpos,bodywalkypos;
         Thread thdRunner;
         public void init() {
              for (int i=0;i < 115; i++){
                   imgBodypics[i] = getImage(getCodeBase(),"images/knight/knight000"+i+".gif");
              for (int i=0;i < 15; i++){               
                   imgHeadpics[i] = getImage(getCodeBase(),"images/headboy02/headboy02000"+i+".gif");
         public void start() {
              if (thdRunner == null) {
                   thdRunner = new Thread(this);
                   thdRunner.start();
         public void stop() {
              if (thdRunner != null) {
                   thdRunner.stop();
                   thdRunner = null;
         public void paint(Graphics g) {
              g.drawImage(imgCurrentbody, intBodyposx, intBodyposy,this);
              g.drawImage(imgCurrenthead, intHeadposx, intHeadposy,this);
         public void walk(int intNumtimes, String strDirection) {
         int intDirectionx,intDirectiony,intBodyimagecode;
              if (strDirection == "down")      {     intDirectionx = 0;
                                                      intDirectiony = 1;
                                                      intBodyimagecode = 6;}
              else if(strDirection == "leftdown"){intDirectionx =-1;
                                                      intDirectiony =1;
                                                      intBodyimagecode = 14;}
              else if(strDirection == "left") {     intDirectionx = -1;
                                                      intDirectiony = 0;
                                                      intBodyimagecode = 22;}
              else if(strDirection =="leftup") {     intDirectionx =-1;
                                                      intDirectiony =-1;
                                                      intBodyimagecode = 30;}
              else if(strDirection == "up")      {     intDirectionx = 0;
                                                      intDirectiony = -1;
                                                      intBodyimagecode = 38;}
              else if(strDirection =="rightdown") {intDirectionx =1;
                                                      intDirectiony =1;
                                                      intBodyimagecode = 14;}
              else if(strDirection == "right") {     intDirectionx = 1;
                                                      intDirectiony = 0;
                                                      intBodyimagecode = 22;}
              else if(strDirection =="rightup") {     intDirectionx =1;
                                                      intDirectiony =-1;
                                                      intBodyimagecode = 30;}
              else{      intDirectionx = 0;
                        intDirectiony = 0;
                        intBodyimagecode = 6;}
              int intLastBodyimagecode = intBodyimagecode + 8;
              int intFirstBodyimagecode = intBodyimagecode;
         for (int intCount = intNumtimes; intCount > 0; intCount--){
              for (int i = 0; i < 8; i++){
              int intJ,intI;
              intJ = i;
              intI = intBodyimagecode + i;
              imgCurrentbody = imgBodypics[intI];
              intBodyposx = 250 - (imgCurrentbody.getWidth(this) / 2) + (intDirectionx * intJ * 12);
              intBodyposy = 200 - (imgCurrentbody.getHeight(this) / 2) + (intDirectiony * intJ * 12);
              imgCurrenthead = imgHeadpics[intJ];
              intHeadposx = 250 - (imgCurrenthead.getWidth(this) / 2) + (intDirectionx * intJ * 12);
              intHeadposy = 200 - (imgCurrenthead.getHeight(this) / 2) + (intDirectiony * intJ * 12);
              repaint();
              intBodyimagecode++;
              try { Thread.sleep(200); }
              catch (InterruptedException e) { }
         public void update(Graphics g) {
         paint(g);
         public void run() {
              setBackground(Color.lightGray);
              walk(1, "left");
              walk(1, "right");
              walk(1, "up");
              try {Thread.currentThread().sleep(5000);}
              catch (InterruptedException e) { }

    Erm, i tried to highlight the code and then press the code tag but after posting it is still plain, and there is no way to edit the post, sorry about that, next time i'll try. About the book "Filthy Rich Clients", no i don't have it, is there any free version of similiar resources?
    testing123

  • HT3529 Can someone help me understand why my iMessage no longer works on my iPad

    Can someone help me understand why my iMessage no longer works on my iPad

    iOS: Troubleshooting Messages
    iOS: Troubleshooting FaceTime and iMessage activation

  • Need a little help understanding java and /etc/profile.d/***

    A few days ago I installed jre-6u10-1 and jdk-6u10-1 via pacman on my desktop machine; for the web plugin.
    The packages installed in /opt/java/...
    I later installed jedit, via pacman.  It runs fine as it (/usr/bin/jedit) is hardcoded to look for java in /opt/java/...
    Today, I installed jedit (pacman -S jedit) on my laptop which did not have any java installed.
    Pacman automatically installed openjdk6-jre-6u10-1 as a prerequisite.
    Openjdk installs to /usr/lib/jvm/..., therefore jedit fails as /opt/java... is non-existent.
    I suppose Sun's java and the opensource version are installed in different locations to keep from overwriting each other.
    I could easily edit /usr/bin/jedit to point to the openjdk location and it would work.
    But I'm a little uncertain of the following three files:
    Sun's java installs /etc/profile.d/jre.sh and /etc/profile.d/jdk.sh
    which do the following (respectively):
    export PATH=$PATH:/opt/java/jre/bin
    if [ ! -f /etc/profile.d/jdk.sh ]; then
    export JAVA_HOME=/opt/java/jre
    fi
    and
    export J2SDKDIR=/opt/java
    export PATH=$PATH:/opt/java/bin
    export JAVA_HOME=/opt/java
    The opensource java package installs /etc/profile/openjdk6.sh
    which does the following:
    export J2SDKDIR=/usr/lib/jvm/java-1.6.0-openjdk
    export J2REDIR=$J2SDKDIR/jre
    export JAVAHOME=/usr/lib/jvm/java-1.6.0-openjdk
    #export CLASSPATH="${CLASSPATH:+$CLASSPATH:}$J2SDKDIR/lib:$J2REDIR/lib"
    So I am left with a few options:
    1.  edit /usr/bin/jedit to look in the opensource location
    2.  edit /usr/bin/jedit to use the $J2SDKDIR variable when looking for java
    3.  update the $PATH via /etc/profile.d/openjdk6.sh to include java's location
    I think all three methods would work, but I have limited experience with java and would like some input as to which proposed solution is the best going forward.
    What methods are other java apps using to find java?
    Thanks
    (edit: more descriptive title)
    Last edited by cjpembo (2008-11-11 04:24:47)

    I think the best option would be to ask the maintainer to modify the jedit-bin file, and have it launch
    $J2SDKDIR/bin/jre/java cp $CP -Djedit.home="/usr/share/jedit" -mx${JAVA_HEAP_SIZE}m org.gjt.sp.jedit.jEdit $@
    That way, it should work with both java implementations (completely untested, btw.)

  • Java Progrramming HELP, Needed Urgently, T hanks

    hey guys,
    I have this lab I need to be done tomorrow, its been weeks lol of thinking and figuring things out can someone make it work ? Pleaseeeee !
    I feel like going out and yelling for help lol I have been trying to figure this out for weeks now.
    I am pasting my Lab and My Codes I did so far, And Please I really need this done today at any rate, all help would be kindly appreciated.
    A Java program is required that will produce a number of reports based on the data from the Product file. This file contains the product name, cost, quantity and UPC. The file name must be input. Valid data from the file will be loaded into an array.
    A menu will provide the following options: (Note there are changes from previous assignment.)
    1     Display of all valid product information including extended price and GST including totals sorted by name.
    2     Display of all invalid records sorted by name.
    3     Search and display a certain product by name.
    4     Sort by UPC and use a binary search and display a certain product by UPC. (valid records)
    9 Exit.
    Processing requirements:
    Input the data from a file and load the records into an object array. Use this object array to produce the above reports.
    Code a class definition exactly as given in the following UML.
    (For specific students: you may code the UPC as an integer but if not numeric throw an exception that is handled in main. Document your choice in your submission).
    Product
    ? Name : String
    ? UPC : String
    ? Cost : Real
    ? Quantity : Integer
    + Product (Name : String, UPC : String, Cost : Real, Quantity : Integer)
    + Calculate Extended Cost() : Real
    + Calculate GST(): Real
    Input Record:
    Product name: String
    UPC: String
    Cost: real
    Quantity: integer
    Output Reports
    1. Display of all product information including extended cost and GST including totals of these 3 fields.
    Following is a sample of the output required:
    ************************ Product Cost REPORT ****************************
    Product                    Cost Quantity Extended Cost     GST     Total Cost
    Diamond Necklace 12345678901x 54,321.99 188 10,212,534.12 510,626.71 10,723,160.83
    Tissues 98989898989x 1.99 2 3.98      0.20     4.18
    TOTALS                         10,212,538.10 510,626.91 10,723,165.01
    2. Display of all invalid records and the count.
    Following is a sample of the output required:
    Invalid UPC Records = 1
    Count Record
    1          Tiara Diamond, 12345678901x, 36020.00, 2
    3. Search and display a certain product by name. Display appropriate message if not found.
    Following is a sample of the output required:
    Enter product name: CrownJewels
    CrownJewels 99999999991x     100,000.00 1 100,000.00 5,000.00 $105,000.00
    6. Display the product information sorted by name
    Following is a sample of the output required:
    ************************ Product Cost REPORT ****************************
    Product                    Cost Quantity Extended Cost     GST     Total Cost
    CrownJewels 99999999991x 100,000.00 1 100,000.00 5,000.00 $105,000.00
    Diamond Necklace 12345678901x 54,321.99 188 10,212,534.12 510,626.71 $10,723,160.83
    Pearls      88888888881x 10,000.00 1 10,000.00 500.00 $10,500.00
    RubyRing      77777777771x 10,000.00 1 10,000.00 500.00 $10,500.00
    Tissues      98989898989x 1.99 2 3.98 0.20     $4.18
    TOTALS          (complete these values)           xxx           xxx      xxx
    Java coding requirements for this assignment
    Main methods required
    1.     Load array with all records. Display exception messages only for records that have invalid data in any of the fields. Return array of valid records and logical size.
    2.     Validate the UPC. Display each report when requested from the menu.
    3.     Justify the data in the columns. Right justify numeric fields; left justify the alpha fields.
    4.     A method for each report required in the menu.
    Class methods
    5.     Use the object method for the extended cost.
    6.     Use the object method for the GST.
    You may use additional methods in the main program but do not add any methods in the class definition.
    Use DecimalFormat for rounding.
    Create an array to hold the objects. Assume that we only need to process a file of a maximum of 500 records but the file may be larger than 500 records.
    A Universal Product Code consists of 12 digits. The first digit (from the left) is the UPC type. The next five digits are the Manufacturer code. The next five digits are the product code which is assigned by the manufacturer. The final digit is the check digit. A person can determine the check digit of a Universal Product Code by doing the following:
    Step 1: Sum all of the digits in the odd positions together.
    0+4+0+1+5+9 = 19
    Step 2: Multiply the sum from Step 1 by 3.
    3 * 19 = 57
    Step 3: Sum all of the digits in the even positions together.
    6+2+0+1+8 = 17
    Step 4: Sum together the results from Step 2 and Step 3.
    17 + 57 = 74
    Step 5: Subtract the sum from the next highest multiple of 10.
    80 - 74 = 6 [check digit]
    TEST DATA:
    Step 1: Create 5 or MORE additional records that will test all conditions. Include these in your documentation. Identify what field is tested in your test data. (Example: error in each field of the record, rounding up, rounding down, valid UPC, invalid UPC, formatting of report, file too large
    Step 2: Use the file attached.
    GODDDDDDDDDDDDDD lol pasting it made me go crazy,
    these are my codes so far, HOwever the problem is ONLY DISPLAY MENU SHOWS, nothing else even though i have enough codes that it can show something,
    My codes are as follows:
    I am working on Eclipse.
    import java.util.Arrays;
    import java.util.Scanner;
    import java.io.*;
    import java.util.*;
    import java.io.IOException;
    * Name : Sana Ghani
    * Date : July 10
    public class lab56
         public static Scanner file;
         public static Scanner parse;
         public static Scanner input = new Scanner(System.in);
         public static Scanner searchInput = new Scanner(System.in);
         public static void main(String[] args) throws Exception
              Product1[] validProduct = new Product1[500];
              int logicalSize = 0;
              int menuChoice=0;
              String FileName = getFileName();
              displayMenu();
              switch(menuChoice)
              case 1:
                   displayAllValidRecords(validProduct, logicalSize);
                   try
                   // Open an output stream
                   OutputStream fout = new FileOutputStream ("myfile.txt");
                   // Print a line of text
                   new PrintStream(fout).println ("hello world!");
                   // Close our output stream
                   fout.close();          
                   // Catches any error conditions
                   catch (IOException e)
                        System.err.println ("Unable to write to file");
                        System.exit(-1);
                   break;
              case 2:
                   break;
              case 3:
                   binarySearchByName( validProduct,logicalSize);
                   break;
              case 4:
                   break;
              case 5:
                   break;
              menuChoice = displayMenu();
         public static void display(Product1[]validProduct, int logicalSize)throws Exception
              String Product, UPC;
              double Cost;
              int Quantity;
              for(int index =0; index<logicalSize; index++)
                   Product = validProduct[index].GetName();
                   UPC = validProduct[index].GetUPC();
                   Cost=validProduct[index].GetCost();
                   Quantity=validProduct[index].GetQuantity();
                   System.out.println(Product+"\t\t"+UPC+"\t\t"+Cost+"\t\t"+Quantity);
         public static String getFileName()
              String fileName;
              Scanner input = new Scanner(System.in);
              System.out.print("Please enter a file name: ");
              fileName = input.next();
              return fileName;
         public static int displayMenu()
              int menuChoice;
              boolean validFlag = false;
              do
                   System.out.println("\n\n*************************************");
                   System.out.println(" Product Display Menu ");
                   System.out.println("*************************************");
                   System.out.println("(1)Display All Records");
                   System.out.println("(2)Display All Invalid Records");
                   System.out.println("(3)Search by Product Name");
                   System.out.println("(4)Sort by Product Name");
                   System.out.println("(5)Exit");
                   System.out.println("*************************************");
                   System.out.print("Enter your choice(1-5): ");
                   menuChoice = input.nextInt();
                   if ((menuChoice >= 1) && (menuChoice <= 5))
                        validFlag = true;
                   if (!validFlag)
                        System.out.println("You have chosen " + menuChoice + ", " + menuChoice +
                        " is not valid. Please try again");
              }while(!validFlag);
              return menuChoice;
         public static String loadArray(Product1 [] ValidProduct, String fileName)throws Exception
              int logicalSize=0;//will always have to declare
              String record;//will always have to declare
              String Product, UPC;//variable names from
              double Quantity;
              double Cost;
              Scanner file = new Scanner(new File(fileName));//open
              record = file.nextLine();//read a line
              record = file.nextLine();//read a line
              for(int index = 0; index < ValidProduct.length && file.hasNext(); index++)//check to see if the file has data
                   record = file.nextLine();
                   parse = new Scanner(record).useDelimiter(",");
                   String Name = parse.next();
                   UPC = parse.next();
                   Cost = parse.nextDouble();
                   Quantity=parse.nextDouble();
                   ValidProduct[index] = new Product1 ( Name, UPC, Cost, (int) Quantity);
    //               create the object-- call the constructor and pass info
                   logicalSize++;
              return logicalSize+".txt";
         public static double roundDouble(double value, int position)
              java.math.BigDecimal bd = new java.math.BigDecimal(value);
              bd = bd.setScale(position,java.math.BigDecimal.ROUND_UP);
              return bd.doubleValue();
         * This method will print report about valid records
         public static void displayAllRecords( Product1[]valid, int ValidProduct,
                   Product1[] invalid, int InvalidProduct)
    //          Print valid records
              displayAllValidRecords(valid, ValidProduct);
    //          Print invalid UPC records
              displayAllValidRecords(invalid, InvalidProduct);
         public static void displayOneRecord(Product1[]valid, int index)
              double extendedCost, GST, SumofGST = 0, // Total Extended Cost
              totalCost, SumOfTotalCost = 0; // Total Extended Cost + GST
    //          Print title
              System.out.println(leftJustify("Product", 50) +
                        leftJustify("UPC", 15) +
                        rightJustify("Cost", 10) +
                        rightJustify("Quantity", 5) +
                        rightJustify("Extended Cost", 15) +
                        rightJustify("GST", 5) +
                        rightJustify("Total Cost", 13));
              extendedCost = valid[index].CalculateExtendedCost();
              extendedCost = roundDouble(extendedCost, 2);
              GST = valid[index].CalculateGST();
              GST = roundDouble(GST, 2);
              totalCost = extendedCost + GST;
              totalCost = roundDouble(totalCost, 2);
    //          justify method ensures all values are of the same size
              System.out.println(//leftJustify(i+"",3) + ": " +
                        leftJustify(valid[index].GetName(), 50) +
                        leftJustify(valid[index].GetUPC(), 15) +
                        rightJustify(valid[index].GetCost()+"", 10) +
                        rightJustify(valid[index].GetQuantity()+"", 5) +
                        rightJustify(extendedCost+"", 10) +
                        rightJustify(GST+"", 10) +
                        rightJustify(totalCost+"", 10));
         * This method will print report about valid records
         public static void displayAllValidRecords( Product1[]valid, int validCounter)
              double extendedCost, sumOfExtendedCost = 0, // Total Extended Cost
              GST, sumOfGST = 0, // Total GST
              totalCost, sumOfTotalCost = 0; // Total Extended Cost + GST
              System.out.println("************************ XYZ Product " +
                        "Cost REPORT ****************************" +
    //          Print title
              System.out.println(leftJustify("Product", 50) +
                        leftJustify("UPC", 15) +
                        rightJustify("Cost", 10) +
                        rightJustify("Qty", 5) +
                        rightJustify("Extended Cost", 15) +
                        rightJustify("GST", 5) +
                        rightJustify("Total Cost", 13));
    //          Print Records
              for(int i=0; i<validCounter; i++)
                   extendedCost = valid.CalculateExtendedCost();
                   extendedCost = roundDouble(extendedCost, 2);
                   GST = valid[i].CalculateGST();
                   GST = roundDouble(GST, 2);
                   totalCost = extendedCost + GST;
                   totalCost = roundDouble(totalCost, 2);
    //               justify method ensures all values are of the same size
                   System.out.println(//leftJustify(i+"",3) + ": " +
                             leftJustify(valid[i].GetName(), 50) +
                             leftJustify(valid[i].GetUPC(), 15) +
                             rightJustify(valid[i].getClass()+"", 10) +
                             rightJustify(valid[i].GetQuantity()+"", 5) +
                             rightJustify(extendedCost+"", 10) +
                             rightJustify(GST+"", 10) +
                             rightJustify(totalCost+"", 10));
                   sumOfExtendedCost += extendedCost;
                   sumOfGST += GST;
                   sumOfTotalCost += totalCost;
         private static void sortByName(Product1 [] ValidProduct, int logicalSize) throws Exception
              Product1 temp;
              for (int outer = logicalSize-1; outer > 1; outer --)
                   for (int inner = 0; inner < outer; inner ++)
                        if (ValidProduct[inner].GetName().compareToIgnoreCase(ValidProduct[inner+1].GetName())>0)
                             temp = ValidProduct[inner];
                             ValidProduct[inner] = ValidProduct[inner + 1];
                             ValidProduct [+ 1] = temp;
         public static void binarySearchByName(Product1 [] ValidProduct, int logicalSize)
              int high = logicalSize - 1;
              int low = 0;
              int mid = 0;
              int count = 0;
              int compare = 0;
              boolean found = false;
              System.out.print("Enter a product name");
              String product = input.nextLine();
              while (high >= low && !found)
                   count += 1;
                   mid = (high + low) / 2;
                   compare = ValidProduct[mid].GetName().compareToIgnoreCase(product);
                   if (compare == 0)
                        System.out.println("Found: " + ValidProduct[mid].GetName());
                        found = true;
                   else if (compare < 0)
                        low = mid + 1;
                   else
                        high = mid - 1;
              if (!found)
                   System.out.println(product + " not found.");
              System.out.println(count + " steps");
              System.out.println();
         public static String leftJustify(String field, int width)
              StringBuffer buffer = new StringBuffer(field);
              while (buffer.length() < width)
                   buffer.append(' ');
              return buffer.toString();
         public static String rightJustify(String field, int width)
              StringBuffer buffer = new StringBuffer(field);
              while (buffer.length() < width)
                   buffer.append(' ');
              return buffer.toString();
         public static void displayValidRecords(Product1 [] ValidProduct, int logicalSize) throws Exception {
              long longMAX_POSSIBLE_UPC_CODE = 999999999999L;
              // set input stream and get number
              Scanner stdin = new Scanner(System.in);
              System.out.print("Enter a 12-digit UPC number: ");
              long input =stdin.nextLong();
              long number = input;
              // determine whether number is a possible UPC code
              if ((input < 0)|| (input > longMAX_POSSIBLE_UPC_CODE)) {
                   // not a UPC code
                   System.out.println(input +"is an invalid UPC code");
              else {   
                   // might be a UPC code
                   // determine digits
                   int d12 = (int) (number % 10);
                   number /= 10;
                   int d11 = (int) (number % 10);
                   number /= 10;
                   int d10 = (int) (number % 10);
                   number /= 10;
                   int d9 = (int) (number % 10);
                   number /= 10;
                   int d8 = (int) (number % 10);
                   number /= 10;
                   int d7 = (int) (number % 10);
                   number /= 10;
                   int d6 = (int) (number % 10);
                   number /= 10;
                   int d5 = (int) (number % 10);
                   number /= 10;
                   int d4 = (int) (number % 10);
                   number /= 10;
                   int d3 = (int) (number % 10);
                   number /= 10;
                   int d2 = (int) (number % 10);
                   number /= 10;
                   int d1 = (int) (number % 10);
                   number /= 10;
                   // compute sums of first 5 even digits and the odd digits
                   int m = d2 + d4 d6 d8 + d10;
                   int n = d1 + d3 d5 d7 + d9 + d11;
                   // use UPC formula to determine required value for d12
                   int r = 10 - ((m +3*n) % 10);
                   // based on r, can test whether number is a UPC code
                   if (r == d12) {
                        // is a UPCcode
                        System.out.println(input+" is a valid UPC code");
                   else {   
                        // not a UPCcode
                        System.out.println(input+" is not valid UPC code");
    Any help would be great thanks !!
    Take care,

    1) It's your problem that you waited until the last minute before you went for help...not ours. We'll give your problem the same attention as anyone elses...therefore your problem isn't any more urgent than any other problem here.
    2) I don't intend on doing your entire assignment. Nor do I intend on reading all of it. If you need help with a specific requirement, then post the information/code relevant to that requirement. I don't know how to help you when you bury the problem inside a 9 mile long essay.
    3) Post code in tags so it's formatted and readable. (there's a *code* button up above that makes the tags for you).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Java Calendar Help Needed :)

    Hi,
    I am trying to develop a Java Event Calendar which is able to display the calendar weekly. So the JPanel will be setup with 7 JLists for the days of the week. Buttons will allow switching of the days of the week, months and year.
    Each JList corresponding to the day of the week will have its data obtained from the database using JDBC and loaded upon 're-drawing' of the lists.
    However i am having trouble with the GUI side in understanding how to implement this, i am confident with the JList and database side of things, i have just used a similar example using the Calendar API for monthly displays, however i am unsure how to convert this to a weekly calendar.
    Ideally 7 JLists will always be available in the panel in order M,T,W,T,F,S,S but some will be set to inactive (for example in the first and last weeks of the month).
    If anyone has any suggestions please could you help me out :)
    Sorry if what im trying to do is a bit confusing.
    I've included the code i've been using for the monthly calendar
    THANKS!!
    public class CalendarPanel extends JPanel implements ActionListener {
      private Calendar panelDate;
      private Label monthLabel;
      private Label yearLabel;
      private Panel daysPanel;
      private Vector calendarListeners;
      private static final String days[] = {"S","M","T","W","T","F","S"};
      public CalendarPanel(){
        super(new BorderLayout());
        panelDate = Calendar.getInstance();
        buildUI();
      public CalendarPanel(Calendar date){
        super(new BorderLayout());
        panelDate = (date != null) ? (Calendar)date.clone() : Calendar.getInstance();
        buildUI();
      public CalendarPanel(Date date){
        super(new BorderLayout());
        panelDate = Calendar.getInstance();
        if(date != null) panelDate.setTime(date);
        buildUI();
      public Calendar getCalendar(){ return panelDate;}
      public void setCalendar(Calendar date){
        if(date != null){
          panelDate = (Calendar)date.clone();
          redrawPanel();
      public void setCalendar(Date date){
        if(date != null){
          panelDate.setTime(date);
          redrawPanel();
      public int getYear(){ return panelDate.get(Calendar.YEAR);}
      public String getMonthName(){
        switch(panelDate.get(Calendar.MONTH)){
        case Calendar.JANUARY: return "January";
        case Calendar.FEBRUARY: return "February";
        case Calendar.MARCH: return "March";
        case Calendar.APRIL: return "April";
        case Calendar.MAY: return "May";
        case Calendar.JUNE: return "June";
        case Calendar.JULY: return "July";
        case Calendar.AUGUST: return "August";
        case Calendar.SEPTEMBER: return "September";
        case Calendar.OCTOBER: return "October";
        case Calendar.NOVEMBER: return "November";
        case Calendar.DECEMBER: return "December";
        case Calendar.UNDECIMBER: return "Undecimber";
        default: return "Unknown";
      private void buildUI(){
        this.add(buildHeaderPanel(), BorderLayout.NORTH);
        daysPanel = new Panel(new GridBagLayout());
        redrawPanel();
        this.add(daysPanel, BorderLayout.CENTER);
      // build the part of the gui that contains the month and year
      // labels with their incrementors / decrementors
      private Panel buildHeaderPanel(){
        monthLabel = new Label(getMonthName(), Label.CENTER);
        yearLabel = new Label(Integer.toString(panelDate.get(Calendar.YEAR)),
                     Label.CENTER);
        GridBagConstraints gbc = new GridBagConstraints();
        Panel headerPanel = new Panel(new GridBagLayout());
        // month label and buttons
        Panel panel = new Panel(new GridBagLayout());
        Button button = new Button("-");
        button.setActionCommand("decrease month");
        button.addActionListener(this);
        gbc.anchor = GridBagConstraints.EAST;
        panel.add(button, gbc);
        gbc.anchor = GridBagConstraints.CENTER;
        panel.add(monthLabel, gbc);
        button = new Button("+");
        button.setActionCommand("increase month");
        button.addActionListener(this);
        gbc.anchor = GridBagConstraints.WEST;
        panel.add(button, gbc);
        gbc.anchor = GridBagConstraints.CENTER;
        gbc.weightx = 1;
        headerPanel.add(panel, gbc);
        // year label and buttons
        panel = new Panel(new GridBagLayout());
        button = new Button("-");
        button.setActionCommand("decrease year");
        button.addActionListener(this);
        gbc.anchor = GridBagConstraints.EAST;
        gbc.weightx = 0;
        panel.add(button, gbc);
        gbc.anchor = GridBagConstraints.CENTER;
        panel.add(yearLabel, gbc);
        button = new Button("+");
        button.setActionCommand("increase year");
        button.addActionListener(this);
        gbc.anchor = GridBagConstraints.WEST;
        panel.add(button, gbc);
        gbc.anchor = GridBagConstraints.CENTER;
        gbc.weightx = 1;
        headerPanel.add(panel, gbc);
        return headerPanel;
      // redraws the entire panel, including relaying out of
      // the days buttons
      private void redrawPanel(){
        monthLabel.setText(getMonthName());
        yearLabel.setText(Integer.toString(getYear()));
        // redraw days panel
        GridBagConstraints gbc = new GridBagConstraints();
        // clear current days panel
        daysPanel.removeAll();
        gbc.fill = GridBagConstraints.BOTH;
        gbc.gridx = 0;
        gbc.gridy = 0;
        gbc.weightx = 1;
        gbc.weighty = 1;
        // add days of week
        for(int i = 0; i < days.length; i++, gbc.gridx++)
          daysPanel.add(new Label(days, Label.CENTER), gbc);
    gbc.gridx = 0;
    gbc.gridy++;
    // days of month
    Button button; // day buttons
    JTable day = new JTable();
    Calendar today = Calendar.getInstance();
    Calendar cellDay = (Calendar)today.clone();
    int month = panelDate.get(Calendar.MONTH);
    int year = panelDate.get(Calendar.YEAR);
    // start with first of panels month
    cellDay.set(year, month, 1);
    gbc.gridx = cellDay.get(Calendar.DAY_OF_WEEK) - 1;
    while( cellDay.get(Calendar.MONTH) == month ){
    if(gbc.gridx > 6){
         gbc.gridy++;
         gbc.gridx = 0;
    button = new Button(Integer.toString(cellDay.get(Calendar.DATE)));
    button.addActionListener(this);
    if( cellDay.equals(today)){
         button.setForeground(Color.red);
    daysPanel.add(button, gbc);
    gbc.gridx++;
    cellDay.add(Calendar.DAY_OF_MONTH, 1);
    // re validate entire panel
    validate();
    // implementation of ActionListener interface
    // currently no real need to create subclassed action
    // events for calendar. All actions generated by this
    // are action events (generated from the buttons).
    // the action command will be one of the four below
    // or a number (the label of the day button!).
    public void actionPerformed(ActionEvent ae){
    String command = ae.getActionCommand();
    if(command.equals("increase month")){
    panelDate.add(Calendar.MONTH, 1);
    redrawPanel();
    } else if(command.equals("decrease month")){
    panelDate.add(Calendar.MONTH, -1);
    redrawPanel();
    } else if(command.equals("increase year")){
    panelDate.add(Calendar.YEAR, 1);
    redrawPanel();
    } else if(command.equals("decrease year")){
    panelDate.add(Calendar.YEAR, -1);
    redrawPanel();
    notifyCalendarListeners(ae);
    // methods for keeping track of interested listeners
    public void addCalendarActionListener(ActionListener al){
    if(al != null){
    if(calendarListeners == null) calendarListeners = new Vector();
    calendarListeners.addElement(al);
    public void removeCalendarActionListener(ActionListener al){
    if((calendarListeners != null) && (al != null)){
    calendarListeners.removeElement(al);
    private void notifyCalendarListeners(ActionEvent ae){
    if((calendarListeners != null) && (!calendarListeners.isEmpty())){
    java.util.Enumeration e = calendarListeners.elements();
    while(e.hasMoreElements())
         ((ActionListener)e.nextElement()).actionPerformed(ae);

    Hi,
    Sorry for the change of screen name, i'm having trouble with my old account.
    I have now got most of the system working. However I am having trouble working out how to stop the last days of the previous month appearing in the first week of the next month. For example on 'July 2008' , days 29 and 30 of June are present in the first week of July. How can i get rid of this? And also for the last week of the month, how to get rid of the first days of the next month?
    import java.awt.BorderLayout;
    import java.awt.Button;
    import java.awt.Color;
    import java.awt.Dimension;
    import java.awt.GridBagConstraints;
    import java.awt.GridBagLayout;
    import java.awt.GridLayout;
    import java.awt.Label;
    import java.awt.Panel;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.KeyEvent;
    import java.awt.event.KeyListener;
    import java.awt.event.MouseAdapter;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.Vector;
    import javax.swing.BorderFactory;
    import javax.swing.Box;
    import javax.swing.BoxLayout;
    import javax.swing.JButton;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JList;
    import javax.swing.JPanel;
    import javax.swing.JPopupMenu;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTextField;
    import javax.swing.border.Border;
    import javax.swing.border.EmptyBorder;
    import javax.swing.border.EtchedBorder;
    * @category CalendarSystem
    * @author Daniel Barrett
    public class CalendarSystem extends JPanel implements ActionListener, MouseListener, KeyListener   {
         JPanel events = new JPanel();
         JPanel action = new JPanel();
              //Events Panel
         DateComboBox eventDateChooser = new DateComboBox();
         JTextField ref = new JTextField(10);
         JTextArea eventDetails = new JTextArea();
         JScrollPane scrollingArea = new JScrollPane(eventDetails);
         JTextField dateF = new JTextField(15);
         JTextField timeF = new JTextField(15);
         String[] minutes = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23","24","25","26","27","28","29","30","31","32","33","34","35","36","37","38","39","40","41","42","43","44","45","46","47","48","49","50","51","52","53","54","55","56","57","58","59"};
         String[] hours = {"00","01","02","03","04","05","06","07","08","09","10","11","12","13","14","15","16","17","18","19","20","21","22","23"};
         JComboBox minsComb = new JComboBox(minutes);
         JComboBox hourComb = new JComboBox(hours);
              //Actions Panel
         JButton delete = new JButton("Delete");
         JButton purge = new JButton("Purge");
         JButton add = new JButton("Add");
         JButton edit = new JButton("Edit");
         JButton mview = new JButton("Month View");
         protected JLabel monthLabel;
         protected JLabel weekLabel;
         protected JLabel lmonday = new JLabel("");
         protected JLabel ltuesday = new JLabel("");
         protected JLabel lwednesday = new JLabel("");
         protected JLabel lthursday = new JLabel("");
         protected JLabel lfriday = new JLabel("");
         protected JLabel lsaturday = new JLabel("");
         protected JLabel lsunday = new JLabel("");
         protected Calendar calendar;
         protected SimpleDateFormat monthFormat = new SimpleDateFormat("MMM yyyy");
         protected SimpleDateFormat dayFormat = new SimpleDateFormat("MMM");
         JPanel monthCont = new JPanel();
         JPanel weekCont = new JPanel();
         JPanel yearCont = new JPanel();
         JPanel daysOfWeek = new JPanel();
         JPanel monday = new JPanel();
         JPanel tuesday = new JPanel();
         JPanel wednesday = new JPanel();
         JPanel thursday = new JPanel();
         JPanel friday = new JPanel();
         JPanel saturday = new JPanel();
         JPanel sunday = new JPanel();
         JList mondayEvents = new JList();
         JScrollPane mondayEventsScroll = new JScrollPane(mondayEvents);
         JList tuesdayEvents = new JList();
         JScrollPane tuesdayEventsScroll = new JScrollPane(tuesdayEvents);
         JList wednesdayEvents = new JList();
         JScrollPane wednesdayEventsScroll = new JScrollPane(wednesdayEvents);
         JList thursdayEvents = new JList();
         JScrollPane thursdayEventsScroll = new JScrollPane(thursdayEvents);
         JList fridayEvents = new JList();
         JScrollPane fridayEventsScroll = new JScrollPane(fridayEvents);
         JList saturdayEvents = new JList();
         JScrollPane saturdayEventsScroll = new JScrollPane(saturdayEvents);
         JList sundayEvents = new JList();
         JScrollPane sundayEventsScroll = new JScrollPane(sundayEvents);
         protected Color selectedBackground;
         protected Color selectedForeground;
         protected Color background;
         protected Color foreground;
         public CalendarSystem(){
              setupDays();
              setupHeaders();
              setupEvents();
              setupActions();
              this.calendar = Calendar.getInstance();
              this.calendar.setFirstDayOfWeek(Calendar.SUNDAY);
              this.add(this.monthCont);
              this.add(this.daysOfWeek);
              this.add(this.weekCont);
              this.add(this.events);
              this.add(this.action);
              this.setLayout(new BoxLayout(this,1));
              this.setMaximumSize(new Dimension(400,30));
              this.updateCalendar();
         private void setupActions() {
              this.action.setBorder(BorderFactory.createTitledBorder("Actions"));
              this.action.add(this.add);
              this.action.add(this.edit);
              this.action.add(this.delete);
              this.action.add(this.purge);
              this.action.add(this.mview);
         private void setupEvents() {
              this.events.setBorder(BorderFactory.createTitledBorder("Event Details"));
              this.events.setLayout(new BoxLayout(this.events,1));
              JPanel row1 = new JPanel();
              JPanel row2 = new JPanel();
              JPanel row3 = new JPanel();
              JLabel la = new JLabel("Reference");
              JLabel da = new JLabel("Date");
              JLabel time = new JLabel("Time");
              JLabel det = new JLabel("Details");
              this.ref.setEditable(false);
              this.dateF.setEditable(false);
              this.timeF.setEditable(false);
              this.eventDetails.setEditable(false);
              row1.add(la);
              row1.add(this.ref);
              row1.add(da);
              row1.add(this.dateF);
              row1.add(time);
              row1.add(this.timeF);
              row2.add(det);
              scrollingArea.setPreferredSize(new Dimension(600,50));
              row3.add(this.scrollingArea);
              this.events.add(row1);
              this.events.add(row2);
              this.events.add(row3);
         protected JLabel createUpdateButton(final int field, final int amount, final boolean month) {
             final JLabel label = new JLabel();
             final Border selectedBorder = new EtchedBorder();
             final Border unselectedBorder = new EmptyBorder(selectedBorder.getBorderInsets(new JLabel()));
             label.setBorder(unselectedBorder);
             label.setForeground(foreground);
             label.addMouseListener(new MouseAdapter() {
                  public void mouseReleased(MouseEvent e) {
                   calendar.add(field, amount);
                   if(month){
                   updateMCalendar();}
                   else{
                        updateCalendar();
                   public void mouseEntered(MouseEvent e) {
                   label.setBorder(selectedBorder);
                  public void mouseExited(MouseEvent e) {
                   label.setBorder(unselectedBorder);
             return label;
         private void updateMCalendar() {
              this.calendar.set(Calendar.DAY_OF_MONTH, 1);
              updateCalendar();     
         private void setupHeaders() {
              //MONTH CONTROLS
             monthCont.setLayout(new BoxLayout(monthCont, BoxLayout.X_AXIS));
             monthCont.setBackground(background);
             monthCont.setOpaque(true);
             JLabel label;
             label = createUpdateButton(Calendar.YEAR, -1,false);
             label.setText("<<");
             label.setToolTipText("Previous Year");
             monthCont.add(Box.createHorizontalStrut(12));
             monthCont.add(label);
             monthCont.add(Box.createHorizontalStrut(12));
             label = createUpdateButton(Calendar.MONTH, -1,true);
             label.setText("< ");
             label.setToolTipText("Previous Month");
             monthCont.add(label);
             monthLabel =new JLabel("", JLabel.CENTER);
             monthLabel.setForeground(foreground);
             //monthCont.add(Box.createHorizontalGlue());
             monthCont.add(Box.createHorizontalStrut(12));
             monthCont.add(monthLabel);
             monthCont.add(Box.createHorizontalStrut(12));
             //monthCont.add(Box.createHorizontalGlue());
             label =createUpdateButton(Calendar.MONTH, 1,true);
             label.setText(" >");
             label.setToolTipText("Next Month");
             monthCont.add(label);
             label = createUpdateButton(Calendar.YEAR, 1,false);
             label.setText(">>");
             label.setToolTipText("Next Year");
             monthCont.add(Box.createHorizontalStrut(12));
             monthCont.add(label);
             monthCont.add(Box.createHorizontalStrut(12));
             //WEEK CONTROLS
             weekCont.setLayout(new BoxLayout(weekCont, BoxLayout.X_AXIS));
             weekCont.setBackground(background);
             weekCont.setOpaque(true);
             JLabel label1;
             label1 = createUpdateButton(Calendar.WEEK_OF_MONTH, -1,false);
             label1.setText("<<");
             label1.setToolTipText("Previous Week");
             weekCont.add(label1);
             weekLabel =new JLabel("", JLabel.CENTER);
             weekLabel.setForeground(foreground);
             JLabel lweek =new JLabel("Week:  ", JLabel.CENTER);
             lweek.setForeground(foreground);
             //monthCont.add(Box.createHorizontalGlue());
             weekCont.add(Box.createHorizontalStrut(12));
             weekCont.add(lweek);
             weekCont.add(weekLabel);
             weekCont.add(Box.createHorizontalStrut(12));
             //monthCont.add(Box.createHorizontalGlue());
             label1 = createUpdateButton(Calendar.WEEK_OF_MONTH, 1,false);
             label1.setText(">>");
             label1.setToolTipText("Next Week");
             weekCont.add(label1);
         public void setupDays(){
              monday.setLayout(new BoxLayout(monday,1));
              tuesday.setLayout(new BoxLayout(tuesday,1));
              wednesday.setLayout(new BoxLayout(wednesday,1));
              thursday.setLayout(new BoxLayout(thursday,1));
              friday.setLayout(new BoxLayout(friday,1));
              saturday.setLayout(new BoxLayout(saturday,1));
              sunday.setLayout(new BoxLayout(sunday,1));
              monday.add(this.lmonday);
              monday.add(this.mondayEventsScroll);
              monday.setBorder(BorderFactory.createTitledBorder("Monday"));
              tuesday.add(this.ltuesday);
              tuesday.add(this.tuesdayEventsScroll);
              tuesday.setBorder(BorderFactory.createTitledBorder("Tuesday"));
              wednesday.add(this.lwednesday);
              wednesday.add(this.wednesdayEventsScroll);
              wednesday.setBorder(BorderFactory.createTitledBorder("Wednesday"));
              thursday.add(this.lthursday);
              thursday.add(this.thursdayEventsScroll);
              thursday.setBorder(BorderFactory.createTitledBorder("Thursday"));
              friday.add(this.lfriday);
              friday.add(this.fridayEventsScroll);
              friday.setBorder(BorderFactory.createTitledBorder("Friday"));
              saturday.add(this.lsaturday);
              saturday.add(this.saturdayEventsScroll);
              saturday.setBorder(BorderFactory.createTitledBorder("Saturday"));
              sunday.add(this.lsunday);
              sunday.add(this.sundayEventsScroll);
              sunday.setBorder(BorderFactory.createTitledBorder("Sunday"));
              this.mondayEventsScroll.setPreferredSize(new Dimension(90,200));
              this.monday.setPreferredSize(new Dimension(145,300));
              this.tuesdayEventsScroll.setPreferredSize(new Dimension(90,200));
              this.tuesday.setPreferredSize(new Dimension(145,300));
              this.wednesdayEventsScroll.setPreferredSize(new Dimension(90,200));
              this.wednesday.setPreferredSize(new Dimension(145,300));
              this.thursdayEventsScroll.setPreferredSize(new Dimension(90,200));
              this.thursday.setPreferredSize(new Dimension(145,300));
              this.fridayEventsScroll.setPreferredSize(new Dimension(90,200));
              this.friday.setPreferredSize(new Dimension(145,300));
              this.saturdayEventsScroll.setPreferredSize(new Dimension(90,200));
              this.saturday.setPreferredSize(new Dimension(145,300));
              this.sundayEventsScroll.setPreferredSize(new Dimension(90,200));
              this.sunday.setPreferredSize(new Dimension(145,300));
              daysOfWeek.add(this.sunday);
              daysOfWeek.add(this.monday);
              daysOfWeek.add(this.tuesday);
              daysOfWeek.add(this.wednesday);
              daysOfWeek.add(this.thursday);
              daysOfWeek.add(this.friday);
              daysOfWeek.add(this.saturday);
        private void updateCalendar() {
             monthLabel.setText(monthFormat.format(calendar.getTime()) );
             weekLabel.setText(String.valueOf(this.calendar.get(calendar.WEEK_OF_MONTH)));
             //Blank out / empty strings for first elements that do not start on sunday
             Calendar setupCalendar = (Calendar) calendar.clone();
             setupCalendar.set(Calendar.DAY_OF_WEEK, setupCalendar.getFirstDayOfWeek());
           // while(setupCalendar.get(Calendar.DAY_OF_WEEK) < calendar.getActualMaximum(Calendar.DAY_OF_WEEK)) {
                //System.out.println("day of month: " + setupCalendar.get(Calendar.DAY_OF_MONTH));
                //System.out.println("day of week: " + (setupCalendar.get(Calendar.DAY_OF_WEEK)));
                //System.out.println("week of month: " + calendar.get(Calendar.WEEK_OF_MONTH) + "\n");
                  setDayLabels(setupCalendar.get(Calendar.DAY_OF_MONTH),setupCalendar.get(Calendar.DAY_OF_WEEK));
                setupCalendar.set(Calendar.DAY_OF_WEEK, setupCalendar.get(Calendar.DAY_OF_WEEK) + 1);
                 setDayLabels(setupCalendar.get(Calendar.DAY_OF_MONTH),setupCalendar.get(Calendar.DAY_OF_WEEK));
                setupCalendar.set(Calendar.DAY_OF_WEEK, setupCalendar.get(Calendar.DAY_OF_WEEK) + 1);
                 setDayLabels(setupCalendar.get(Calendar.DAY_OF_MONTH),setupCalendar.get(Calendar.DAY_OF_WEEK));
                setupCalendar.set(Calendar.DAY_OF_WEEK, setupCalendar.get(Calendar.DAY_OF_WEEK) + 1);
                 setDayLabels(setupCalendar.get(Calendar.DAY_OF_MONTH),setupCalendar.get(Calendar.DAY_OF_WEEK));
                setupCalendar.set(Calendar.DAY_OF_WEEK, setupCalendar.get(Calendar.DAY_OF_WEEK) + 1);
                 setDayLabels(setupCalendar.get(Calendar.DAY_OF_MONTH),setupCalendar.get(Calendar.DAY_OF_WEEK));
                setupCalendar.set(Calendar.DAY_OF_WEEK, setupCalendar.get(Calendar.DAY_OF_WEEK) + 1);
                 setDayLabels(setupCalendar.get(Calendar.DAY_OF_MONTH),setupCalendar.get(Calendar.DAY_OF_WEEK));
                setupCalendar.set(Calendar.DAY_OF_WEEK, setupCalendar.get(Calendar.DAY_OF_WEEK) + 1);
                 setDayLabels(setupCalendar.get(Calendar.DAY_OF_MONTH),setupCalendar.get(Calendar.DAY_OF_WEEK));
        public void setDayLabels(int day, int dayOfWeek){
             if(dayOfWeek == 1){
                  this.lsunday.setText(String.valueOf(day));
             if(dayOfWeek == 2){
                  this.lmonday.setText(String.valueOf(day));
             if(dayOfWeek == 3){
                  this.ltuesday.setText(String.valueOf(day));
             if(dayOfWeek == 4){
                  this.lwednesday.setText(String.valueOf(day));
             if(dayOfWeek == 5){
                  this.lthursday.setText(String.valueOf(day));
             if(dayOfWeek == 6){
                  this.lfriday.setText(String.valueOf(day));
             if(dayOfWeek == 7){
                  this.lsaturday.setText(String.valueOf(day));
         @Override
         public void actionPerformed(ActionEvent arg0) {
         @Override
         public void mouseClicked(MouseEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void mouseEntered(MouseEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void mouseExited(MouseEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void mousePressed(MouseEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void mouseReleased(MouseEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void keyPressed(KeyEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void keyReleased(KeyEvent arg0) {
              // TODO Auto-generated method stub
         @Override
         public void keyTyped(KeyEvent arg0) {
              // TODO Auto-generated method stub
         public static void main(String args[]){
              JFrame frame = new JFrame();
              frame.setSize(1100, 670);
              frame.add(new CalendarSystem());
              frame.setVisible(true);
    }Thanks
    Dan

  • Help with understanding key event propagation

    Hello,
    I am hoping someone can help me understand a few things which are not clear to me with respect to handling of key events by Swing components. My understanding is summarized as:
    (1) Components have 3 input maps which map keys to actions
    one for when they are the focused component
    one for when they are an ancestor of the focused component
    one for when they are in the same window as the focused component
    (2) Components have a single action map which contains actions to be fired by key events
    (3) Key events go to the currently focused component
    (4) Key events are consumed by the first matching action that is found
    (5) Key events are sent up the containment hierarchy up to the window (in which case components with a matching mapping in the WHEN_IN_FOCUSED_WINDOW map are searched for)
    (6) The first matching action handles the event which does not propagate further
    I have a test class (source below) and I obtained the following console output:
    Printing keyboard map for Cancel button
    Level 0
    Key: pressed C
    Key: released SPACE
    Key: pressed SPACE
    Level 1
    Key: pressed SPACE
    Key: released SPACE
    Printing keyboard map for Save button
    Level 0
    Key: pressed SPACE
    Key: released SPACE
    Level 1
    Key: pressed SPACE
    Key: released SPACE
    Printing keyboard map for Main panel
    Event: cancel // typed SPACE with Cancel button having focus
    Event: save // typed SPACE with Save button having focus
    Event: panel // typed 'C' with panel having focus
    Event: panel // typed 'C' with Cancel button having focus
    Event: panel // typed 'C' with Save button having focus
    I do not understand the following aspects of its behaviour (tested on MacOSX although I believe the behaviour is not platform dependent):
    (1) I assume that the actions are mapped to SPACE since the spacebar clicks the focused component but I don't explicitly set it?
    (2) assuming (1) is as I described why are there two mappings, one for key pressed and one for key released yet the 'C' key action only has a key pressed set?
    (3) assuming (1) and (2) are true then why don't I get the action fired twice when I typed the spacebar, once when I pressed SPACE and again when I released SPACE?
    (4) I read that adding a dummy action with the value "none" (i.e. the action is the string 'none') should hide the underlying mappings for the given key, 'C' the my example so why when I focus the Cancel button and press the 'C' key do I get a console message from the underlying panel action (the last but one line in the output)?
    Any help appreciated. The source is:
    import javax.swing.*;
    public class FocusTest extends JFrame {
         public FocusTest ()     {
              initComponents();
              setTitle ("FocusTest");
              setLocationRelativeTo (null);
              setSize(325, 160);
              setVisible (true);
         public static void main (String[] args) {
              new FocusTest();
    private void initComponents()
         JPanel panTop = new JPanel();
              panTop.setBackground (java.awt.Color.RED);
    JLabel lblBanner = new javax.swing.JLabel ("PROPERTY TABLE");
    lblBanner.setFont(new java.awt.Font ("Lucida Grande", 1, 14));
    lblBanner.setHorizontalAlignment (javax.swing.SwingConstants.CENTER);
              panTop.add (lblBanner);
              JPanel panMain = new JPanel ();
              JLabel lblKey = new JLabel ("Key:");
              lblKey.setFocusable (true);
              JLabel lblValue = new JLabel ("Value:");
    JTextField tfKey = new JTextField(20);
    JTextField tfValue = new JTextField(20);
    JButton btnCancel = new JButton (createAction("cancel"));     // Add a cancel action.
    JButton btnSave = new JButton (createAction("save"));          // Add a sve action.
              panMain.add (lblKey);
              panMain.add (tfKey);
              panMain.add (lblValue);
              panMain.add (tfValue);
              panMain.add (btnCancel);
              panMain.add (btnSave);
              add (panTop, java.awt.BorderLayout.NORTH);
              add (panMain, java.awt.BorderLayout.CENTER);
    setDefaultCloseOperation (javax.swing.WindowConstants.EXIT_ON_CLOSE);
    // Add an action to the panel for the C key.
              panMain.getInputMap (JComponent.WHEN_IN_FOCUSED_WINDOW).put (KeyStroke.getKeyStroke (java.awt.event.KeyEvent.VK_C, 0), "panel");
              panMain.getActionMap ().put ("panel", createAction("panel"));
              // FAILS ???
              // Add an empty action to the Cancel button to block the underlying panel C key action.
    btnCancel.getInputMap().put (KeyStroke.getKeyStroke (java.awt.event.KeyEvent.VK_C, 0), "none");
    // Print out the input map contents for the Cancel and Save buttons.
    System.out.println ("\nPrinting keyboard map for Cancel button");
    printInputMaps (btnCancel);
    System.out.println ("\nPrinting keyboard map for Save button");
    printInputMaps (btnSave);
              // FAILS NullPointer because the map contents are null ???
    System.out.println ("\nPrinting keyboard map for Main panel");
    // printInputMaps (panMain);
    private AbstractAction createAction (final String actionName) {
         return new AbstractAction (actionName) {
              public void actionPerformed (java.awt.event.ActionEvent evt) {
                   System.out.println ("Event: " + actionName);
    private void printInputMaps (JComponent comp) {
         InputMap map = comp.getInputMap();
         printInputMap (map, 0);
    private void printInputMap (InputMap map, int level) {
         System.out.println ("Level " + level);
         InputMap parent = map.getParent();
         Object[] keys = map.allKeys();
         for (Object key : keys) {
              if (key.equals (parent)) {
                   continue;
              System.out.println ("Key: " + key);
         if (parent != null) {
              level++;
              printInputMap (parent, level);
    Thanks,
    Tim Mowlem

    Use the [url http://forum.java.sun.com/help.jspa?sec=formatting]Code Formatting Tags so the posted code retains its original formatting.
    1) In the Metal LAF the space bar activates the button. In the Windows LAF the Enter key is used to activate the button. Therefore these bindings are added by the LAF.
    2) The pressed binding paints the button in its pressed state. The released binding paint the button in its normal state. Thats why the LAF adds two bindings.
    In your case you only added a single binding.
    3) The ActionEvent is only fired when the key is released. Same as a mouse click. You can hold the mouse down as long as you want and the ActionEvent isn't generated until you release the mouse. In fact, if you move the mouse off of the button before releasing the button, the ActionEvent isn't even fired at all. The mouse pressed/released my be generated by the same component.
    4) Read (or reread) the [url http://java.sun.com/docs/books/tutorial/uiswing/misc/keybinding.html#howto]How to Remove Key Bindings section. "none" is only used to override the default action of a component, it does not prevent the key stroke from being passed on to its parent.

  • JAVA QUESTIONS HELP!!!!!

    Hi there im a student and have an exam on java coming up next week, i have a few past paper questions that im stuck with if anyone can help that would be great.....
    1.) Java implements generic types by erasure: what does this mean?
    A. The compiler removes references to parameter types and inserts casts wherever return types refer to parameter types.
    B. The programmer must comment out references to parameter types before code is compiled.
    C. The compiler removes any casts that may be type-unsafe. &#1048576;
    D. The compiler removes any references to parameter types and inserts references to the closest super class that will make expressions type-safe.
    E. Any type-unsafe casts to parameter types will be ignored by the interpreter at run-time.
    2.) In Remote method Invocation, what is meant by �marshalling�?
    A. Marshalling is the process of synchronizing all parameters to the method being invoked, in order to
    prevent data corruption arising from the concurrent method call. &#1048576;
    B. Marshalling is the process of sending a copy of the remote object to the client JVM in order to
    invoke its method locally. &#1048576;
    C. Marshalling is the process of sending the state of the client JVM on a byte stream to the remote
    object in order that the JVM can be started as a separate thread on the remote host. &#1048576;
    D. Marshalling is the process of suspending the current thread in the client JVM until a result is obtained
    from the remote method invocation. &#1048576;
    E. Marshalling is the process of sending the state of all parameter instances on a byte stream to the remote object.
    3.)What is the immediate superclass of javax.swing.JFrame?
    A. java.lang.Object &#1048576;
    B. javax.swing.Window &#1048576;
    C. javax.swing.JComponent &#1048576;
    D. java.AWT.Window &#1048576;
    E. java.AWT.Frame
    4.) What is the immediate superclass of javax.swing.JComponent?
    A. java.lang.Object &#1048576;
    B. java.AWT.Component &#1048576;
    C. java.AWT.Container &#1048576;
    D. java.AWT.Window &#1048576;
    E. javax.swing.Object
    5.) Which of the following statements about the java.AWT and javax.swing packages is true?
    A. All components in both packages are thread-safe&#1048576;
    B. Most components in both packages are thread-safe&#1048576;
    C. Most components in java.AWT are thread-safe, but most in javax.swing are not&#1048576;
    D. Most components in javax.swing are thread-safe, but most in java.AWT are not&#1048576;
    E. No components in either package are thread-safe&#1048576;
    6.) Which of the following best describes how AWT events are handled in Java?
    A. There is a special thread that handles all AWT events. &#1048576;
    B. Each AWT event causes a new thread to be created to handle that event. &#1048576;
    C. All AWT events are handled in the main thread. &#1048576;
    D. The programmer must explicitly create one thread to handle all AWT events. &#1048576;
    E. For each AWT event, the programmer must explicitly create a thread to handle that event. &#1048576;
    7.) Which of the following best describes how component-generated events can be handled in Java?
    A. All component-generated events are handled automatically by the Java interpreter. &#1048576;
    B. The programmer creates instances of appropriate listener classes, and registers these instances with
    the component; when the component generates an event, the relevant methods of all registered
    listeners are executed. &#1048576;
    C. The programmer creates instances of appropriate listener classes, and registers these instances with
    the component; when the component generates an event, one of the registered listeners is chosen by
    the interpreter and the relevant method of that instance is executed. &#1048576;
    D. The programmer must declare a subclass of the component and add one method for each type of
    event the component can generate; when the component generates an event, the appropriate method
    is executed. &#1048576;
    E. Each component class has event-handling methods; the programmer declares a subclass of the
    component and overrides those methods; when the component generates an event, the overridden
    method is executed. &#1048576;
    Any help would b great thanks guys. Andy

    1.) Java implements generic types by erasure: what
    does this mean?
    A. The compiler removes references to parameter types
    and inserts casts wherever return types refer to
    parameter types.
    B. The programmer must comment out references to
    parameter types before code is compiled.
    C. The compiler removes any casts that may be
    type-unsafe. &#1048576;
    D. The compiler removes any references to parameter
    types and inserts references to the closest super
    class that will make expressions type-safe.
    E. Any type-unsafe casts to parameter types will be
    ignored by the interpreter at run-time.None of the above (assuming this is not a Google translation of some non-English text).
    2.) In Remote method Invocation, what is meant by
    �marshalling�?
    A. Marshalling is the process of synchronizing all
    parameters to the method being invoked, in order to
    prevent data corruption arising from the concurrent
    method call. &#1048576;
    B. Marshalling is the process of sending a copy of
    the remote object to the client JVM in order to
    invoke its method locally. &#1048576;
    C. Marshalling is the process of sending the state of
    the client JVM on a byte stream to the remote
    object in order that the JVM can be started as a
    separate thread on the remote host. &#1048576;
    D. Marshalling is the process of suspending the
    current thread in the client JVM until a result is
    obtained
    from the remote method invocation. &#1048576;
    E. Marshalling is the process of sending the state of
    all parameter instances on a byte stream to the
    remote object.None of the above. Although there is one answer that at least describes how Marshalling is used.
    3.)What is the immediate superclass of
    javax.swing.JFrame?
    A. java.lang.Object &#1048576;
    B. javax.swing.Window &#1048576;
    C. javax.swing.JComponent &#1048576;
    D. java.AWT.Window &#1048576;
    E. java.AWT.FrameAt least this one does have the correct answer. It's in the API docs, so I guess it'd be hard to be wrong.
    4.) What is the immediate superclass ofDitto.
    5.) Which of the following statements about the
    java.AWT and javax.swing packages is true?
    A. All components in both packages are
    thread-safe&#1048576;
    B. Most components in both packages are
    thread-safe&#1048576;
    C. Most components in java.AWT are thread-safe, but
    most in javax.swing are not&#1048576;
    D. Most components in javax.swing are thread-safe,
    but most in java.AWT are not&#1048576;
    E. No components in either package are
    thread-safe&#1048576;Again, none of the above.
    6.) Which of the following best describes how AWT
    events are handled in Java?
    A. There is a special thread that handles all AWT
    events. &#1048576;
    B. Each AWT event causes a new thread to be created
    to handle that event. &#1048576;
    C. All AWT events are handled in the main thread.
    &#1048576;
    D. The programmer must explicitly create one thread
    to handle all AWT events. &#1048576;
    E. For each AWT event, the programmer must explicitly
    create a thread to handle that event. &#1048576;One answer is almost, sort of, correct. Wow.
    I can understand why you're having problems answering these questiosn. Well, there's no excuse for the questions that come out fo the Javadocs, but for the others ... it explains a lot about the quality of recent graduates.

  • Java course litterature choice

    Hello fellow Archers!
    I'm heading for uni this autumn to study Software Engineering.
    And my first coarse is on Java and I've had some troubles locating the books
    other than on e-shops. Which makes it hard to get a good impression about the
    books, so I've turned to my fellow archers in hope that someone here has
    used any of these books and can give me an opinion (:
    o  David J. Barnes and Michael Kölling, Objects First with Java; a
    practical introduction using BlueJ, third edition, isbn 0-13-197629-
    X, Prentice Hall, 2006. (2nd edition is also usable, but 3rd edition is
    preferred).
    o  John Lewis, William Loftus, Java Software Solutions: Foundations of
    Program Design: International Edition, 6/E, 0321549341 
    o  Walter Savitch, Absolute Java: International Edition, 3/E,
    0321505042
    o  Y. Daniel Liang, Introduction to Java Programming, Comprehensive:
    International Edition, 7/E, 013605966
    Since I've dabbled with Java in school some years ago, and been doing some
    other programming since I don't really need one that is first and foremost targeted to
    non-programmers but more for a book that I can have on my shelf/desk most of my
    time during my first year of uni.
    Thanks on beforehand!
    -- Sebastian

    sekre wrote:How is the book in terms of source code examples are there many/few, practical/strictly theoretical ?
    The book I had in High School were totally useless in terms of source code examples so you basically had to have a second book simply to look at some examples. Was kinda a bummer for our teacher
    I think there are a lot of examples. Not like on every page but definitely every other page. As far as how practical the examples are, I guess they get the point across of whatever he's trying to show .. they are fairly understandable.
    sekre wrote:How are the exercises if any in the book? Short and relevant or requiring more problem solving than `Hello World`-ish exercises?
    every chapter has exercises at the end (with solutions). They range from conceptual questions to actual programming assignments. There's a companion website that has solutions to the bigger coding problems. I've never really done any of them as the course that used the book had custom problems and didn't take the ones from the book.
    sekre wrote:And last question, at the beginning of new chapters do they early introduce you to some sourcecode for that specific chapter or do you have to read through 5-10 pages before you actually see some relevant code?  (Strongly prefer to see an implementation early since it helps me understand what I read)
    as far as Savitch's book is concerned, he usually dives right in with text in the beginning followed immediately by either diagrams or actual source code to illustrate what's going on.
    Like I said, I liked that book a lot and it's not "dry" or anything like that.
    There's nothing about reflection in this book and general design patterns are not really covered at all.
    I guess it does what it's supposed to do, i.e. get you started with Java(introduce you classes, methods, generics, exceptions, collections)
    this might help.. these are the chapters w/ page numbers where they start
    Ch. 01 - getting started 1
    Ch. 02 - console input and output 57
    Ch. 03 - flow of control 93
    Ch. 04 - defining classes I 163
    Ch. 05 - defining classes II 247
    Ch. 06 - arrays 333
    Ch. 07 - inheritance 413
    Ch. 08 - polymorphism and abstract classes 467
    Ch. 09 - exception handling 507
    Ch. 10 - file i/o 561
    Ch. 11 - recursion 633
    Ch. 12 - uml and patterns 671
    Ch. 13 - interfaces and inner classes 693
    Ch. 14 - generics and the arrayList class 739
    Ch. 15 - linked data structures 783
    Ch. 16 - collections, maps and iterators 881
    Ch. 17 - swing I 923
    Ch. 18 - swing II 1001
    Ch. 19 - java never ends... 1065

  • I have installed the latest version of iTunes for Windows 8 but when I try to open it, it says Windows has an error and I simply can't open it any longer.  Any help is appreciated!

    I have installed the latest version of iTunes for Windows 8 but when I try to open it, it says Windows has an error and I simply can't open it any longer.  Any help is appreciated!

    Hey socestlavie,
    Thanks for the question. I understand you are experiencing issues with iTunes for Windows. The following resource may help to resolve your issue:
    iTunes for Windows Vista, Windows 7, or Windows 8: Fix unexpected quits or launch issues
    http://support.apple.com/kb/TS1717
    Thanks,
    Matt M.

  • I would like to know which Sun Cert Java Course I should take ???

    I am a very good C programmer that is trying to learn Java programming.
    I know my way around all the various programming statements such as if-then-else, switch etc etc ...
    I know the basics of an Applet and a Stand Alone application ...
    I feel that I need some grounding on OO Technology ...
    I would like to learn JAVA from where I am ...
    I have also been reading up a lot on Java Programming lately ...
    I am more of an Intermediate programmer ...
    I have seen the Sun Certified Java courses web page and is quite confused by the many assortment of courses available ...
    I would like to ask which Java Course is right for me at my level of programming experiences ???
    Thanks in advance !!!
    Andy

    My limited understanding is that there are two main tests you can go for. The first is the Programmer certification, which tests your knowledge of the Java language itself, so you're asked questions about very specific things about the language syntax and such. I think these questions are stupid, because they serve no practical purpose, and some questions are more of a test of your memory.
    Then you can take the Developer certification, which is focused more on evaulating and writing programs.
    I haven't taken either, but there are some good resources for preparing for these tests.
    http://www.javaprepare.com/quests/test.html

  • About to fail Java..HELP

    Here's the story..I am horrable at Java. I took this class..I am having a lot of trouble and the teacher will not help me.. Here's my assignment..
    Write a program to compute mileage statistics for an automobile. Mr. Magoo has kept track of several tankfuls of gasoline by recording miles driven and gallons used for each tankful. Develop a Java application that will let Mr. Magoo input miles driven and gallons used (both ints) for each tankful and then display the miles per gallon obtained (a double). When Mr. Magoo enters -1 for miles, the program will display the total miles, total gallons, (both ints) and overall miles per gallon (a double, display rounded to 2 decimal places).Use a priming read similar to that found on page 4 of the Chap 4 handout. Continue processing input values until Mr. Magoo enters the sentinel value of -1. Use a message dialog at the start of the program that tells him what the valid input values are and what sentinel value to use to end processing. When Mr. Magoo enters an invalid amount (<= 0) for either value, there should be an error dialog box. Mr. Magoo might possibly enter two (or more) invalid amounts in a row! Make sure the program catches all invalid data.After Mr. Magoo enters the sentinel value, print out the totals. Invalid values are not included in the totals. There should be 1 information message which says "Valid miles and gallons are >0 and on the next line.."Enter -1 for miles to end processing" and then 1 box to enter mmiles, 1 to enter gallons, and an information message to say "MPG this tankful is: " TEST DATA:
         MILES     GALLONS
         155     6
         -300
         375     11
         284     8
         145     -5
         309     10
         -1
    heres my code which is very wrong, not complete and generated many errors:
    import javax.swing.JOptionPane;
    public class Mpg
    public static void main(String args[])
              String getMpg;
              double Mpg, gallons, miles;
              JOptionPane.INFORMATION_MESSAGE (null, "Valid miles and gallons are >0
              "\nEnter -1 for miles to end processing.");
              Mpg = Double.parseDouble(getMpg);
              Mpg = miles / gallons;
              JOptionPane.showInputDialog (null, "Number of miles: " + miles +","Results", JOptionPane.QUESTION_MESSAGE );
              JOptionPane.showInputDialog (null, "Number of gallons: " + gallons +", "Results", JOptionPane.QUESTION_MESSAGE );
              JOptionPane.showInputDialog (null, "MPG this tankful: " + Mpg +", "Results", JOptionPane.INFORMATION_MESSAGE );
              System.exit(0);
    I would be thankful for any help I can recieve. I have no idea how to make this program work. I am banging my head against walls!!!! Thanks Everyone!

    Hi,
    Whilst not agreeing with the tone of some of the messages the principle is correct up to a point.
    Anyway a little help is needed here :)
    Your program could be done in any language as its basically a procedural task. Lets look at that first.
    Your input screen - be it the command line or a JOptionPane must have a "switch" behind it that filters out unwanted input and only calls the mpg formula if the input is correct.
    To make the calculation you need to temporarily store two values "milestravelled" and "gallonsused"
    The input reciever should look for "milestravelled" first and when that has been correctly input ( > 0 ) it will treat the next input as "gallonsused".
    Once the two values are stores it should automatically - or by request - calculate the MPG figure and display it.
    Secondly, your code had some syntax errors I've corrected - there was an extra +" after the miles, gallons and Mpg variables
    JOptionPane.showInputDialog (null, "Number of miles: " + miles ,"Results", JOptionPane.QUESTION_MESSAGE );
    JOptionPane.showInputDialog (null, "Number of gallons: " + gallons , "Results", JOptionPane.QUESTION_MESSAGE );
    JOptionPane.showInputDialog (null, "MPG this tankful: " + Mpg , "Results", JOptionPane.INFORMATION_MESSAGE );
    Your information message declaration is not correct either. I suggest you check your syntax using the JDK documentation or your book.
    I hope that helps a little and will encourage you to work out the rest on your own.
    PS: Why are you using swing? A simple command line application would do fine for this task. Is it a course requirement or are you using a java development program to learn java. If its the second reason I think I can see why you're a bit lost. The IDE programs stick in a load of code that may not be necessary at all. The best way to learn is using the trusty JDK and notepad :)
    Bye

  • Can someone pls help me with java on my macbook pro because after i download the mountain lion java has died and i need java to see streaming quotes from stock market

    can someone pls help me with java on my macbook pro because after i download the mountain lion java has died and i need java to see streaming quotes from stock market

    Java is no longer included in Mac OS X by default. If you want Java, you will have to install it.
    However, note that you should think twice before installing Java for such a trivial need as looking at stock market quotes. There are other ways to get that information that don't involve Java, and using Java in your web browser is a HUGE security risk right now. Java has been vulnerable to attack almost constantly for the last year, and has become a very popular, frequently used method for getting malware installed via "drive-by downloads." You really, truly don't want to be using it. See:
    Java is vulnerable… Again?!
    http://java-0day.com

  • Urgent need of help with a java WSDL application

    Hello,
    I'm trying to turn a WORKING java application which uses some webservices, into a JAR file.
    Somehow i keep on getting the same errors all the time.
    I added all the necessary jar files, which are used in the program, in the global JAR file, but still the error remains.
    Can anyone help me with this error? (Error see below, WARNING EXTREMELY LONG!)
    ---------------------------------------------------------------- ERROR MESSAGE --------------------------------------------------------------------
    standard type mapping initialization error: javax.xml.rpc.JAXRPCException: javax
    .xml.soap.SOAPException: Unable to create SOAP Factory: Provider com.sun.xml.mes
    saging.saaj.soap.ver1_1.SOAPFactory1_1Impl not found
    at oracle.j2ee.ws.client.BasicService.createLiteralMappings(BasicService
    .java:282)
    at oracle.j2ee.ws.client.BasicService.createStandardTypeMappingRegistry(
    BasicService.java:244)
    at test.proxy.runtime.RegistrationWS_Service_SerializerRegistry.getRegis
    try(RegistrationWS_Service_SerializerRegistry.java:26)
    at test.proxy.runtime.RegistrationWS_Service_Impl.<init>(RegistrationWS_
    Service_Impl.java:26)
    at java.lang.Class.newInstanceImpl(Native Method)
    at java.lang.Class.newInstance(Class.java:1300)
    at oracle.j2ee.ws.client.ServiceFactoryImpl.createService(ServiceFactory
    Impl.java:92)
    at oracle.j2ee.ws.client.ServiceFactoryImpl.loadService(ServiceFactoryIm
    pl.java:121)
    at test.Main.test(Main.java:21)
    at test.Main.<init>(Main.java:10)
    at test.Main.main(Main.java:14)
    CAUSE:
    javax.xml.rpc.JAXRPCException: javax.xml.soap.SOAPException: Unable to create SO
    AP Factory: Provider com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl n
    ot found
    at oracle.j2ee.ws.client.BasicService.createLiteralMappings(BasicService
    .java:282)
    at oracle.j2ee.ws.client.BasicService.createStandardTypeMappingRegistry(
    BasicService.java:244)
    at test.proxy.runtime.RegistrationWS_Service_SerializerRegistry.getRegis
    try(RegistrationWS_Service_SerializerRegistry.java:26)
    at test.proxy.runtime.RegistrationWS_Service_Impl.<init>(RegistrationWS_
    Service_Impl.java:26)
    at java.lang.Class.newInstanceImpl(Native Method)
    at java.lang.Class.newInstance(Class.java:1300)
    at oracle.j2ee.ws.client.ServiceFactoryImpl.createService(ServiceFactory
    Impl.java:92)
    at oracle.j2ee.ws.client.ServiceFactoryImpl.loadService(ServiceFactoryIm
    pl.java:121)
    at test.Main.test(Main.java:21)
    at test.Main.<init>(Main.java:10)
    at test.Main.main(Main.java:14)
    Caused by: javax.xml.rpc.JAXRPCException: javax.xml.soap.SOAPException: Unable t
    o create SOAP Factory: Provider com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFacto
    ry1_1Impl not found
    at oracle.j2ee.ws.common.encoding.literal.LiteralFragmentSerializer.<ini
    t>(LiteralFragmentSerializer.java:95)
    at oracle.j2ee.ws.common.encoding.literal.LiteralFragmentSerializer.<ini
    t>(LiteralFragmentSerializer.java:62)
    at oracle.j2ee.ws.common.encoding.literal.StandardLiteralTypeMappings.<i
    nit>(StandardLiteralTypeMappings.java:198)
    at oracle.j2ee.ws.client.BasicService.createLiteralMappings(BasicService
    .java:280)
    ... 10 more
    Caused by: javax.xml.soap.SOAPException: Unable to create SOAP Factory: Provider
    com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl not found
    at javax.xml.soap.SOAPFactory.newInstance(SOAPFactory.java:33)
    at oracle.j2ee.ws.common.encoding.literal.LiteralFragmentSerializer.<ini
    t>(LiteralFragmentSerializer.java:93)
    ... 13 more
    CAUSE:
    javax.xml.rpc.JAXRPCException: javax.xml.soap.SOAPException: Unable to create SO
    AP Factory: Provider com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl n
    ot found
    at oracle.j2ee.ws.client.BasicService.createLiteralMappings(BasicService
    .java:282)
    at oracle.j2ee.ws.client.BasicService.createStandardTypeMappingRegistry(
    BasicService.java:244)
    at test.proxy.runtime.RegistrationWS_Service_SerializerRegistry.getRegis
    try(RegistrationWS_Service_SerializerRegistry.java:26)
    at test.proxy.runtime.RegistrationWS_Service_Impl.<init>(RegistrationWS_
    Service_Impl.java:26)
    at java.lang.Class.newInstanceImpl(Native Method)
    at java.lang.Class.newInstance(Class.java:1300)
    at oracle.j2ee.ws.client.ServiceFactoryImpl.createService(ServiceFactory
    Impl.java:92)
    at oracle.j2ee.ws.client.ServiceFactoryImpl.loadService(ServiceFactoryIm
    pl.java:121)
    at test.Main.test(Main.java:21)
    at test.Main.<init>(Main.java:10)
    at test.Main.main(Main.java:14)
    Caused by: javax.xml.rpc.JAXRPCException: javax.xml.soap.SOAPException: Unable t
    o create SOAP Factory: Provider com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFacto
    ry1_1Impl not found
    at oracle.j2ee.ws.common.encoding.literal.LiteralFragmentSerializer.<ini
    t>(LiteralFragmentSerializer.java:95)
    at oracle.j2ee.ws.common.encoding.literal.LiteralFragmentSerializer.<ini
    t>(LiteralFragmentSerializer.java:62)
    at oracle.j2ee.ws.common.encoding.literal.StandardLiteralTypeMappings.<i
    nit>(StandardLiteralTypeMappings.java:198)
    at oracle.j2ee.ws.client.BasicService.createLiteralMappings(BasicService
    .java:280)
    ... 10 more
    Caused by: javax.xml.soap.SOAPException: Unable to create SOAP Factory: Provider
    com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl not found
    at javax.xml.soap.SOAPFactory.newInstance(SOAPFactory.java:33)
    at oracle.j2ee.ws.common.encoding.literal.LiteralFragmentSerializer.<ini
    t>(LiteralFragmentSerializer.java:93)
    ... 13 more
    ---------------------------------------------------------------- ERROR MESSAGE --------------------------------------------------------------------

    I face this same problem too, I have a jar which calls a webservice and I want to execute it from windows command , I get the following error when I use the command : java -cp Has.jar moicr.Main
    standard type mapping initialization error: javax.xml.rpc.JAXRPCException: javax
    .xml.soap.SOAPException: Unable to create SOAP Factory: Provider com.sun.xml.mes
    saging.saaj.soap.ver1_1.SOAPFactory1_1Impl not found
    at oracle.j2ee.ws.client.BasicService.createLiteralMappings(BasicService
    .java:282)
    at oracle.j2ee.ws.client.BasicService.createStandardTypeMappingRegistry(
    BasicService.java:244)
    at has.proxy.runtime.JoPayWebServiceService_SerializerRegistry.getRegist
    ry(JoPayWebServiceService_SerializerRegistry.java:26)
    at has.proxy.runtime.JoPayWebServiceService_Impl.<init>(JoPayWebServiceS
    ervice_Impl.java:26)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
    orAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
    onstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
    at java.lang.Class.newInstance0(Class.java:350)
    at java.lang.Class.newInstance(Class.java:303)
    at oracle.j2ee.ws.client.ServiceFactoryImpl.createService(ServiceFactory
    Impl.java:92)
    at oracle.j2ee.ws.client.ServiceFactoryImpl.loadService(ServiceFactoryIm
    pl.java:121)
    at has.proxy.JoPayWebServiceClient.<init>(JoPayWebServiceClient.java:18)
    at moict.Main.confirmPayment(Main.java:142)
    at moict.Main.main(Main.java:93)
    CAUSE:
    javax.xml.rpc.JAXRPCException: javax.xml.soap.SOAPException: Unable to create SO
    AP Factory: Provider com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl n
    ot found
    at oracle.j2ee.ws.client.BasicService.createLiteralMappings(BasicService
    .java:282)
    at oracle.j2ee.ws.client.BasicService.createStandardTypeMappingRegistry(
    BasicService.java:244)
    at has.proxy.runtime.JoPayWebServiceService_SerializerRegistry.getRegist
    ry(JoPayWebServiceService_SerializerRegistry.java:26)
    at has.proxy.runtime.JoPayWebServiceService_Impl.<init>(JoPayWebServiceS
    ervice_Impl.java:26)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
    orAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
    onstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
    at java.lang.Class.newInstance0(Class.java:350)
    at java.lang.Class.newInstance(Class.java:303)
    at oracle.j2ee.ws.client.ServiceFactoryImpl.createService(ServiceFactory
    Impl.java:92)
    at oracle.j2ee.ws.client.ServiceFactoryImpl.loadService(ServiceFactoryIm
    pl.java:121)
    at has.proxy.JoPayWebServiceClient.<init>(JoPayWebServiceClient.java:18)
    at moict.Main.confirmPayment(Main.java:142)
    at moict.Main.main(Main.java:93)
    Caused by: javax.xml.rpc.JAXRPCException: javax.xml.soap.SOAPException: Unable t
    o create SOAP Factory: Provider com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFacto
    ry1_1Impl not found
    at oracle.j2ee.ws.common.encoding.literal.LiteralFragmentSerializer.<ini
    t>(LiteralFragmentSerializer.java:95)
    at oracle.j2ee.ws.common.encoding.literal.LiteralFragmentSerializer.<ini
    t>(LiteralFragmentSerializer.java:62)
    at oracle.j2ee.ws.common.encoding.literal.LiteralAnyElementSerializer.<i
    nit>(LiteralAnyElementSerializer.java:16)
    at oracle.j2ee.ws.common.encoding.literal.StandardLiteralTypeMappings.<i
    nit>(StandardLiteralTypeMappings.java:198)
    at oracle.j2ee.ws.client.BasicService.createLiteralMappings(BasicService
    .java:280)
    ... 14 more
    Caused by: javax.xml.soap.SOAPException: Unable to create SOAP Factory: Provider
    com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl not found
    at javax.xml.soap.SOAPFactory.newInstance(SOAPFactory.java:33)
    at oracle.j2ee.ws.common.encoding.literal.LiteralFragmentSerializer.<ini
    t>(LiteralFragmentSerializer.java:93)
    ... 18 more
    CAUSE:
    javax.xml.rpc.JAXRPCException: javax.xml.soap.SOAPException: Unable to create SO
    AP Factory: Provider com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl n
    ot found
    at oracle.j2ee.ws.client.BasicService.createLiteralMappings(BasicService
    .java:282)
    at oracle.j2ee.ws.client.BasicService.createStandardTypeMappingRegistry(
    BasicService.java:244)
    at has.proxy.runtime.JoPayWebServiceService_SerializerRegistry.getRegist
    ry(JoPayWebServiceService_SerializerRegistry.java:26)
    at has.proxy.runtime.JoPayWebServiceService_Impl.<init>(JoPayWebServiceS
    ervice_Impl.java:26)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
    orAccessorImpl.java:39)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
    onstructorAccessorImpl.java:27)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
    at java.lang.Class.newInstance0(Class.java:350)
    at java.lang.Class.newInstance(Class.java:303)
    at oracle.j2ee.ws.client.ServiceFactoryImpl.createService(ServiceFactory
    Impl.java:92)
    at oracle.j2ee.ws.client.ServiceFactoryImpl.loadService(ServiceFactoryIm
    pl.java:121)
    at has.proxy.JoPayWebServiceClient.<init>(JoPayWebServiceClient.java:18)
    at moict.Main.confirmPayment(Main.java:142)
    at moict.Main.main(Main.java:93)
    Caused by: javax.xml.rpc.JAXRPCException: javax.xml.soap.SOAPException: Unable t
    o create SOAP Factory: Provider com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFacto
    ry1_1Impl not found
    at oracle.j2ee.ws.common.encoding.literal.LiteralFragmentSerializer.<ini
    t>(LiteralFragmentSerializer.java:95)
    at oracle.j2ee.ws.common.encoding.literal.LiteralFragmentSerializer.<ini
    t>(LiteralFragmentSerializer.java:62)
    at oracle.j2ee.ws.common.encoding.literal.LiteralAnyElementSerializer.<i
    nit>(LiteralAnyElementSerializer.java:16)
    at oracle.j2ee.ws.common.encoding.literal.StandardLiteralTypeMappings.<i
    nit>(StandardLiteralTypeMappings.java:198)
    at oracle.j2ee.ws.client.BasicService.createLiteralMappings(BasicService
    .java:280)
    ... 14 more
    Caused by: javax.xml.soap.SOAPException: Unable to create SOAP Factory: Provider
    com.sun.xml.messaging.saaj.soap.ver1_1.SOAPFactory1_1Impl not found
    C:\>

  • Help with these java statements

    Can someone help me understand the following :
    "There are no errors but the loop terminates prematurely due to condition using the incorrect relational operator. The values of TotalVAT and TotalCosts will be 0.0."
    double[] Costs = {10.00, 20.00, 30.00, 15.00};double TotalCost = 0.0;double TotalVAT = 0.0;for (int Count = 0; Count > Costs.length; Count++) { double VAT = Costs[ Count ] * 0.175; TotalVAT = TotalVAT + VAT; TotalCost = TotalCost + Costs[ Count ] + VAT;}
    [\code]
    Thank you,

      double[] Costs = {10.00, 20.00, 30.00, 15.00};
      double TotalCost = 0.0;
      double TotalVAT = 0.0;
      for (int Count = 0; Count > Costs.length; Count++)
        double VAT = Costs[ Count ] * 0.175;
        TotalVAT = TotalVAT + VAT;
        TotalCost = TotalCost + Costs[ Count ] + VAT;
      }"the loop terminates prematurely" = the loop ends too early,
    it's not run as often as you think it would be. With loops that is
    often either once too few or not at all, in this case the latter.
    "due to condition using the incorrect relational operator" ->
    relational operators are operators that compare numbers (or other
    data), e.g. ==, !=, <, and >. There is only one relational operator
    here, it's >.
    For-loops work like this:
    for (init; cond; inc)
    init is the initialization, that's fine here: int Count = 0
    cond is a condition that has to be met everytime the loop starts from
    the beginning (not like in some other languages, where the condition is
    the one that will lead to the end of the loop). So here it checks
    whether Count > Costs.length is true and only then it will be executed.
    That's of course nonsense - you want to repeat that loop while Count is
    still less than Costs.length and you want to stop when it reaches
    Costs.length or goes above it, not the other way around. You loop will
    never execute at all! So simply replace the > with a <.
    (inc is the incrementation, that's fine here, too.)
    Say, who wrote that comment "There are no errors but the loop
    terminates prematurely due to condition using the incorrect relational
    operator. The values of TotalVAT and TotalCosts will be 0.0."? Was that
    a contest about being as verbose and ununderstandable as possible?
    A note: Only classes (and interfaces) start with capital letters. Use
    lower case letters for variables (and methods and packages): costs,
    totalCost, totalVAT, count, vat. (ALL CAPS are used for constants.)
    Hope this helps,
    Monika.

Maybe you are looking for

  • Impact of not having bank clearing account?

    My client doesn't want to use bank clearing account and wants to directly cr or dr the main bank account whenever a payment is received or made. Could you guys tell me what will be the impact of this, as I see reconciliation might be an issue.

  • Problem in setting image in setbouns  size

    hai to all iam new to core java i created an application with 4 fields and 1 button name is browse. my problem is image i want to set full image within specified setbounds it is possible in core java thanks please help me

  • Performance monitor - System performance does not start work?

    When I right click it to start it does nothing, and I can't stop it either by right clicking it.

  • Printing Labels in Illustrator 3

    I have just loaded Illustrator 3 and don't think i'll have too many problems creating designs but, how on earth do i print my labels to avery stock. I have tried exporting but can't figure it out - do i need to buy more software? Please help!!!!! Jen

  • ACR 4.4, ACR 3.3...What does the "ACR" stand for ?

    In the Camera Calibration tab in Camera Raw or Lightroom, we can choose the profile from the menu. There are so many profiles in the menu, ACR 4.4, ACR 3.3...What does the "ACR" stand for ?