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:\>

Similar Messages

  • Hello, im new to mac and I need some help with a java problem.

    Hello, im new to mac. I just need someone who can help with a problem ive come across when playing online games that run java. The game is arcanists. its on the funorb website. really fun game and i love it, but i cant play it without my screen keep scrolling or my character not responding at all. please get back at me ASAP. thx apple friends!

    FF has an extention that can be used to increase the conection speed. Its called Tweak Network 1.1 I see a difference on my iMac G5. Its not huge but it may be a big difference on yours.
    http://www.bitstorm.org/extensions/tweak/

  • Urgently need some help with a few Swing questions

    Hi
    I'm hoping someone can help me, I need to get these problems fixed very soon or I'm in trouble.
    Scenario: I have a JTreeTable inside a JScrollPane inside a JPanel that is inside a JFrame.
    Problems I'm having (solutions or help with any of all would be greatly appreciated):
    1. I'm trying to make it possible to do a selection in the JTreeTable by right-clicking the mouse (as well as the normal left click), but only if there is nothing currently selected, so I do something like this:
            int[] sel = treeTable.getSelectedRows();
            if ((sel == null) || (sel.length == 0)) {
                treeTable.setColumnSelectionAllowed(false);
                treeTable.setRowSelectionAllowed(true);
                treeTable.setRowSelectionInterval(0, 0);            // but I don't know what these values should be set to, where to get them from?
            }I want to select the row at the mouse cursor, I have the x/y values but I don't know how to relate them to the row index. The full feature that I require is I need
    2. I have a popup menu that appears after a right click on the JTreeTable, it's handled by a MouseListener attached to the JTreeTable, I want this to also appear anywhere else in the JScrollpane. I've tried moving the MouseListener to the JScrollPane, but then the popup stops working if user clicks inside JTreeTable, if I add it to both, it almost works, except that user cannot click below the JTreeTable's first column. Any ideas on this?
    3. How can I change the JTreeTable selection behaviour so that you can only multi-select using Ctrl/Shift and not the mouse? Mouse must only allow single connection, I'm currently using:
    treeTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);But this allows mouse drag selection as well, which shouldn't be there. How is this avoidable?
    4. I want to make the minimize button to make an icon in system tray and be able to restore it by clicking on it. Also I want to be able to minimze from a popup menu, I've currently got the following:
            thisApp.getMainFrame().setState(Frame.ICONIFIED);
            thisApp.getMainFrame().setVisible(false);
            thisApp.getMainFrame().pack();
            try {
               tray.add(trayIcon);
            } catch (AWTException ex) {
            }thisApp is a copy of the SingleFrameApplication variable that is passed to the main frame constructor (main frame extends FrameView). This code above doesn't do anything except create the tray icon. If I click on the tray icon (code below) then it opens up a blank window:
            trayIcon.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                    thisApp.getMainFrame().setVisible(true);
                    thisApp.getMainFrame().setState(Frame.NORMAL);
                    thisApp.getMainFrame().pack();
                    tray.remove(trayIcon);
            });I need to get this part fixed and I optionally also want to bind this behaviour to the normal minimize button.
    Please, please help!
    Lionel

    Issue 2 has been solved, was an error in the MouseListener code.

  • I need some help with my java game using applets, CAN SOMEBODY PLEASE HELP

    Hi,
    I am in the process of creating a RPG program using Java. I am not very experienced with java, however the problem i am currently facing is something i can't seem to figure out. I would like to draw a simple grid where a character (indicated by a filled circle) moves around this grid collecting items (indicated by a red rectangle). When the character moves on top of the grid with the item, i would like it to disappear. Right now i am not worrying about the fact that the item will reappear after the character moves away again, because sometimes, when the character moves over the item, nothing happens/another item disappears. i have been at this for 4 days and still cannot figure out what is goign on. can somebody please help me? it would be most appreciated.
    Thanks
    PS if i needed to send you my code, how do i do it?

    Thank you for replying.
    The thing is, I am taking java as a course, and it is necessary for me to start off this way (this is for my summative evaluation). i agree with you on the fact, however, that i should go in small steps. i have been doing that until this point, and my frustration caused me to jump around randomly for an answer. I also think that it may just be a bug, but i have no clue as to how to fix it, as i need to show my teacher at least a part of what i was doing by sometime next week. Here is my code for anybody willing to go through it:
    // The "Keys3" class.
    import java.applet.*;
    import java.awt.*;
    import java.awt.Event;
    import java.awt.Font;
    import java.awt.Color;
    import java.applet.AudioClip;
    public class Keys3 extends java.applet.Applet
        char currkey;
        int currx, curry, yint, xint;
        int itmval [] = new int [5],
            locval [] = new int [5],
            tempx [] = new int [5], tempy [] = new int [5],
            tot = 0, score = 0;
        boolean check = true;
        AudioClip bgSound, bgSound2;
        AudioClip hit;
        private Image offscreenImage;
        private Graphics offscreen;     //initializing variables for double buffering
        public void init ()  //DONE
            bgSound = getAudioClip (getCodeBase (), "sound2_works.au");
            hit = getAudioClip (getCodeBase (), "ah_works.au");
            if (bgSound != null)
                bgSound.loop ();
            currx = 162;
            curry = 68;
            setBackground (Color.white);
            for (int count = 0 ; count < 5 ; count++)
                itmval [count] = (int) (Math.random () * 5) + 1;
                locval [count] = (int) (Math.random () * 25) + 1;
            requestFocus ();
        public void paint (Graphics g)  //DONE
            resize (350, 270);
            drawgrid (g);
            if (check = true)
                pickitems (g);
                drawitems (g);
            g.setColor (Color.darkGray);
            g.fillOval (currx, curry, 25, 25);
            if (currkey != 0)
                g.setColor (Color.darkGray);
                g.fillOval (currx, curry, 25, 25);
            if (collcheck () != true)
                collision (g);
            else
                drawitems (g);
        } // paint method
        public void update (Graphics g)  //uses the double buffering method to overwrite the original
                                         //screen with another copy to reduce flickering
            if (offscreenImage == null)
                offscreenImage = createImage (this.getSize ().width, this.getSize ().height);
                offscreen = offscreenImage.getGraphics ();
            } //what to do if there is no offscreenImage copy of the original screen
            //draws the backgroudn colour of the offscreen
            offscreen.setColor (getBackground ());
            offscreen.fillRect (0, 0, this.getSize ().width, this.getSize ().height);
            //draws the foreground colour of the offscreen
            offscreen.setColor (getForeground ());
            paint (offscreen);
            //draws the offscreen image onto the main screen
            g.drawImage (offscreenImage, 0, 0, this);
        public boolean keyDown (Event evt, int key)  //DONE
            switch (key)
                case Event.DOWN:
                    curry += 46;
                    if (curry >= 252)
                        curry -= 46;
                        if (hit != null)
                            hit.play ();
                    break;
                case Event.UP:
                    curry -= 46;
                    if (curry <= 0)
                        curry += 46;
                        if (hit != null)
                            hit.play ();
                    break;
                case Event.LEFT:
                    currx -= 66;
                    if (currx <= 0)
                        currx += 66;
                        if (hit != null)
                            hit.play ();
                    break;
                case Event.RIGHT:
                    currx += 66;
                    if (currx >= 360)
                        currx -= 66;
                        if (hit != null)
                            hit.play ();
                    break;
                default:
                    currkey = (char) key;
            repaint ();
            return true;
        public boolean collcheck ()  //DONE
            if (((currx == tempx [0]) && (curry == tempy [0])) || ((currx == tempx [1]) && (curry == tempy [1])) || ((currx == tempx [2]) && (curry == tempy [2])) || ((currx == tempx [3]) && (curry == tempy [3])) || ((currx == tempx [4]) && (curry == tempy [4])))
                return false;
            else
                return true;
        public void collision (Graphics g)
            drawgrid (g);
            for (int count = 0 ; count < 5 ; count++)
                if ((currx == tempx [count]) && (curry == tempy [count]))
                    g.setColor (Color.darkGray);
                    g.fillOval (currx, curry, 25, 25);
                else if ((currx != tempx [count]) && (curry != tempy [count]))
                    g.setColor (Color.red);
                    g.fillRect (tempx [count], tempy [count], 25, 25);
        public void drawitems (Graphics g)
            for (int count = 0 ; count < 5 ; count++)
                g.setColor (Color.red);
                g.fillRect (tempx [count], tempy [count], 25, 25);
        public void pickitems (Graphics g)
            check = false;
            for (int count = 0 ; count < 5 ; count++)
                if (locval [count] <= 5)
                    tempy [count] = 22;
                else if (locval [count] <= 10)
                    tempy [count] = 68;
                else if (locval [count] <= 15)
                    tempy [count] = 114;
                else if (locval [count] <= 20)
                    tempy [count] = 160;
                else if (locval [count] <= 25)
                    tempy [count] = 206; //this determines the y-position of the item to be placed
                if (locval [count] % 5 == 0)
                    tempx [count] = 294;
                else if ((locval [count] == 1) || (locval [count] == 6) || (locval [count] == 11) || (locval [count] == 16) || (locval [count] == 21))
                    tempx [count] = 30;
                else if ((locval [count] == 2) || (locval [count] == 7) || (locval [count] == 12) || (locval [count] == 17) || (locval [count] == 22))
                    tempx [count] = 96;
                else if ((locval [count] == 3) || (locval [count] == 8) || (locval [count] == 13) || (locval [count] == 18) || (locval [count] == 23))
                    tempx [count] = 162;
                else if ((locval [count] == 4) || (locval [count] == 9) || (locval [count] == 14) || (locval [count] == 19) || (locval [count] == 24))
                    tempx [count] = 228;
        public void drawgrid (Graphics g)  //DONE
            g.drawRect (10, 10, 330, 230); //draws the outer rectangular border
            int wi = 10; //width of one square on the board
            int hi = 10; //height of one square on the board
            for (int height = 1 ; height <= 5 ; height++)
                for (int row = 1 ; row <= 5 ; row++)
                    if (((height % 2 == 1) && (row % 2 == 1)) || ((height % 2 == 0) && (row % 2 == 0)))
                        g.setColor (Color.gray);
                        g.fillRect (wi, hi, 66, 46);
                    else /*if (((height % 2 == 0) && (row % 2 == 1)) || ((height % 2 == 0) && (row % 2 == 0)))*/
                        g.setColor (Color.lightGray);
                        g.drawRect (wi, hi, 66, 46);
                        g.setColor (Color.lightGray);
                        g.drawRect (wi, hi, 66, 46); //drawn twice to make a shadow effect
                    wi += 66;
                wi = 10;
                hi += 46;
            } //this draws the basic outline of the game screen
    } // Keys3 class

  • Urgent need of help with a chat application!

    Hi,
    I'm writing a Chat Application and I want to add Emoticon, I did so by adding buttons but I don't know how to send the gif to my JTextField and to my JTextArea.
    Here is part of my code can someone can help me PLEASE!!!
    JPanel chatPane = new JPanel(new BorderLayout());
    JPanel emoticon = new JPanel(new GridLayout(2, 5));
    b1 = new JButton (sourrire);
    b1.setToolTipText("Un Sourire");
    // b1.addActionListener();
    emoticon.add(b1);
    b2 = new JButton (gsourrire);
    b2.setToolTipText("Un Grand Sourire");
    // b2.addActionListener();
    emoticon.add(b2);
    b3 = new JButton (triste);
    b3.setToolTipText("Triste");
    // b3.addActionListener();
    emoticon.add(b3);
    b4 = new JButton (grimace);
    b4.setToolTipText("Grimace");
    // b4.addActionListener();
    emoticon.add(b4);
    b5 = new JButton (pleure);
    b5.setToolTipText("Pleure");
    // b5.addActionListener();
    emoticon.add(b5);
    b6 = new JButton (bec);
    b6.setToolTipText("Un bec");
    // b6.addActionListener();
    emoticon.add(b6);
    b7 = new JButton (coeur);
    b7.setToolTipText("Un coeur pour toi");
    // b7.addActionListener();
    emoticon.add(b7);
    b8 = new JButton (fache);
    b8.setToolTipText("Fache");
    // b8.addActionListener();
    emoticon.add(b8);
    b9 = new JButton (lunettes);
    b9.setToolTipText("Je suis Cool");
    // b9.addActionListener();
    emoticon.add(b9);
    b10 = new JButton (clinoeil);
    b10.setToolTipText("Clin d'Oeil");
    //b10.addActionListener(new ActionAdapter2());
    emoticon.add(b10);
    Thanks a lot!
    Isabelle

    Hi anoopjain13
    what I did is that each button is an IconImage and I was trying to send the Icon to the textfield.
    here is the complete code of my chat, you'll understand better what I tried to do.
    //Naziha Berrassil et Isabelle Gosselin
    //Travail Pratique #1
    //remis � Said Senhaji
    //Developpement d'une application CHAT
    //package chatv2.a
    import java.lang.*;
    import java.util.*;
    import java.io.*;
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import java.net.*;
    public class TCPChat2a implements Runnable {
    // Constantes de l'etat de la connection
    public final static int NULL = 0;
    public final static int DISCONNECTED = 1;
    public final static int DISCONNECTING = 2;
    public final static int BEGIN_CONNECT = 3;
    public final static int CONNECTED = 4;
    // Declaration d'un tableau de chaines
    public final static String statusMessages[] = {
    " Erreur! Aucune connexion possible!", " Deconnexion",
    " Deconnexion en cours...", " Connexion en cours...", " Connexion"
    //Instentiation de la classe
    public final static TCPChat2a tcpObj = new TCPChat2a();
    // Indique la fin d'une session
    public final static String END_CHAT_SESSION =
    new Character((char)0).toString();
    // Informations sur l'etat de la connexion
    public static String hostIP = "localhost";
    public static String user = "";
    public static String s1;
    public static int port = 1234;
    public static int connectionStatus = DISCONNECTED;
    public static boolean isHost = true;
    public static String statusString = statusMessages[connectionStatus];
    public static StringBuffer toAppend = new StringBuffer("");
    public static StringBuffer toSend = new StringBuffer("");
    // Declaration des composantes GUI et initialisation
    public final static ImageIcon sourrire = new ImageIcon ("icons/sourrire.gif");
    public static JButton b1;
    public final static ImageIcon gsourrire = new ImageIcon ("icons/grand_sourrire.gif");
    public static JButton b2;
    public final static ImageIcon triste = new ImageIcon ("icons/triste.gif");
    public static JButton b3;
    public final static ImageIcon pleure = new ImageIcon ("icons/pleure.gif");
    public static JButton b4;
    public final static ImageIcon coeur = new ImageIcon ("icons/coeur.gif");
    public static JButton b5;
    public final static ImageIcon grimace = new ImageIcon ("icons/grimace.gif");
    public static JButton b6;
    public final static ImageIcon lunettes = new ImageIcon ("icons/lunettes.gif");
    public static JButton b7;
    public final static ImageIcon fache = new ImageIcon ("icons/fache.gif");
    public static JButton b8;
    public final static ImageIcon bec = new ImageIcon ("icons/bec.gif");
    public static JButton b9;
    public final static ImageIcon clinoeil = new ImageIcon ("icons/clinoeil.gif");
    public static JButton b10;
    public static JFrame mainFrame = null;
    public static JTextArea chatText = null;
    public static JTextField chatLine = null;
    public static JPanel statusBar = null;
    public static JLabel statusField = null;
    public static JTextField statusColor = null;
    public static JTextField ipField = null;
    public static JTextField username = null;
    public static JTextField portField = null;
    public static JRadioButton hostOption = null;
    public static JRadioButton guestOption = null;
    public static JButton connectButton = null;
    public static JButton disconnectButton = null;
    // Declaration des composantes TCP
    public static ServerSocket hostServer = null;
    public static Socket socket = null;
    public static BufferedReader in = null;
    public static PrintWriter out = null;
    //Methode qui retourne le premier pannel(optionsPane),ce dernier
    //se compose de 5 panneaux
    private static JPanel initOptionsPane() {
    //pannel pane qui sera ajout� au pannel optionsPane
    JPanel pane = null;
    //initiation de la classe ActionAdapteur qui implemente ActionListner
    ActionAdapter buttonListener = null;
    // Creation du pannel optionsPane
    JPanel optionsPane = new JPanel(new GridLayout(5, 1));
    // 1er pannel pane pour label et textfield de l'adresse IP
    pane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    pane.add(new JLabel("Serveur IP:"));
    ipField = new JTextField(10);
    ipField.setBackground(new Color(0.98f, 0.97f, 0.85f));
    ipField.setText(hostIP);
    ipField.setEnabled(false);
    //evenement generer par Component avec la methode addFocusListener
    //en cas d'obtention ou perte du focus par un composant
    ipField.addFocusListener(new FocusAdapter() {
    public void focusLost(FocusEvent e) {
    ipField.selectAll();
    //Editable seulement en mode deconnexion
    if (connectionStatus != DISCONNECTED) {
    changeStatusNTS(NULL, true);
    else {
    hostIP = ipField.getText();
    pane.add(ipField);
    optionsPane.add(pane);
    // 2eme pannel pane pour label et textfield du port
    pane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    pane.add(new JLabel("Port:"));
    portField = new JTextField(10);
    portField.setBackground(new Color(0.98f, 0.97f, 0.85f));
    portField.setEditable(true);
    portField.setText((new Integer(port)).toString());
    portField.addFocusListener(new FocusAdapter() {
    public void focusLost(FocusEvent e) {
    //Textfield du port modifiable si on est en mode deconnexion
    if (connectionStatus != DISCONNECTED) {
    changeStatusNTS(NULL, true);
    else {
    int temp;
    try {
    temp = Integer.parseInt(portField.getText());
    port = temp;
    catch (NumberFormatException nfe) {
    portField.setText((new Integer(port)).toString());
    mainFrame.repaint();
    pane.add(portField);
    optionsPane.add(pane);
    // 3eme pannel pour label et textfield du nom d'utilisateur
         pane = new JPanel(new FlowLayout(FlowLayout.RIGHT));
              pane.add(new JLabel("Nom: "));
              username = new JTextField(10);
    username.setBackground(new Color(0.98f, 0.97f, 0.85f));
              username.setText(user);
              username.setEnabled(true);
              username.addFocusListener(new FocusAdapter() {
              public void focusLost(FocusEvent e) {
              // username.selectAll();
              // Should be editable only when disconnected
              if (connectionStatus != DISCONNECTED) {
              changeStatusNTS(NULL, true);
              else {
              user = username.getText();
              pane.add(username);
    optionsPane.add(pane);
    // Host/guest option
    buttonListener = new ActionAdapter() {
    public void actionPerformed(ActionEvent e) {
    if (connectionStatus != DISCONNECTED) {
    changeStatusNTS(NULL, true);
    else {
    isHost = e.getActionCommand().equals("host");
    // Cannot supply host IP if host option is chosen
    if (isHost) {
    ipField.setEnabled(false);
    ipField.setText("localhost");
    hostIP = "localhost";
    else {
    ipField.setEnabled(true);
    //creation de boutton groupe radio(serveur et invite)
    ButtonGroup bg = new ButtonGroup();
    hostOption = new JRadioButton("Serveur", true);
    hostOption.setMnemonic(KeyEvent.VK_S);
    hostOption.setActionCommand("host");
    hostOption.addActionListener(buttonListener);
    guestOption = new JRadioButton("Invite", false);
    guestOption.setMnemonic(KeyEvent.VK_I);
    guestOption.setActionCommand("invite");
    guestOption.addActionListener(buttonListener);
    bg.add(hostOption);
    bg.add(guestOption);
    // 4eme pannel pane pour les 2 bouttons radio
    pane = new JPanel(new GridLayout(1, 2));
    pane.add(hostOption);
    pane.add(guestOption);
    optionsPane.add(pane);
    // 5eme pannel buttonPane pour les bouttons de connexion et deconnexion
    JPanel buttonPane = new JPanel(new GridLayout(1, 2));
    buttonListener = new ActionAdapter() {
    public void actionPerformed(ActionEvent e) {
    // requete pou debut d'une connexion
    if (e.getActionCommand().equals("connect")) {
    changeStatusNTS(BEGIN_CONNECT, true);
    // Deconnexion
    else {
    changeStatusNTS(DISCONNECTING, true);
    //creation des bouttons dans le pannel et l'ajout au premier pannel
    //(optionsPane)
    connectButton = new JButton("Connexion");
    connectButton.setMnemonic(KeyEvent.VK_C);
    connectButton.setActionCommand("connect");
    connectButton.addActionListener(buttonListener);
    connectButton.setEnabled(true);
    disconnectButton = new JButton("Deconnexion");
    disconnectButton.setMnemonic(KeyEvent.VK_D);
    disconnectButton.setActionCommand("disconnect");
    disconnectButton.addActionListener(buttonListener);
    disconnectButton.setEnabled(false);
    buttonPane.add(connectButton);
    buttonPane.add(disconnectButton);
    optionsPane.add(buttonPane);
    return optionsPane;
    // Initialisation de toutes les composantes GUI et affichage du frame
    private static void initGUI() {
    // Configuration du status bar
    // cr�ation d'un autre pannel statusBar qui se compose d'un petit carr�
    // color� et un label indiquant le mode de connexion
    statusField = new JLabel(); //Label indiquant l'�tat de la connexion
    statusField.setText(statusMessages[DISCONNECTED]);
    statusColor = new JTextField(1); //carr� color� indiquant l'�tat de la connection grace a des couleurs
    statusColor.setBackground(Color.red);
    statusColor.setEditable(false);
    statusBar = new JPanel(new BorderLayout());
    statusBar.add(statusColor, BorderLayout.WEST);
    statusBar.add(statusField, BorderLayout.CENTER);
    // Configuration du pannel optionsPane en appelant la methode d'initiation
    // de ce dernier
    JPanel optionsPane = initOptionsPane();
    // Creation et configuration du pannel chatPane qui contient un
    // textarea au centre avec une barre defilante verticale et un textfield
    // au sud pour faire rentrer les messages
    JPanel chatPane = new JPanel(new BorderLayout());
         JPanel emoticon = new JPanel(new GridLayout(2, 5));
    b1 = new JButton (sourrire);
    b1.setToolTipText("Un Sourire");
    // b1.addActionListener();
    emoticon.add(b1);
    b2 = new JButton (gsourrire);
    b2.setToolTipText("Un Grand Sourire");
    // b2.addActionListener();
    emoticon.add(b2);
    b3 = new JButton (triste);
    b3.setToolTipText("Triste");
    // b3.addActionListener();
    emoticon.add(b3);
    b4 = new JButton (grimace);
    b4.setToolTipText("Grimace");
    // b4.addActionListener();
    emoticon.add(b4);
    b5 = new JButton (pleure);
    b5.setToolTipText("Pleure");
    // b5.addActionListener();
    emoticon.add(b5);
    b6 = new JButton (bec);
    b6.setToolTipText("Un bec");
    // b6.addActionListener();
    emoticon.add(b6);
    b7 = new JButton (coeur);
    b7.setToolTipText("Un coeur pour toi");
    // b7.addActionListener();
    emoticon.add(b7);
    b8 = new JButton (fache);
    b8.setToolTipText("Fache");
         // b8.addActionListener();
         emoticon.add(b8);
    b9 = new JButton (lunettes);
    b9.setToolTipText("Je suis Cool");
    // b9.addActionListener();
    emoticon.add(b9);
    b10 = new JButton (clinoeil);
    b10.setToolTipText("Clin d'Oeil");
    //b10.addActionListener(new ActionAdapter2());
    emoticon.add(b10);
    emoticon.addActionListener(new ActionAdapter() {
    public void actionPerformed(ActionEvent e) {
                             String image = chatLine.setImage().toString();
                             appendToChatBox(image);
                             chatLine.selectAll();
                             sendString(image)
                             chatLine.setText(" ");
    emoticon.setVisible(true);
    //b1 = setVisible(true);
    chatText = new JTextArea(10, 100);
    chatText.setBackground(new Color(0.98f, 0.97f, 0.85f));
    chatText.setLineWrap(true);
    chatText.setEditable(false);
    chatText.setForeground(Color.blue);
    JScrollPane chatTextPane = new JScrollPane(chatText,
    JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
    JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    chatLine = new JTextField(10);
    chatLine.setBackground(new Color(0.98f, 0.97f, 0.85f));
    chatLine.setForeground(Color.blue);
    chatLine.setEnabled(false);
    chatLine.addActionListener(new ActionAdapter() {
    public void actionPerformed(ActionEvent e) {
    String s = chatLine.getText();
    if (!s.equals("")) {
    appendToChatBox(user=username.getText()+" dit : \n" + s + "\n");
    chatLine.selectAll();
    // Envoi de la chaine entr�e
    sendString(s);
    chatLine.setText("");
    chatPane.add(chatLine, BorderLayout.SOUTH);
    chatPane.add(chatTextPane, BorderLayout.NORTH);
    chatPane.setPreferredSize(new Dimension(300, 300));
         chatPane.add(emoticon, BorderLayout.CENTER);
    // Ajout des pannels dans le pannel principal (mainPane)
    JPanel mainPane = new JPanel(new BorderLayout());
    mainPane.add(statusBar, BorderLayout.SOUTH);
    mainPane.add(optionsPane, BorderLayout.WEST);
    mainPane.add(chatPane, BorderLayout.CENTER);
    // Configuration du frame (mainFrame)
    mainFrame = new JFrame("Chat");
    mainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    // la m�thode setDefaultCloseOperation(int)provient de la classe javax.swing.JDialog
         // Elle specifi l'op�ration qui sera ex�cut�e par d�fault lorsque
         // l'utilisateur initialisera une fermeture de session
    mainFrame.setContentPane(mainPane);
    mainFrame.setSize(mainFrame.getPreferredSize());
         // la m�thode getPreferredSize() provient de la classe java.awt
         // Retourne la grosseur "pr�f�r�e" du container.
    mainFrame.setLocation(200, 200);
    // la m�thode setLocation(double, double) provient de la classe java.awt.Point
         // elle permet de specifiez un emplacement d'un point a des coordonn�es de type Float
    mainFrame.pack();
    // la m�thode pack() provient de la class AWT.Window, elle permet a la fenetre
    // d'�tre ajuster a la grosseur et a la mise en page des sous-composantes de celle-ci
    mainFrame.setVisible(true);
    // Le thread qui permet le changement des composantes GUI pendant le
    // changement de l'etat
    private static void changeStatusTS(int newConnectStatus, boolean noError) {
    // Changer l'etat si valide
    if (newConnectStatus != NULL) {
              connectionStatus = newConnectStatus;
    // S'il n'y a aucunes erreur, afficher le bon message de l'etat
    if (noError) {
    statusString = statusMessages[connectionStatus];
    // Autrement, afficher le message d'erreur
    else {
    statusString = statusMessages[NULL];
    System.out.println("Echec lors de la connexion");
    // Appel a la routine de run()(Runnable interface) sur la gestion des erreurs
    // et la mise a jours des composantes GUI grace au thread
    SwingUtilities.invokeLater(tcpObj);
    // Le changement des composantes GUI sans aucun pendant le
    // changement de l'etat
    private static void changeStatusNTS(int newConnectStatus, boolean noError) {
    // Changer l'etat si valide
    if (newConnectStatus != NULL) {
    connectionStatus = newConnectStatus;
    // S'il n'y a aucunes erreur, afficher le bon message de l'etat
    if (noError) {
    statusString = statusMessages[connectionStatus];
    // Autrement, afficher le message d'erreur
    else {
    statusString = statusMessages[NULL];
    // Appel a la routine de run()(Runnable interface) sur la gestion des erreurs
    // en utilisant le thread
    tcpObj.run();
    // L'ajout au chat box avec l'utilisation du Thread
    private static void appendToChatBox(String s) {
    synchronized (toAppend) {
    toAppend.append(s);
    System.out.println(s);
    // Ajouter le text au "send-buffer"
    private static void sendString(String s) {
    synchronized (toSend) {
    toSend.append(user=username.getText()+ " dit : \n" + s + "\n");
    // Nettoyage pour le debranchement
    private static void cleanUp() {
    try {
    if (hostServer != null) {
    hostServer.close();
    hostServer = null;
    catch (IOException e) { hostServer = null; }
    try {
    if (socket != null) {
    socket.close();
    socket = null;
    catch (IOException e) { socket = null; }
    try {
    if (in != null) {
    in.close();
    in = null;
    catch (IOException e) { in = null; }
    if (out != null) {
    out.close();
    out = null;
    // Verification de l'etat courrant et ajustement de "enable/disable"
    // en fonction de l'etat
    public void run() {
    switch (connectionStatus) {
    case DISCONNECTED:
    connectButton.setEnabled(true);
    disconnectButton.setEnabled(false);
    ipField.setEnabled(true);
    portField.setEnabled(true);
    username.setEnabled(true);
    hostOption.setEnabled(true);
    guestOption.setEnabled(true);
    chatLine.setText("");
    chatLine.setEnabled(false);
    statusColor.setBackground(Color.red);
    break;
    case DISCONNECTING:
    connectButton.setEnabled(false);
    disconnectButton.setEnabled(false);
    ipField.setEnabled(false);
    portField.setEnabled(false);
    hostOption.setEnabled(false);
    guestOption.setEnabled(false);
    chatLine.setEnabled(false);
    statusColor.setBackground(Color.orange);
    break;
    case CONNECTED:
    connectButton.setEnabled(false);
    disconnectButton.setEnabled(true);
    ipField.setEnabled(false);
    portField.setEnabled(false);
    hostOption.setEnabled(false);
    username.setEnabled(false);
    guestOption.setEnabled(false);
    chatLine.setEnabled(true);
    statusColor.setBackground(Color.green);
    break;
    case BEGIN_CONNECT:
    connectButton.setEnabled(false);
    disconnectButton.setEnabled(false);
    ipField.setEnabled(false);
    portField.setEnabled(false);
    hostOption.setEnabled(false);
    username.setEnabled(false);
    guestOption.setEnabled(false);
    chatLine.setEnabled(true);
    chatLine.grabFocus();
    statusColor.setBackground(Color.orange);
    break;
    // S'assurer que l'etat des champs bouton/texte sont consistent
    // avec l'etat interne
    ipField.setText(hostIP);
    portField.setText((new Integer(port)).toString());
    hostOption.setSelected(isHost);
    guestOption.setSelected(!isHost);
    statusField.setText(statusString);
    chatText.append(toAppend.toString());
    toAppend.setLength(0);
    mainFrame.repaint();
    // Procedure principale
    public static void main(String args[]) {
    String s;
    initGUI();
    while (true) {
    try {
    Thread.sleep(10);
         // Verification a toute les 10 ms
    catch (InterruptedException e) {}
    switch (connectionStatus) {
    case BEGIN_CONNECT:
    try {
    // Essai de configuration du serveur si "host"
    if(user != ""){
         if (isHost) {
         hostServer = new ServerSocket(port);
         socket = hostServer.accept();
         // Si invit�, essai de branchement au serveur
         else {
         socket = new Socket(hostIP, port);
    in = new BufferedReader(new
    InputStreamReader(socket.getInputStream()));
    out = new PrintWriter(socket.getOutputStream(), true);
    changeStatusTS(CONNECTED, true);
    System.out.println("Ouverture de la session: \n" + socket);
              else{
              JOptionPane.showMessageDialog(null, "Erreur, vous devez entrer un nom d'utilisateur", "Erreur", JOptionPane.PLAIN_MESSAGE);
                        changeStatusTS(DISCONNECTED, false);
    // Si erreur, nettoyage et envoi du message d'erreur
    catch (IOException e) {
    cleanUp();
    changeStatusTS(DISCONNECTED, false);
    break;
    case CONNECTED:
    try {
    // Envoi de data
    if (toSend.length() != 0) {
    out.print(toSend);
    out.flush();
    toSend.setLength(0);
    changeStatusTS(NULL, true);
    // Reception de data
    if (in.ready()) {
    s = in.readLine();
    if ((s != null) && (s.length() != 0)) {
    // Verification de la fin de la transmission
    if (s.equals(END_CHAT_SESSION)) {
    changeStatusTS(DISCONNECTING, true);
    // Autrement, reception du texte
    else {
    appendToChatBox( s + "\n");
    changeStatusTS(NULL, true);
    catch (IOException e) {
    cleanUp();
    changeStatusTS(DISCONNECTED, false);
    break;
    case DISCONNECTING:
    // Dis aux autres fenetre de chat de se d�brancher aussi
    out.print(END_CHAT_SESSION);
    out.flush();
                   System.out.println("Fermeture de la session");
    // Nettoyage (ferme les streams/sockets)
    cleanUp();
    changeStatusTS(DISCONNECTED, true);
    break;
    default: break; // ne fait rien
    // Certaines interfaces �couteurs sont accompagn�es d'adaptateurs qui
    //implementent toutes les methodes de l'interface et evitent de les lister.
    class ActionAdapter implements ActionListener {
    public void actionPerformed(ActionEvent e) {}
    ////////////////////////////////////////////////////////////////////

  • Please I need some help with a table

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

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

  • Need some help with threads...

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

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

  • Help with some Java Programs

    Hi all ..
    i am a new in Java and i need some help with my School Project ,,,
    Will you help me ??
    regards,
    Toota

    People here will answer questions and comment on your code, but don't ecpect them to debug your source nor do your homework for you.

  • Error 1603: Need some help with this one

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

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

  • I'm suddenly in need of help with my Firefox browser (6.0.2)

    Hi there,
    I'm suddenly in need of help with my Firefox browser (6.0.2)
    (OS: I use Windows XP).
    When I open up the browser, all I see is a completely blank white screen, with all the toolbars at the top.
    I know that my physical connections are fine: I've tested the modem, turned the pc off and on etc. and I can also receive/send emails.
    This problem started today, 8th September, 2011 and has never happened before.
    Is it a coincidence that Firefox updated itself just before I logged off yesterday evening? Could it be something to do with this particular new update?
    I've also noted that just before I "open up" Firefox, I now get a small box saying:
    [JAVASCRIPT APPLICATION]
    Exc In Ev handl: TypeError: This oRoot.enable is not a function
    This has never appeared before - I hope it offers a clue a to what is wrong.
    The Browser is not stuck in Safe Mode, by the way.
    Obviously, I can't search for any solutions to the problem on the internet, as I can't physically see any websites!
    (A friend is sending this query on my behalf from their pc)
    Any light you could throw on this confusing problem would be much appreciated. I'd rather not have to uninstall and reinstall Firefox if possible.
    If the only option is to uninstall Firefox and reinstall it from your site, then I'm also in trouble (I can't see the internet or make any downloads).
    In that case, would you be able to send the .exe file as an attachment to my email address? If so, please let me know and I'll give you further details.
    Many thanks in advance.

    A possible cause is security software (firewall) that blocks or restricts Firefox or the plugin-container process without informing you, possibly after detecting changes (update) to the Firefox program.
    Remove all rules for Firefox from the permissions list in the firewall and let your firewall ask again for permission to get full unrestricted access to internet for Firefox and the plugin-container process and the updater process.
    See:
    * https://support.mozilla.com/kb/Server+not+found
    * https://support.mozilla.com/kb/Firewalls
    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    *Don't make any changes on the Safe mode start window.
    *https://support.mozilla.com/kb/Safe+Mode

  • I need your help with a decision to use iPhoto.  I have been a PC user since the mid 1980's and more recently have used ACDSee to manage my photo images and Photoshop to edit them.  I have used ProShow Gold to create slideshows.  I am comfortable with my

    I need your help with a decision to use iPhoto.  I have been a PC user since the mid 1980’s and more recently have used ACDSee to manage my photo images and Photoshop to edit them.  I have used ProShow Gold to create slideshows.  I am comfortable with my own folder and file naming conventions. I currently have over 23,000 images of which around 60% are scans going back 75 years.  Since I keep a copy of the originals, the storage requirements for over 46,000 images is huge.  180GB plus.
    I now have a Macbook Pro and will add an iMac when the new models arrive.  For my photos, I want to stay with Photoshop which also gives me the Bridge.  The only obvious reason to use iPhoto is to take advantage of Faces and the link to iMovie to make slideshows.  What am I missing and is using iPhoto worth the effort?
    If I choose to use iPhoto, I am not certain whether I need to load the originals and the edited versions. I suspect that just the latter is sufficient.  If I set PhotoShop as my external editor, I presume that iPhoto will keep track of all changes moving forward.  However, over 23,000 images in iPhoto makes me twitchy and they are appear hidden within iPhoto.  In the past, I have experienced syncing problems with, and database errors in, large databases.  If I break up the images into a number of projects, I loose the value of Faces reaching back over time.
    Some guidance and insight would be appreciated.  I have a number of Faces questions which I will save for later. 

    Bridge and Photoshop is a common file-based management system. (Not sure why you'd have used ACDSEE as well as Bridge.) In any event, it's on the way out. You won't be using it in 5 years time.
    Up to this the lack of processing power on your computer left no choice but to organise this way. But file based organisation is as sensible as organising a Shoe Warehouse based on the colour of the boxes. It's also ultimately data-destructive.
    Modern systems are Database driven. Files are managed, Images imported, virtual versions, lossless processing and unlimited editing are the way forward.
    For a Photographer Photoshop is overkill. It's an enormously powerful app, a staple of the Graphic Designers' trade. A Photographer uses maybe 15% to 20% of its capability.
    Apps like iPhoto, Lightroom, Aperture are the way forward - for photographers. There's the 20% of Photoshop that shooters actually use, coupled with management and lossless processing. Pop over to the Aperture or Lightroom forums (on the Adobe site) and one comment shows up over and over again... "Since I started using Aperture/ Lightroom I hardly ever use Photoshop any more..." and if there is a job that these apps can do, then the (much) cheaper Elements will do it.
    The change is not easy though, especially if you have a long-standing and well thought out filing system of your own. The first thing I would strongly advise is that you experiment before making any decisions. So I would create a Library, import 300 or 400 shots and play. You might as well do this in iPhoto to begin with - though if you’re a serious hobbyist or a Pro then you'll find yourself looking further afield pretty soon. iPhoto is good for the family snapper, taking shots at birthdays and sharing them with friends and family.
    Next: If you're going to successfully use these apps you need to make a leap: Your files are not your Photos.
    The illustration I use is as follows: In my iTunes Library I have a file called 'Let_it_Be_The_Beatles.mp3'. So what is that, exactly? It's not the song. The Beatles never wrote an mp3. They wrote a tune and lyrics. They recorded it and a copy of that recording is stored in the mp3 file. So the file is just a container for the recording. That container is designed in a specific way attuned to the characteristics and requirements of the data. Hence, mp3.
    Similarly, that Jpeg is not your photo, it's a container designed to hold that kind of data. iPhoto is all about the data and not about the container. So, regardless of where you choose to store the file, iPhoto will manage the photo, edit the photo, add metadata to the Photo but never touch the file. If you choose to export - unless you specifically choose to export the original - iPhoto will export the Photo into a new container - a new file containing the photo.
    When you process an image in iPhoto the file is never touched, instead your decisions are recorded in the database. When you view the image then the Master is presented with these decisions applied to it. That's why it's lossless. You can also have multiple versions and waste no disk space because they are all just listings in the database.
    These apps replace the Finder (File Browser) for managing your Photos. They become the Go-To app for anything to do with your photos. They replace Bridge too as they become a front-end for Photoshop.
    So, want to use a photo for something - Export it. Choose the format, size and quality you want and there it is. If you're emailing, uploading to websites then these apps have a "good enough for most things" version called the Preview - this will be missing some metadata.
    So it's a big change from a file-based to Photo-based management, from editing files to processing Photos and it's worth thinking it through before you decide.

  • I've just came on board from Andriod and need massive help with the Contacts application any one out there willing to help the 'noob'?

    I had the folks at the store port over all of my contacts from my old
    ratty Andriod phone to my new shiny iPhone.
    however all 200+ of my contacts sort of "shook" out,
    meaning say John Smith, on my old phone,
    had in my contacts the following:
    John Smith
    123 Main St. Anytown, Anystate USA
    555-826-4879 home
    555-799-4247 cell
    [email protected]
    johnsmith@facebook
    all nice and neat on my andriod but when it ported over
    all that information was just scattered all over my contacts sort of like:
    john smith, smith john
    john smith 123 main st. etc.
    johhn smith home 555 etc.
    john smith cell 555 etc.
    john smith johnsmith@ etc.
    etc.
    so for all those 200+ contacts in my phone, I've got a zillion of them now...
    so I'd like to get this all back in order before I and Siri explode.
    I know nothing, and I know even less about outlook and the sort.
    But I do know I am in Dire need of help with this... I figured that eveything else
    involving iphones and apple in general was supposed to be cake but it seems
    like this is the only thing that isn't cake at all... unless, I'm just a right idiot. (which is possible, hence spelling and grammatical issues).

    I believe I've tried to sync it with google, but it didn't seem to take
    muchless take my calender. it seems to favor my facebook calender
    more over my google calender, but Siri seems to be helping me re-write
    it...but that's not the game here, it's the contacts. I've tried to export
    the cvp (??) list and import it into my iTunes account. However, It only
    doubled my issue because it didn't over write my existing contacts.

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

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

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

  • Need some help with putting a folder in users directory

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

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

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

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

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

Maybe you are looking for

  • Error Message relating to cache ???

    I am getting a weird error message which says: "The following errors occurred while trying to open this document: Missing File cache-1 Missing File cache Missing File cache-2" This page has 4 images which I retrieved from iPhoto, and appear on the iW

  • Error : CONFIRMATION window is already open

    Hello, I have a sceanrio where i have to open a same dynpro application with different set of  values. Let say I have service order with 2 operation. User can do confirmation against these operations. List of service orders are displayed in ALV list.

  • Macbook pro w hdmi converter

    Greetings,from the mini-plug to the hdmi output to my 55in 1080p LCD. when i close the lid, it will goto sleep or shut-down. i want to be able to close the lid and have output to the big screen without using the mirroring option. i would like to know

  • Calling a function which has a CLOB parameter via an anonymous block.

    OK, we are moving a lot of exports currently done by Crystal to just be done by stored procs. So we have a load of existing, some extremely length SQL statements used for these exports. IN the exports, we have meaningful column headings, so we have a

  • Where can I find Red 4k clips to download?

    Subject line pretty much sums it up. I know that they will be pretty large files, but I'd really like to play with some native Red 4k footage using CS5 and I don't have access to a Red 4k camera. The longer the duration, the better, and each clip nee