Help with newb-project much appreciated

Printable View

Luck,
CJSL
  • 12-04-2008, 12:44 PM
    barr
    Thank you, I wasn't aware of that sun had those basic tutorials. Neat.

    Question: Is there a way for the applet to know it's location on the server?

    For example, the applet is located at "htp://mydomain.com/scripts/applet/", and I want to connect with a php-file in the same folder.

    So instead of:

    Code:

    URL  requestHandler = new URL("htp://mydomain.com/scripts/applet/requestHandler.php");
    Can I do something like this?

    Code:

    URL appletLocation = *get the location of the applet*;
    URL requestHandler = new URL(appletLocation, "requestHandler.php");

  • 12-04-2008, 05:04 PM
    xcallmejudasx
    Java 2 Platform SE 5.0 look at the getPath(), getHost() etc methods. I think those may be what you want
  • 12-05-2008, 12:41 PM
    barr
    Quote:

    Originally Posted by xcallmejudasx View Post
    Java 2 Platform SE 5.0 look at the getPath(), getHost() etc methods. I think those may be what you want

    Thanks, I found the getCodeBase() that seems to be what I want.

    *********************

    Now I'm working with the interface, and I have a problem with the following code:

    Code:

    public class gallery{
                    JLabel title = new JLabel("Gallery");
                    public void show(){
                            contentPanel.removeAll();
                            contentPanel.add(title, BorderLayout.NORTH);
                            contentPanel.add(text, BorderLayout.CENTER);
                           
                    }
            }
           
            public class uploader{
                    JLabel title = new JLabel("Uploader");
                    public void show(){
                            contentPanel.removeAll();
                            contentPanel.add(title, BorderLayout.NORTH);
                            contentPanel.add(text, BorderLayout.CENTER);
                           
                    }
            }

    I have two buttons, one for uploading and one for browsing. The event handlers for the buttons sets the JLabel text to a string returned from a php-page that returns time(), and calls uploader.show() resp. browser.show(), that clears the contentPanel and adds it's own content.

    However, the JLabel title only changes the first time I press a button, if I first press the button "upload", the title changes to Uploader, and if I then press "Browse", the title changes to "Gallery". But after that, the title don't change anymore. But the JLabel text change each time I press a button.

    How can this be?
  • 12-08-2008, 05:19 PM
    xcallmejudasx
    I'm not familiar with JLabel or contentPanel but I think it may be something to do with add. Is there a set or clear method available? The way I picture any add method working is to actually add some object, not just change the text of the object, which is why I think you may need to contentPanel.set() or something.

    Have you tried clearing the title right after the button is pressed and then re-writing the title again over it?
  • 12-11-2008, 12:08 PM
    barr
    Thanx, I found out that contentPanel.validate() solved my problem.
  • 12-11-2008, 12:14 PM
    barr
    I've come to the point where a can send and recieve http-requests, but I'm doing something wrong.

    Code:

    POST /info.php HTTP/1.1
    Host: mypage.com
    Connection: Keep-Alive
    Content-Type: multipart/form-data; boundary=gismoquack
    Content-Length: 158


    --gismoquack
    content-disposition: form-data; name="id"

    user
    --qismoquack
    content-disposition: form-data; name="filename"

    test.jpg
    --qismoquack--

    info.php checks if "id" and "filename" is posted, but it says that only "id" is posted.

    Can you see what I've done wrong?