Start() method in JApplet

It seems that the start() method will not repaint the graphics of the applet untill it return. Following is some code I wrote.
public void start(){
repaint();
m_methode(arg);
System.out.println("start finished");
the m_methode(arg) does some other jobs. But the repaint() method doesn't work untill
I get the message "start finished"
By the way,I didn't use Thread in my program. Many program I saw use Thread to repaint the applet. My question is that it is a must or not to implement runnable if I want to repaint in the middle of program.

repaint() is a method of Graphics or paintComponent not start() or init()

Similar Messages

  • Source2wsdd: ServiceGen does not contain a start method - help!

    Hello all Weblogic Users!
    I would greatly appreciate any help with this problem.
    I am getting this error when I do my build on Linux.
    [source2wsdd] source2wsdd: Doclet class weblogic.webservice.tools.ddgen.ServiceGen does not contain a start method.
    Previously I was getting an error where the ServiceGen class could not be found. This was occuring both in Windows and Linux.
    For Windows, this can be fixed in two ways. 1) Run setWLSEnv.cmd first (in weblogic81/server/bin. 2) (Unconfirmed but try it) Add the tools.jar, weblogic.jar, and webservices.jar to the ant runtimes lib in Eclipse (see preferences/ant/runtimes/global entries. - This will let you run the task inside Eclipse)
    In Linux, I added the webloigc.jar and webservices.jar to the user's special ~/'.ant/lib directory (see ant documentation). This too fixed the problem of being unable to find the ServiceGen class. But now I am getting the error above. I am ripping my hair out trying to fix it.
    Any help would be appreciated.
    Thanks to all....

    Hi bkshn,
    This error is caused by the missing "Main" method in your project. it is the entry point of your project.
    If you want to create a EF project, you could follow the way in the aricle below.
    https://msdn.microsoft.com/en-us/data/ee712907#codefirst
    The Main method is like below.
    class Program
    static void Main(string[] args)
    using (var db = new BloggingContext())
    // Create and save a new Blog
    Console.Write("Enter a name for a new Blog: ");
    var name = Console.ReadLine();
    var blog = new Blog { Name = name };
    db.Blogs.Add(blog);
    db.SaveChanges();
    // Display all Blogs from the database
    var query = from b in db.Blogs
    orderby b.Name
    select b;
    Console.WriteLine("All blogs in the database:");
    foreach (var item in query)
    Console.WriteLine(item.Name);
    Console.WriteLine("Press any key to exit...");
    Console.ReadKey();
    And you could start to learn the EF from the following MSDN blogs.
    https://msdn.microsoft.com/en-us/data/ee712907
    If you have any other concern regarding this issue, please feel free to let me know.
    Best regards,
    Youjun Tang
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Can a thread's start() method be called more than once?

    Is it legal/well-defined to call a Thread object's start() method after a previous call to start() has completed?
    eg.
    Thread t = new Thread(public void run() {...});
    t.start();
    t.join();
    t.start(); // will this call fail?

    Ok, since no one's going to answer you I will.
    Yes. It won't work if you call start() multiple times and it will throw an exception on all subsequent times.
    The way I work around it is to put the method in an inner-class and then create a new instance of that iner-class everytime I want to start a new thread.

  • EJBGen start method error

    Hi,
    I am getting this error while trying to create a sample bean using EJBGen.
    1. I have added the ejbgen.jar to the classpath.
    2. I have set the classpath to the current dir where the AccountBean.java is present.
    I have used the following code in AccountBean.java
    * @ejbgen:entity
    * ejb-name = AccountEJB-OneToMany
    * data-source-name = examples-dataSource-demoPool
    * table-name = Accounts
    * prim-key-class = java.lang.String
    * @ejbgen:jndi-name
    * local = one2many.AccountHome
    * @ejbgen:finder
    * signature = "Account findAccount(double balanceEqual)"
    * ejb-ql = "WHERE balance = ?1"
    * @ejbgen:finder
    * signature = "Collection findBigAccounts(double balanceGreaterThan)"
    * ejb-ql = "WHERE balance > ?1"
    * @ejbgen:relation
    * name = Customer-Account
    * target-ejb = CustomerEJB-OneToMany
    * multiplicity = many
    * cmr-field = customer
    import javax.ejb.*;
    import com.sun.javadoc.*;
    abstract public class AccountBean implements EntityBean {
         * @ejbgen:cmp-field column = acct_id
         * @ejbgen:primkey-field
         * @ejbgen:remote-method transaction-attribute = Required
         abstract public String getAccountId();
         abstract public void setAccountId(String val);
    I am getting the following error.
    C:\>javadoc -docletpath ejbgen.jar -doclet weblogic.tools.ejbgen.EJBGen AccountBean.java
    Loading source file AccountBean.java...
    Constructing Javadoc information...
    javadoc: Doclet class weblogic.tools.ejbgen.EJBGen does not contain a start method
    1 error
    I have checked the EJBGen class file and the start method is present in it. Please suggest if I am missing anything.
    thanks,
    Srikanth.

    even i got the same error, where you able to fix it ?
    i am using weblogic 9.2

  • Run time error when calling Start() method from an Output counter user control in my class.

    I am new to DAQmx and .NET.
    In my application I need to activate a clock out on counter 2 (HW pci 16 E 4).
    I went through all the steps like the sampling examples but instead of Analog input
    I used counter output , and setup the pulse ratios.
    When I click the switch in the user interface ( a user control databinded to the clock output)
    the output works. Since I need to activate it programmatically I tried to call the daQmxUserControl11.Start()
    method but this causes the following error :
    An unhandled exception of type 'NationalInstruments.DAQmx.DaqException' occurred in nationalinstruments.daqmx.dll
    Additional information: Specified operation cannot be performed while the task is running.
    Task Name: DAQmxTask1
    Status Code: -200479
    Any ideas on what am I doing wrong?
    Thanks David

    Thanks a lot,
    I also discovered that dragging the user control onto my user interface doesn't allow alternate activation.
    ( I actually tried stopping and then starting but the result was the same )
    Calling the routines as indicated in the header comments also gave some hiccups ( I had to remark some code to get the system working progrtammatically.
    public void Start()
    #region Update UI
    this.switch1.Caption = "On";
    this.switch1.Value = true;
    #endregion
    daqmxTask.Start();
    public void Stop()
    #region Update UI
    this.switch1.Caption = "Off";
    this.switch1.Value = false;
    #endregion
    daqmxTask.Stop();
    #region Methods

  • How to invoke a method in JApplet from javascript.

    We want to invoke a method in JApplet from javascript.
    with the help Java Plug-in HTML Converter Version 1.3, we have generated OBJECT/EMBED tag for
    the following applet tag.
    <APPLET CODE = "SimpleApplet" WIDTH = 200 HEIGHT = 300 NAME = "simpleApplet"
    MAYSCRIPT = true>
    <PARAM NAME = "p1" VALUE = "v1">
    </APPLET>
    it is given the following code
    <!--"CONVERTED_APPLET"-->
    <!-- CONVERTER VERSION 1.3 -->
    <OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
    WIDTH = 200 HEIGHT = 300 NAME = "simpleApplet"
    codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0">
    <PARAM NAME = CODE VALUE = "SimpleApplet" >
    <PARAM NAME = NAME VALUE = "simpleApplet" >
    <PARAM NAME = MAYSCRIPT VALUE = true >
    <PARAM NAME="type" VALUE="application/x-java-applet;version=1.3">
    <PARAM NAME="scriptable" VALUE="false">
    <PARAM NAME = "p1" VALUE = "v1">
    <COMMENT>
    <EMBED type="application/x-java-applet;version=1.3" CODE = "SimpleApplet" NAME =
    "simpleApplet" WIDTH = 200 HEIGHT = 300 MAYSCRIPT = true p1 = "v1" scriptable=false
    pluginspage="http://java.sun.com/products/plugin/1.3/plugin-install.html"><NOEMBED></COMMENT>
    </NOEMBED></EMBED>
    </OBJECT>
    <!--
    <APPLET CODE = "SimpleApplet" WIDTH = 200 HEIGHT = 300 NAME = "simpleApplet"
    MAYSCRIPT = true>
    <PARAM NAME = "p1" VALUE = "v1">
    </APPLET>
    -->
    <!--"END_CONVERTED_APPLET"-->
    But, even after trying to invoke method in the JApplet from javascript, it is not being invoked in
    Netscape. it is being invoked from
    IE after changing the scriptable = true. Is there any such parameter to change, to invoke the
    method in JApplet from javascript?
    can anybody give any suggestion?

    hi there,,
    well the same problem exists with my code also, NS fails to call the function from java applet... if u get the answer please mail me on [email protected]

  • Dependencies and start method

    Hi all,
    Am I right assuming that the execution of start method (start/exec) takes place after all dependencies of an instance have been resolved ?
    TIA
    oliver

    That's right.
    - Stephen

  • Can start method invoke twice at one instance

    I am using JBoss and writing a class which extends Thead. I would like to ask can I invoke start() method twice to an instance of that class. I've tried it but it seems that the object did nothing when start() method is invoked at the second time.

    Any Thread can only be start()ed once.
    Also, prefer implementing Runnable to extending Thread. Think of Threads as the workers and Runnables as the job itself. You implement Runnable because your "unit of work" or whatever you want to call it IS-A Runnable -- that is, something that will do its job start-to-finish when you call run. You would only extend Thread if your class IS-A Thread -- that is, it has a reason to do everything Thread does, and you need to slightly add to or modify Thread's behavior.

  • Thread start() method problem

    I have a program server-client program that have a lot thread but
    when I called thread.start() method it doesn't return run() method.
    even so my input-output codes is running ( my client program can send data to server program )
    Please help me

    yasinmalli wrote:
    start() method doesn't call run() method of thread when I debug row to rowIt does, but the debugger will only ever follow the flow of the current thread and therefore not step into the run method. Set a breakpoint at the very beginning of your run() method and then step over the start() method, you'll see that the new thread will break exactly at that breakpoint just after start() was executed.

  • Why java allow start() method only once for a thread

    Hi ,
    Why java allows start method only once for thread . suppose
    Thread t = new Thread();
    t.start();
    say at later stage if again we call t.start() IllegalStateException is thrown , even though isAlive method returns false.
    Hence the question , why start() method is allowed only once.If you need start a thread , we need to create a new instance.

    Really. Why do you think that? Do you have any evidence? It is one of the first things I would think of, personally.Considering that the Thread API doesn't allow you to specify a stack address (only stack size), I think it demonstrates they wanted to remove that capability from their Thread API all together. That missing "capability" makes me believe they want me to believe it's not something I need to worry about when using their API... I think the exact semantics of the Thread class and its methods were driven by how to make it most understandable and usable for their customers. I'm certain this issue was one of many that was given considerable thought during the design and implementation of the JVM and the underlying runtime classes.
    Do I have any evidence? No. But if you can point me at some first-hand information on this, I'd love to read it. Most of what I've found is second or third hand accounts. (and I mean that sincerely, not as a smart-ass remark or rebuke of your comments).
    On the one hand you seem to think the Java API designers are idiots, on the other hand you think that they should be. I can't make it out.I thought my position was that the Java developers were talented enough to implement platform in whatever way their API called for; hence, the designers made a choice about how they wanted their API to be used by their customers. They decided which capabilities they wanted to include or exclude, and created an API that was consistent with their vision for this technology. While I'm certain technical limitations had an effect on the API design, I certainly don't think the API was dictated by the them.
    I think the current design of the Java Thread API was a reflection of their vision to make Threading easier and more accessible to Joe Programmer, not limitations in the implementation. I never said it was wrong or that I could do better... I just said I think they could have done something different if they decided it would have made for a better customer experience. But hey, maybe I'm wrong.

  • Help with Reg Expression Start method

    Hi there,
    I've been looking through some examples of regular expressions and I've became totally unglued at what the start method of the Matcher class returns.
    Here's the example...
    Passing in "\d*" ab34ef to the following code
    import java.util.regex.*;
    public class Class1
      public static void main(String []args)
        Pattern p= Pattern.compile(args[0]);
        Matcher m=p.matcher(args[1]);
        boolean b=false;
        while (b=m.find())
          int x=m.start();
          String y=m.group();
          System.out.print(x + y);
    }Gives the output
    01234456
    I understand eveything apart from the 6 character. How can m.start()return 0 (at the start) and 6 at the end when the string being searched is 6 characters long.
    My head hurts.

    The fact that a string is an array of characters under the hood is just an implementation detail, and it's getting in your way. What start() returns is the beginning position of a substring which may have a length of zero.
    The first time through the loop, the regex matches a zero-length substring at the beginning of the target string. That's the position preceding the first character, index 0. Then, because the match didn't consume any characters, the Matcher moves ahead one position before trying again. Another zero-length match, another bump-along, and now it's at index 2. This time, the regex can actually match some characters. It matches the substring "34", and that brings us to the part that's really confusing. Because the previous match consumed some characters, the Matcher doesn't do a bump-along before attempting the next match. It matches a zero-length substring at index 4, right where the previous match ended. Then it bumps along to index five and does another zero-length match.
    Now, you and I know that the character at index 5 is the last one in a string whose length is 6, so there's no reason to look for any more matches at this point. And if the regex were required to match at least one character, the Matcher wouldn't bother trying again. But in this case a zero-length match is considered valid, and there's one more position where that's possible. It does one last bump-along and matches nothing once more.

  • How  start() method map run()

    Can any one give me some idea-
    How thread start() method calls run() method of Runnable interface???
    Please help me?

    There's no trick to it, I assume the start() method contains a call to someRunnable.run();
    Example:
    public void start() {
        doStuff();
        runnable.run();
    }Of course it can't be that simple since start must return immediately and run() will continue running in it's own thread...
    In other words, you don't need to worry about that.

  • IMFMediaSession::Start method stops working on second intance

    I have created a test app modeled on the playlist example in the vista sdk. I modified it a bit to play video and loop with the skip function. I then set it up to create two windows with a player in each. Now with one window it plays just fine and loops
    as expected. When I add a second window with another playlist something strange begins to happen. The first window plays and loops just fine, but when it comes to the second window, when it gets to the end of the sequencer source, it triggers the MEEndOfPresentation
    event. The code is set to call the skip function, which it executes fine. Then the player just goes black. It must still be playing or something, because if I wait the player will start playing again. If I wait even longer it will go black again. Now the whole
    time the first window is running fine.
    I have built this test app with the following example
    https://msdn.microsoft.com/en-us/library/ms697285(v=vs.85).aspx
    I could post the code for the test app, but it is quite a bit. I am hoping someone might have a clue to what the problem is before I fill this thread with code. I would appreciate it if someone could help me work through this problem.
    Edit: I have put the code, sample files I used, and a mftrace file here
    https://onedrive.live.com/?cid=C549C64FC840D296&id=C549C64FC840D296%21109
    Thank You

    uploaded the code^^^^^

  • JApplet / application init / start progress status feedback

    We used to put up a separate JFrame during the initization/startup of our applets/applications for status messages. While o.k. for Java Webstart / application modes (& maybe standalone applet mode), this was not pretty for customers embedding our apps in portals.
    So, the goal became to show custom progress/status on the "gray screen" initial applet contentpane until our app desktop is ready to show. Known threading / painting issues during applet startup made this task somewhat non-trival.
    Searched around here on the jdc & found a nice little Moving Ball class & used that as a base for the play app below. Thought I'd post this back to jdc in case anyone else finds it useful. The JApplet code has a main, so same code should work for the app whether deployed as a (plug-in) applet, application JAR or Web Start app.
    The code should show a RED moving ball during init, a YELLOW one during start and a GREEN one after start method is done (w/ball x position update in scrolling pane)....
    import javax.swing.*;
    import java.awt.*;
    import java.awt.event.WindowListener;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
        cforster: Uses Ball painting code (from jdc) & separate status area to simulate JApplet
        startup msgs to be shown to user during applet init...
        Point is to show status during applet/application initialization (init / start) methods...
        Can JAR this up & try in appletviewer or using 1.4.2+ plugin, etc.
        With main() also usable in application / Webstart mode....
        If going the application route (or double-click JAR route), need JAR manifest.mf like:
        Manifest-Version: 1.0
        Main-Class: Today
        Created-By: 1.4.2 (Sun Microsystems Inc.)
    public class Today extends JApplet {
        private static Today inst;
        //  Ball color will change from RED (init) -> YELLOW (start) -> RED (start done)
        Color ballColor = Color.RED;
        final int colorSleep = 3000;    // Time to waste in init & start methods
        final int pauseSleep = 25;      // Time between Ball moves/draws
        JTextArea jta = new JTextArea("===  Status  ===" + "\n", 50, 132);
        MovingBall movingBall = new MovingBall(jta);
        public static Today getInstance() {
            if (inst == null) inst = new Today();
            return inst;
        public Today() {
            super();
        public void init() {
            setVisible(true);
            getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
            movingBall.setPreferredSize(new Dimension(400, 100));
            movingBall.setBackground(Color.lightGray);
            getContentPane().add(movingBall);
            jta.setEditable(false);
            jta.setBackground(Color.lightGray);
            getContentPane().add(new JScrollPane(jta));
            movingBall.start();
            validate();
            try {
                Thread.sleep(colorSleep);
            catch (InterruptedException ie) {      }
        public void start() {
            ballColor = Color.YELLOW;
            validate();
            try {
                Thread.sleep(colorSleep);
            catch (InterruptedException ie) {       }
            ballColor = Color.GREEN;
        public void stop() {
            movingBall.stop();
        public static void main(String args[]) {
            final Today CallingApplet = Today.getInstance();
            JFrame frame = new JFrame("Moving Ball / Load status");
            frame.getContentPane().setLayout(new BorderLayout());
            frame.getContentPane().add("Center", CallingApplet);
            // Use an adapter to close the window
            WindowListener listener = new WindowAdapter() {
                public void windowClosing(WindowEvent e) {
                    System.exit(0);
            frame.addWindowListener(listener);
            frame.setBackground(Color.lightGray);
            frame.pack();
            frame.setSize(400, 400);
            frame.show();
            CallingApplet.init();
            CallingApplet.start();
        class MovingBall extends JPanel implements Runnable {
            final int xPos_Start = 8;
            int xPos = xPos_Start, yPos = 100, rad = 10;
            boolean moveForward = true;
            Thread thread;
            Graphics dbg;
            Image dblImage;
            JTextArea jta = null;
            MovingBall ball = this;
            // Takes in JTestArea that is supposed to be the status msg area...
            // In practice, the staus area & updates are elsewhere...
            public MovingBall(JTextArea jta) {
                this.jta = jta;
            public void start() {
                Thread ballThread = new Thread(this);
                ballThread.start();
            public void run() {
                Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
                yPos = getHeight() / 2 + (rad / 2) + rad;
                while (true) {
                    if (moveForward)
                        xPos++;
                    else
                        xPos--;
                    if (xPos > getWidth() - (2 * rad))
                        moveForward = false;
                    else if (xPos < xPos_Start + (2 * rad)) moveForward = true;
                    SwingUtilities.invokeLater(new Runnable() {
                        public void run() {
                            if (xPos % 20 == 0) {
                                jta.append("xPos = " + xPos + "\n");
                                jta.setCaretPosition(jta.getText().length());
                            ball.paintImmediately(ball.getBounds());
                    try {
                        Thread.sleep(pauseSleep);
                    catch (InterruptedException ie) {
                        break;
            public synchronized void stop() {
                thread = null;
    /*  Not needed for Swing Component (only AWT ?)
              public void update(Graphics g)
                   if(dblImage == null)
                        dblImage = createImage(this.getSize().width, this.getSize().height);
                        dbg = dblImage.getGraphics();
                   dbg.setColor(getBackground());
                   dbg.fillRect(0, 0, this.getSize().width, this.getSize().height);
                   dbg.setColor(getForeground());
                   paintComponent(dbg);
                   g.drawImage(dblImage, 0, 0, this);
            public void paintComponent(Graphics g) {
                g.setColor(getBackground());
                g.fillRect(0, 0, getWidth(), getHeight());
                g.setColor(ballColor);
                g.fillOval(xPos - rad, yPos - rad, 2 * rad, 2 * rad);
    }If anyone plays with this & finds issues/problems or makes improvements to its mechanism, would be nice to post back to this thread.

    hello,
    I found that while configuration of AM there was an warning
    Command deploy executed successfully with following warning messages: Error occurred during application loading phase. The application will not run properly. Please fix your application and redeploy.
    WARNING: com.sun.enterprise.deployment.backend.IASDeploymentException: ContainerBase.addChild: start: LifecycleException:  java.lang.NoClassDefFoundError
    Successfully deployed /amserverthis might help in resolving the issue.
    regards,
    sumant

  • JApplet class key methods

    JApplet class has following key methods:
    public void init()
    public void start()
    public void paint( Graphics g )
    public void stop()
    public void destroy()
    I have an applet that only uses the key method init() and I don't have multithreaded logic and it seems to work just fine. Why does my applet work without specifically invoking the other JApplet class key methods? Are any of these key methods called by a default version for the key method?

    So are you saying that if I don't define start()
    method by overriding or overloading the browser's
    start() method, then the browser's start() method
    places the applet thread into ready state even though
    I don't have any other threads?No. I say if you do not redefine start() and stop(), that doesn't mean that they're not defined. They are in fact implemented (though they are empty), and the browser calls them. Depending on what your applet does, it won't need to explicitely start something in it's start() method, it will run anyway, like calculator applet for example.
    BTW, how do I find the declarations and definitions of
    the browser's key methods?I'm not sure about what you mean by "browser's key methods". You shouldn't need to care to much about what the browser does...

Maybe you are looking for

  • Valuation type in case of stock transport order

    Hi, We are spilt valuation. now we are doing stock transport order and it is asking for valuation type. while we dont want to enter valuation type in STO. as which material is to sent to plant, we know at that time of delivery. but during making STO

  • Onclick or onsubmit which is better?

    Hello, Adding JS validation onclick of a submit button or adding JS to form onsubmit, which is better?. What is Adv and Dis?. <form name="frm" method="post"> <input type="Submit" name="Submit" value="Submit" onclick="return JSCheck(this.form)"> </for

  • I can't find any animation in the libary.

    I just downloaded iMovie for the Apple Store. I am busy with creating a movie and I can't find any animations in the libary. I only have maps and backgrounds.

  • Macbook air wifi connection problem?

    Hello Apple Communities So i recently pre-ordered a custom built 13inch macbook air, and i am just wondering if theres still any issues with the wifi connection. I living in Australia by the way. Thanks!

  • Glitched iPod showing yellow letters, won't sync, itunes unknown error 1621. Help please!

    6th generation touch screen ipod, only 1 week old.  While I was running, the music volume got loud, and then the ipod quit.  When trying to turn it back on, the ipod will only go to a screen with yellow lettering that reads: N20  Snowfox (4ao432) Vol