Please help. Simple Socket Question

Hi. I am writing the basics for a game. Simple. I have a few classes, 1 of which is for connecting and another in which each user inherits a new copy as they join, it contains all their personal variables.
By having their socket address, how can I access a specific instance of that file?
Thanks for any help.

Hi. I am writing the basics for a game. Simple. I
have a few classes, 1 of which is for connecting and
another in which each user inherits a new copy as
they join, it contains all their personal variables.
By having their socket address, how can I access a
specific instance of that file?Specific instance of what file? Sockets connect processes to other processes, not to files.

Similar Messages

  • Please help me jmf question

    Hi i want to create custom data source as i have read in different post and also on sun site
    I tried to create one one for my self,
    where am getting stream from tcp port.
    before that i test the data by using socket programming, i saved the input stream into file and played and its working fine and then i transfer that file using avtransmiter2.java and it work fine again its mean it confirm that the data i am getting from skype is working fine . now my question is how to get that input stream and instead of saving to the file i can play it using jmf player or send it on rtp session. i read different post how to create custom data source from inputstreams but have not work for me ... i modified a user code posted http://archives.java.sun.com/cgi-bin/wa?A2=ind0106&L=jmf-interest&D=0&P=25865 in that post some body recommanded to implement seekable so i implemented that one als in that code..... below is the code
    the error is
    LoadInputStream.loadBytes() - realizing player
    Exception in thread "JMF thread: com.sun.media.PlaybackEngine@8ed465[ com.sun.media.PlaybackEngine@8ed465 ] ( configureThread)" java.lang.NullPointerException
    at com.skype.sample.InputSourceStream.read(InputSourceStream.java:89)
    at com.sun.media.parser.BasicPullParser.readBytes(BasicPullParser.java:142)
    at com.sun.media.parser.BasicPullParser.readBytes(BasicPullParser.java:114)
    at com.sun.media.parser.BasicPullParser.readInt(BasicPullParser.java:191)
    at com.sun.media.parser.audio.AuParser.readHeader(AuParser.java:109)
    at com.sun.media.parser.audio.AuParser.getTracks(AuParser.java:76)
    at com.sun.media.BasicSourceModule.doRealize(BasicSourceModule.java:180)
    at com.sun.media.PlaybackEngine.doConfigure1(PlaybackEngine.java:229)
    at com.sun.media.PlaybackEngine.doConfigure(PlaybackEngine.java:193)
    at com.sun.media.ConfigureWorkThread.process(BasicController.java:1370)
    at com.sun.media.StateTransitionWorkThread.run(BasicController.java:1339)
    i need urgent help to this matter so please help me in that i would be very thankfulll ......
    below is the code
    skype use the standard audio format
    Audio format
    File: WAV PCM
    Sockets: raw PCM samples
    16 KHz mono, 16 bit
    Note
    import javax.media.*;
    import java.io.*;
    import java.net.ServerSocket;
    import java.net.Socket;
    import javax.swing.*;
    import java.awt.*;
    import java.util.*;
    public class LoadInputStream extends JFrame implements ControllerListener {
    private Player player;
    /** Creates new LoadInputStream */
    public LoadInputStream() {
    try{
    // declaration section:
    // declare a server socket and a client socket for the server
    // declare an input and an output stream
    ServerSocket SkypeServer = null;
    DataInputStream is;
    Socket clientSocket = null;
    try {
    SkypeServer = new ServerSocket(4447);
    catch (IOException e) {
    System.out.println(e);
    // Open input stream
    clientSocket = SkypeServer.accept();
    is = new DataInputStream(clientSocket.getInputStream());
    loadBytes(is);
    setBounds(100, 100, 300, 300);
    setVisible(true);
    catch(Exception e){
    System.out.println(e);
    /* Loads the given byte [] into the MediaPlayer and starts playing it immediately. */
    public void loadBytes(InputStream is){
    DataSource ds=new DataSource(is);
    System.out.println("LoadInputStream.loadBytes() - Creating DataSource (InputStream)");
    System.out.println("LoadInputStream.loadBytes() - Creating Player");
    try {
    player = Manager.createPlayer(ds);
    } catch(NoPlayerException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch(IOException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    System.out.println("LoadInputStream.loadBytes() - Adding Controller Listener");
    player.addControllerListener(this);
    System.out.println("LoadInputStream.loadBytes() - realizing player");
    player.realize();
    public static void main(String[] args){
    new LoadInputStream();
    public void controllerUpdate(javax.media.ControllerEvent e) {
    if(e instanceof RealizeCompleteEvent){
    System.out.println("Adding visual component");
    getContentPane().add(player.getVisualComponent());
    player.start();
    =============================Datasource==========================================================
    import java.io.*;
    import java.nio.ByteBuffer;
    import javax.media.*;
    import javax.media.protocol.*;
    public class DataSource extends PullDataSource {
    private InputStream is;
    private byte [] bytes;
    /** Creates new MediaViewerDataSource */
    public DataSource(InputStream is) {
    super();
    this.is = is;
    try{
    int byteCount = is.available();
    bytes = new byte [byteCount];
    is.read(bytes);
    catch (Exception e){
    System.out.println(e);
    public PullSourceStream [] getStreams() {
    PullSourceStream [] streams = new PullSourceStream [1];
    InputSourceStream iss = new InputSourceStream(new ByteArrayInputStream(bytes), new FileTypeDescriptor(ContentDescriptor.RAW_RTP));
    streams[0] = iss;
    return streams;
    public void connect() {}
    public void disconnect() {}
    public String getContentType() {
    return new String("audio.x-wav");
    public MediaLocator getLocator() {
    return null;
    public void initCheck() {}
    public void setLocator(MediaLocator source) {}
    public void start() {}
    public void stop() {}
    public Object getControl(String s){
    return null;
    public Object [] getControls(){
    return null;
    public Time getDuration(){
    return null;
    =================================InputStream======================================================
    import java.io.InputStream;
    import java.io.IOException;
    import java.nio.ByteBuffer;
    import javax.media.protocol.ContentDescriptor;
    import javax.media.protocol.PullSourceStream;
    import javax.media.protocol.Seekable;
    import javax.media.protocol.SourceStream;
    * Build a source stream out of an input stream.
    * @see DataSource
    * @see SourceStream
    * @see java.io.InputStream
    * @version %I%, %E%.
    public
    class InputSourceStream implements PullSourceStream, Seekable {
    protected InputStream stream;
    protected boolean eosReached;
    ContentDescriptor contentType;
    protected ByteBuffer inputBuffer;
    * Construct an <CODE>InputSourceStream</CODE> from an input stream.
    * @param s The input stream to build the source stream from.
    * @param type The content-type of the source stream.
    public InputSourceStream(InputStream s, ContentDescriptor type) {
    stream = s;
    eosReached = false;
    contentType = type;
    * Get the content type for this stream.
    * @return content descriptor for the stream.
    public ContentDescriptor getContentDescriptor() {
    return contentType;
    * Obtain the content length
    * @return content length for this stream.
    public long getContentLength() {
    return SourceStream.LENGTH_UNKNOWN;
    * Query if the next read will block.
    * @return true if a read will block.
    public boolean willReadBlock() {
    if( eosReached == true) {
    return true;
    } else {
    try {
    return stream.available() == 0;
    } catch (IOException e) {
    return true;
    * Read a buffer of data.
    * @param buffer The buffer to read data into.
    * @param offset The offset into the buffer for reading.
    * @param length The number of bytes to read.
    * @return The number of bytes read or -1 indicating end-of-stream.
    public int read(byte[] buffer, int offset, int length) throws IOException {
    int bytesRead = stream.read(buffer, offset, length);
    if( bytesRead == -1) {
    eosReached = true;
    inputBuffer.get(buffer,offset,length);
    return bytesRead;
    * Turn the stream off.
    * @exception IOException Thrown if there is a problem closing the stream.
    public void close() throws IOException {
    stream.close();
    * Return if the end of stream has been reached.
    * @return true if the end of the stream has been reached.
    // $jdr: This is a bug. Need to figure out
    // the "correct" way to determine, before a read
    // is done, if we're at EOS.
    public boolean endOfStream() {
    return eosReached;
    * Returns an zero length array because no controls
    * are supported.
    * @return a zero length <code>Object</code> array.
    public Object[] getControls() {
    return new Object[0];
    * Returns <code>null</code> because no controls are implemented.
    * @return <code>null</code>.
    public Object getControl(String controlName) {
    return null;
    public long seek(long where) {
    try {
    inputBuffer.position((int)(where));
    return where;
    catch (IllegalArgumentException E) {
    return this.tell(); // staying at the current position
    public long tell() {
    return inputBuffer.position();
    public void SeekableStream(ByteBuffer byteBuffer) {
    inputBuffer = byteBuffer;
    this.seek((long)(0)); // set the ByteBuffer to to beginning
    public boolean isRandomAccess() {
    // TODO Auto-generated method stub
    return false;
    }

    Use a BufferedImage where you draw the other images.
    You have to know the size.
    For example if the size is (50*50) for each image :
    int width =50;
    int height = 50;
    BufferedImage bufIm = new BufferedImage(width*3,height*3,BufferedImage.TYPE_INT_ARGB);
    Graphics gr = bufIm.createGraphics();
    int k, j;
    Toolkit tk = Toolkit.getDefaultToolkit();
    Image imTemp;
    for (k = 0; k<3; k++) {
        for (j = 0; j<3; j++) {
            imTemp = tk.getImage(imageNames[k][j]);
            gr.drawImage(imTemp,width*k,height*j, this); // replace this by the Image observer you want (this if you are in a panel for example)
    }After that bufIm contains the images as you want and you can paint it on a Graphics.
    Denis

  • Please help (Simple chat programme)

    I made a simple chat programme.
    It has a server object and it can handle several client.
    It is working properly and can use to chat.
    I have some problems. can you please help me.
    1.What is the best method to read input and outputStreams
    I have used inputStream.readUTF()/outputStream.writeUTF() methods and
    also I have used bufferedReader.readLine()/Printwriter.println() methods.
    I don't know about other methods.So please tell me what is the best and new out of these two.
    And are there any method which is better than these two.
    2.Is there any way to get more details from input and output streams
    Here more details means Fontcolor,Size etc;
    by now I'm adding them in to my output streams and filtering them when rea input stream.
    I'm getting other details(Fontcolor,Size) and add them all to a string.
    that means if client type "hi" my string will be something like this
    "12ff0000hi".
    When read the input stream i make a char[] and take first 2 chars to integer next six to a string and rest
    to another string.
    I think now you can understand my concept. So I'll not tell every thing.(if you want i can fully describe it)
    I' feeling this is very bad way to do that kind of work.
    Am i correct?
    so can you give me some hints or examples to do such kind of things.

    Here's a simple DataInputStream program that talks to itself. It runs the server as a seperate thread.
    import java.io.*;
    import java.net.*;
    public class DataXfer
            private int port = 5050;
            private String address="127.0.0.1";
            public static void main(String args[])
                    new DataXfer().startup();
            // run the server code as a thread and then run the client code
            private void startup()
                    new Thread(new Runnable(){public void run(){listen();}}).start(); // start server thread
                    synchronized(this){
                            try{wait();}catch(InterruptedException ie){}    // wait until its ready
                    connect();                                      // do client stuff     
            private void listen()
                    ServerSocket ss = null;
                    Socket us = null;
                    boolean running = true;
                    try{
                            System.out.println("Listening on port "+port);
                            synchronized(this){notify();}               // tell client we're ready
                            ss = new ServerSocket(port);    // listen for incoming connection
                            us = ss.accept();
                            ss.close();
                            ss = null;
                            DataInputStream dis = new DataInputStream(us.getInputStream());
                            try{
                                    while(running){
                                            int len = dis.readShort();      // read the count
                                            byte [] ba = new byte[len];
                                            int rlen = dis.read(ba,0,len);  // read the data
                                            System.out.println("len="+len+" read length="+rlen);
                                            if(rlen < len){
                                                    us.close();
                                                    running = false;
                                            else{
                                                    for(int j = 0; j<rlen; j++)System.out.print(ba[j]+" ");
                                                    System.out.println("");
                            catch(EOFException ee){System.out.println("EOF");}
                    catch(IOException ie){
                            ie.printStackTrace();
                            System.exit(0);
                    finally{
                            if(ss != null)try{ss.close();}catch(IOException se){}
                            if(us != null)try{us.close();}catch(IOException ue){}
            private void connect()
                    Socket us=null;
                    byte [] ba = new byte[31];
                    for(byte i = 0; i<ba.length; i++)ba=i;
    try{
    System.out.println("Connecting to "+address+":"+port);
    us = new Socket(address, port); // make connection
    System.out.println("Connected");
    DataOutputStream dos = new DataOutputStream(us.getOutputStream());
    for(int j = 0; j<ba.length;j+=10){
    dos.writeShort(j); // write the count
    dos.write(ba,0,j); // write the data
    System.out.println("sent "+j+" bytes");
    try{Thread.sleep(1000);}catch(InterruptedException ie){}
    catch(IOException ie){ie.printStackTrace();}
    finally{
    if(us != null)try{us.close();}catch(IOException ue){}
    For an example of a chat program using NIO see my NIO Server Example. That example is neither short nor simple.

  • Please help me about question security because in my apple id no have for restart or chenge my answer

    please help me about answer security question in my apple id because im forgot for my answer, in my apple id no have for change answer, tell me for this please because i love my iphone.
    <Email Edited by Host>

    You need to ask Apple to reset your security questions; this can be done by clicking here and picking a method, or if your country isn't listed, filling out and submitting this form.
    They wouldn't be security questions if they could be bypassed without Apple verifying your identity.
    (110899)

  • Urgent!! Please Help! Security Question!

    I have forgotten the answers to my security questions (all three). As i made my Apple ID over 3 years ago, it did not ask me for a recovery e-mail adress. Is there any way i can reset the answers without the e-mail? Please Help!!

    Welcome to the Apple Community.
    ou should contact AppleCare who will initially try to assist you with a reset email or if unsuccessful will pass you to the security team to reset your security questions for you.
    If you are in a region that doesn't have international telephone support try contacting Apple through iTunes Store Support.

  • *****Please Help Simple Java Corba Problem*****

    This is probably a really simple one but I am very cheased off about it.
    I run my applications on a Win XP pro OS, and when I go to type in nameserv it gives me the following error I hava downloaded and installed JDK 1.4.1. I also have the JRE, And jbuilder personal edition ver 8.....And J2RE 1.4.1
    C:\Documents and Settings\Ash>nameserv
    Exception in thread "main" java.lang.NoClassDefFoundError: java/util/HashSet
    at com.inprise.vbroker.orb.ORB.<init>(ORB.java:81)
    at org.omg.CORBA.ORB.create_impl(ORB.java)
    at org.omg.CORBA.ORB.init(ORB.java)
    at com.inprise.vbroker.naming.ExtFactory.main(ExtFactory.java:126)
    my classpath looks like this
    .;C:\VisualCafePDETrial\BIN\COMPONENTS\SYMBEANS.JAR;C:\VisualCafePDETrial\JAVA\LIB\CLASSES.ZIP;C:\VisualCafePDETrial\JAVA\LIB;C:\BES\bin;C:\j2sdk1.4.1\lib\tools.jar;.;
    and my path is
    C:\VisualCafePDETrial\BIN;C:\VisualCafePDETrial\JAVA\BIN;C:\BES\binC:\j2sdk1.4.1\lib\tools.jar;.;
    what on earth am I doing wrong ??
    Also when I goto compile any java program it comes up with the following
    C:\DOCprac\Prac5\bank_naming>vbmake
    Building the bank_agent example ...
    Exception in thread "main" java.lang.ClassCastException
    at com.visigenic.vbroker.tools.idl2java.main(idl2java.java:30)
    Symantec Java! JustInTime Compiler Version 3.00.021(i) for JDK 1.1.x (TRIAL VER)
    Copyright (C) 1996-98 Symantec Corporation
    compiling: Client.java
    Client.java:2: Package org.omg.CORBA not found in import.
    import org.omg.CORBA.*;
    ^
    Client.java:3: Package org.omg.CosNaming not found in import.
    import org.omg.CosNaming.*;
    ^
    2 errors
    Symantec Java! JustInTime Compiler Version 3.00.021(i) for JDK 1.1.x (TRIAL VER)
    Please help I am really desperate to sort this one out. Can you give me some detailed info on how I would do this.>>>Thanx in advance

    You have 2 sets of errors, at least.
    The first is : Exception in thread "main" java.lang.NoClassDefFoundError: java/util/HashSet which is that you have not imported the class for hashset.
    The second is that the import of the jars is probably wrong, hard to say without seeing code.

  • Please help - simple drop down box

    i am very new to this - i have just opened the app for the first time - i have to create this form by tomorrow!!
    I have a simple list in access - it contains 15 fields in the table - very simple.  I need EVERY drop down box on the page to ref. this table to populate the list - which changes on a daily basis.  There will be a total of 35 drop down boxes on the form - all pointing to the exact same CHANGING list.
    PLEASE HELP!!!

    You can enter the sales tax rate for each province as the export value and
    then use the drop-down field directly in your calculations.
    On Thu, Feb 5, 2015 at 6:06 PM, jennam90934439 <[email protected]>

  • PLEASE HELP - Simple movieclip click to URL is NOT working... Why???

    I've tried over 4 tutorials to make my movieclip link to a URL. It's just not working for some reason...
    Here is my code.
    ondemand.addEventListener(MouseEvent.CLICK,goThere);
    function goThere(e:MouseEvent){
    var request:URLRequest = new URLRequest("www.money.net");
    navigateToURL(request);
    ondemand.buttonMode = true;
    ondemand.useHandCursor = true;
    stop();
    ondemand is a movieclip instance with a PNG image of text.
    This should work!! There are no compilation errors...
    No mouse cursor change on hover... just like nothing is there.
    Please help...   

    I am overall confused by your description of what you have, especially when you get to doubleclicking the movie and assigning code in it.
    In any case, you need to assign the name (the same name) to every instance of a tweened object. The lack of a name in earlier frames will be inherited by instances in subsequent frames
    I'm confused about your mention of 3 instances being in the library.  Just for clarity, an instance is a library symbol (or an object) that you place on the stage.  If you place two of the same objects on the stage, then you have 2 instances.  Items in the library are instance-wanna-bes.  If you have three different symbols in the library, and you are tweening them as if they were the same, your tween can't possibly work.

  • HELP PLEASE HELP! urgent question with an easy answer!!!!

    Hello;
    I designed a JFrame game, that uses gif files as ImageIcons. The game works perfectly when I run it from console with the java.exe command.
    However; now I want to create a wraparound and run the JFrame in the Internet Explorer from an applet. So I created a new file that extends JApplet; this new file creates a new object of the JFrame-game's class and show()'s it.
    And I created an HTM file that runs the JApplet class. However, the internet explorer cannot open the applet because it has trouble loading the pictures (gif files). How can I load the pictures from my applet for my frame???
    I dont want to change the Java security file. I just want to make the images accessible by my applet. I cannot use commands like setImage in my applet because my JFrame sets the Images.
    (I repeat)My JApplet only invokes an object of my JFrame class and shows it.
    PLEASE HELP PLEASE PLEASE..
    Thanks..

    OK; let me tell you the whole thing. My pictures are in the same folder for sure.
    My JFrame reads pictures and assigns JButtons pictures. when I run the frame there are 16 buttons with the same picture, and when I click the buttons there is a listener in the JFrame that changes the pictures. Simply put, the JFrame has no trouble finding and loading the pictures.
    Then I created a JApplet as follows:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    public class MemoryApplet extends JApplet
    public void init ()
         GameFrame ce = new GameFrame ();
         ce.show ();
    GameFrame is the name of the JFrame class. Then when I try to open the applet using IE, it gives the following error:
    Exception: java.security.AccessControlException: (javax.io.FilePermission back.gif read)
    back.gif is one of the gif files that are used in GameFrame

  • Pretty please help, Quick newb question...

    I have a dell axim x50. I have the jad and jar files. How can I make my application work on the PDA??
    I've simulated with toolkit, and such.
    Please Please help ><

    The act of getting the jar from a pc to the device is called "provisioning"
    Some devices let you do this over bluetooth or IR and many others only allow it over http.
    I used to use some free web midlet hosting sites but the ones i used have been shut down now. (do a search on the net for "Free Midlet Hosting")
    These days i set up a web server on my development machine and then just use the phones wap browser to download the program.

  • Please help, simple question about Smart Playlists and Live Updating

    PLEASE for some reason I've never gotten an answer on this.
    I have a Smart Playlist called "Recently Played" with Live Updating. No matter how I set the parameters, the most recently played *song will ALWAYS appear on the bottom of the list when using my iPhone on the go.* I bolded that because I want you to be aware I'm not talking about on iTunes - I'm aware you can change how the list is viewed on iTunes.
    When using your iPod/iPhone on the fly and Live Updating is enabled, is there any way to make the most recently played song appear at the very top???
    Thanks so much

    Haven't seen that problem before but try the following: in iTunes, right-click the playlist name and enable the option "Copy to Play Order." Then sync.
    The normal use of "Copy to Play Order" when you have the playlist displayed in iTunes in some sort order, but you want it to display in the iPod in shuffled order (as it will actually play). Different problem than you are observing, but the same thing "might" help.... Let us know.

  • Context help (please help, simple question i think)

    Hi, on my webserver, I have a nested tag that goes:
    <Host name="www.mydomain.com">
    <Alias>domain.com</Alias>
    <Context docBase="/home/domainacct/public_html/jsp" path="/jsp" reloadable="true">
    </Context>
    </Host>
    When I use this setup, JSP works! I can access any http://www.mydomain.com/jsp/*.jsp
    But I don't want JSP files to be loadable only from the /jsp directory, as I would like
    to be able to do:
    <Host name="www.mydomain.com">
    <Alias>domain.com</Alias>
    <Context docBase="/home/domainacct/public_html" path="" reloadable="true">
    </Context>
    </Host>
    so that I can access jsp files like: http://www.mydomain.com/test.jsp
    But when I try that setup it doesn't work.
    Do you guys know how I can do this? Thanks.

    nope u can't do that i far as i know.
    the context docBase should be the actual path to the folder. so if your webapp is in C:\TOOLS\webapps\Development than ur docBase is Development....like the root directory for example.
    the context tag as far as i know cannot be used for what u want 2 do. i don't think u can in Java.

  • Please, help a newbie:  Question about animating expanding containers

    Hi All,
    Short Version of my Question:
    I'm making a media player that needs to have an animation for panels sliding up and down and left and right, and the method I've been using to do this performs far slower than the speed I believe is possible, and required. What is a fast way to make a high performance animation for such an application?
    Details:
    So far, to do the animation, I've been using JSplitPanes and changing the position of the divider in a loop and calling paintImmediately or paintDirtyRegion like so:
    public void animateDividerLocation( JSplitPane j, int to, int direction) {
    for(int i=j.getDividerLocation(); i>=to; i-=JUMP_SIZE) {
    j.setDividerLocation(i);
    j.validate();
    j.paintImmediately(0, 0, j.getWidth(), j.getHeight());
    The validate and paintImmediately calls have been necessary to see any changes while the loop is going. I.e., if those calls are left out, the components appear to just skip right to where they were supposed to animate to, without having been animated at all.
    The animation requirement is pretty simple. Basically, the application looks like it has 3 panels. One on the right, one on the left, and a toolbar at the bottom. The animation just needs to make the panels expand and contract.
    Currenly, the animation only gets about, say, 4 frames a second on the 800 MHz Transmeta Crusoe processor, 114 MB Ram, Windows 2000 machine I must use (to approximate the performance of the processor I'll be using, which will run embedded Linux), even though I've taken most of the visible components out of the JPanels during the animation. I don't think this has to do with RAM reaching capacity, as the harddrive light does not light up often. Even if this were the case, the animation goes also goes slow (about 13 frames a second) on my 3 GHz P4 Windows XP if I keeps some JButtons, images etc., inside the JPanels. I get about 50 frames/sec on my 3 GHz P4, if I take most of the JButtons out, as I do for the 800 MHz processor. This is sufficient to animate the panels 400 pixels across the screen at 20 pixels per jump, but it isn't fast or smooth enough to animate across 400 pixels moving at 4 pixel jumps. I know 50 frames/sec is generally considered fast, but in this case, there is hardly anything changing on the screen (hardly any dirty pixels per new frame) and so I'd expect there to be some way to make the animation go much faster and smoother, since I've seen games and other application do much more much faster and much smoother.
    I'm hoping someone can suggest a different, faster way to do the animation I require. Perhaps using the JSplitPane trick is not a good idea in terms of performance. Perhaps there are some tricks I can apply to my JSplitPane trick?
    I haven't been using any fancy tricks - no double buffering, volatile images, canvas or other animation speed techniques. I haven't ever used any of those things as I'm fairly new to Swing and the 2D API. Actually I've read somewhere that Swing does double buffering without being told to, if I understood what I read. Is doing double buffering explicitly still required? And, if I do need to use double buffering or canvas or volatile images or anything else, I'm not sure how I would apply those techiniques to my problem, since I'm not animating a static image around the screen, but rather a set of containers (JSplitPanes and JPanels, mostly) and components (mostly JButtons) that often get re-adjusted or expanded as they are being animated. Do I need to get the Graphics object of the top container (would that contain the graphics objects for all the contained components?) and then double buffer, volatile image it, do the animation on a canvas, or something like that? Or what?
    Thanks you SO much for any help!
    Cortar
    Related Issues(?) (Secondary concerns):
    Although there are only three main panels, the actual number of GUI components I'm using, during the time of animation, is about 20 JPanels/JSplitPanes and 10 JButtons. Among the JPanels and the JSplitPanes, only a few JPanels are set to visible. I, for one, don't think this higher number of components is what is slowing me down, as I've tried taking out some components on my 3GHz machine and it didn't seem to affect performance much, if any. Am I wrong? Will minimizing components be among the necessary steps towards better performance?
    Anyhow, the total number of JContainers that the application creates (mostly JPanels) is perhaps less than 100, and the total number of JComponents created (mostly JButtons and ImageIcons) is less than 200. The application somehow manages to use up 50 MBs RAM. Why? Without looking at the code, can anyone offer a FAQ type of answer to this?

    You can comment out the lines that add buttons to the panels to see the behavior with empty panels.
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.Timer;
    public class DancingPanels
        static GridBagLayout gridbag = new GridBagLayout();
        static Timer timer;
        static int delay = 40;
        static int weightInc = 50;
        static boolean goLeft = false;
        public static void main(String[] args)
            final GridBagConstraints gbc = new GridBagConstraints();
            gbc.weightx = 1.0;
            gbc.weighty = 1.0;
            gbc.fill = gbc.HORIZONTAL;
            final JPanel leftPanel = new JPanel(gridbag);
            leftPanel.setBackground(Color.blue);
            gbc.insets = new Insets(0,30,0,30);
            leftPanel.add(new JButton("1"), gbc);
            leftPanel.add(new JButton("2"), gbc);
            final JPanel rightPanel = new JPanel(gridbag);
            rightPanel.setBackground(Color.yellow);
            gbc.insets = new Insets(30,50,30,50);
            gbc.gridwidth = gbc.REMAINDER;
            rightPanel.add(new JButton("3"), gbc);
            rightPanel.add(new JButton("4"), gbc);
            final JPanel panel = new JPanel(gridbag);
            gbc.fill = gbc.BOTH;
            gbc.insets = new Insets(0,0,0,0);
            gbc.gridwidth = gbc.RELATIVE;
            panel.add(leftPanel, gbc);
            gbc.gridwidth = gbc.REMAINDER;
            panel.add(rightPanel, gbc);
            timer = new Timer(delay, new ActionListener()
                    gbc.fill = gbc.BOTH;
                    gbc.gridwidth = 1;
                public void actionPerformed(ActionEvent e)
                    double[] w = cycleWeights();
                    gbc.weightx = w[0];
                    gridbag.setConstraints(leftPanel, gbc);
                    gbc.weightx = w[1];
                    gridbag.setConstraints(rightPanel, gbc);
                    panel.revalidate();
                    panel.repaint();
            JFrame f = new JFrame("Dancing Panels");
            f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            f.getContentPane().add(panel);
            f.setSize(400,300);
            f.setLocation(200,200);
            f.setVisible(true);
            timer.start();
        private static double[] cycleWeights()
            if(goLeft)
                weightInc--;
            else
                weightInc++;
            if(weightInc > 100)
                weightInc = 100;
                goLeft = true;
            if(weightInc < 0)
                weightInc = 0;
                goLeft = false;
            double wLeft = weightInc/ 100.0;
            double wRight = (100 - weightInc)/100.0;
            return new double[]{wLeft, wRight};
    }

  • Please help with slicing question

    I'm new to FW and to slicing. I have tried to get all of the info from tutorials and the help that I could.I'm still confused.I'm trying to produce a multi page website mockup with FW using export to CSS and Images.
    I've submitted two other posts with 0 replies. I guess my questions were too broad? I've done some trial and error and tried testing with a simplified version of the multi page website mockup I'm trying to produce. See the simplified file here:
    http://www.openrangeimaging.com/test-posts/slicetest01.png
    The top area would be the header. The lower bar will have some nav tabs. The circle is to be a logo that if clicked on will take the user to the home page.. Below the nav bar is to be two columns with content.
    I have tried different ways of slicing this but cannot get the file to export correctly as CSS and Images. I also can't seem to include the logo as a slice with a link without getting the "overlap" problem. I have been beating myself against this for some time and have not had any success. Any help or advice on where to get help or any reply at all will be most appreciated. Thanks!

    Great, my entire message was wiped out. Here it is again:
    My comments are inline.
    On 2010-10-14, at 2:16 AM, markf12 wrote:
    Jim, thank you for your very helpful reply!
    Honestly I wouldn't even try to directly export this design from FW to a CSS based layout. I think I'd move a lot faster by exporting the graphics from FW and building the design in DW.<<
    This is what I needed to know. Being new to FW I was mistakenly assuming that I could use the Images and CSS to export a clicklable mockup that would also form the html/css basis of the 15 page site I'm designing. I thought that this was possible if only I could figure out how. I expected some pretty involved work in Dreamweaver would be needed. I now understand that for what I'm doing using the HTML and Images is what should be used. Then I develop the site in Dreamweaver using perhaps some images exported from the FW mockup, but not any html or css. Thank you for clearing that up for me! I knew i had some fundamental/core misunderstanding. The export to Images and CSS is only for very simple design.
    JB - It IS possible, but you have to design the site based on certain practices. Overlapping slices is one thing to avoid.
    . If you're new to Fireworks, you really want to keep things simple as  you learn the process. Regardless, a solid knowledge of HTML and CSS is  very important.<<
    Yes I'd like to keep it simple but this is a bit of trial by fire (pun intended) on a project. I have gotten books and other tutorial type stuff on html and css. I would not call my knowledge of it solid as I am new to it. i think I get the gist of it and am determined to become proficient. The only real way to do that is to actually create something/gotta start somewhere so.......
    JB - getting the "gist" isn't enough. If you do not have a solid grounding in HTML and CSS, you will likely run into trouble even IF you successfully export the design, because you will need to to edit and tweak the code once you're in DW. I'd recommend building your first sites "the old fashioned way" first, before trying to automate the process.
    David Hogue has created a great series of CSS export videos on the Fireworks Dev Center. I strongly recommend watching them. Likewise Michel Bozgounov has written an excellent article on setting up a Fireworks document for CSS export:<<
    I had viewed a number of  Dave H's tutorials. I somehow overlooked the ones that you provided a link to. I'm going to watch them straight away. I had read the Article by Michel B. also excellent. I have also read your excellent tutorials and watched your lynda.com video training. I've gained allot from all of this.
    Thanks again for your help!
    JB - You're very welcome. Good luck.

  • Please help, simple requirement using Layers, there must be a solution?!

    Hi, I am using a trial version of Adobe Acrobat X Pro, with a view to purchasing the program for several members of my staff. However, it does not seem to be able to do something fairly simple which I need.. unless someone can help please! I work with maps that come to me as pdfs, and I need to be able to add text items (with arrows) to these maps that are then visible only when certain layers are selected in the new pdf, so that the three sub-contractors I distribute our completed maps to can view either all the text/arrows we have added, or only the info relevant to them if they prefer.
    We've tried saving three maps each with different info on then importing them as three new layers to the original map, but that doesn't give the functionality to interchange views and it's very time-consuming. We've tried using InDesign on trial version but the layers are messy in the exported pdf (adds obsolete layers as a 'feature', the administrator in the InDesign forum said). I've experimented with the pre-flight functions in Acrobat Pro but found them not so user-friendly. Is there a way to select some text items and export them to a tiff with transparent background, then import these as a new layer perhaps? Or please someone tell me I'm being stupid and this was addressed in a simple function since Acrobat v2?!

    Thanks all, I do appreciate these feedbacks, but I am struggling to understand the analogy between a car and iPad. When buying a car in a different location, you are adviced of all the features and then you take a decision if you are okay with it or not. But this was not the case with the iPad. I only found that out after a while being that it is my first iPad. Of course I will not make this same mistake again but I find it challenging that there are no provisions for correct this facetime issues for none residents.
    I assume as you have all continiously stated that I may not make a difference on this as a lone voice but if Apple can consider making it possible for none residents or insisting that this is explicitly mentioned at the point of sales in Duabi for Apple products then it begins to be fair. In the car example, you are at least sure that certain feutures are unavailable and do not realize this after the purchase is done and you are back to your home country.
    I also think saying "Dubai iPad" might not be correct as I always believed I was dealing with Apple product which out to give same level of satisfaction accross the globe....
    I am a frequent traveller and really it would not have been inconveniencing not to buy this iPad when I did as I could have bought it from the UK, US or SA.....but just thought iPad was iPad everywhere.
    Again why do I really have to buy another one? These cost money. And I do not have a shop to sell it as a non-facetime ipad. I would have expected apple center to receive these ipads and replace them or correct them.....
    I am just listing this out incase the Apple team can see some sence in what I am saying. There are a number of ways this current situation would have been avoided for people like me.
    Regards

Maybe you are looking for