Simple Java 3D program’s CPU Usage spikes to up to 90 percent!

Hi, everyone. I’m completely new to Java 3D and I’m toying around with basic program structure right now. My code is based off of that in the first chapter on 3D in Killer Game Programming in Java. I removed most of the scene elements, replacing them with a simple grid, Maya style. (Yes, I’m starting off small, but my ambitions are grand – I intend on creating a polygonal modeling and animation toolset. After all, the Maya PLE is dead – damn you, Autodesk! – and I just plain dislike Blender.) I implement a simple OrbitBehavior as a means for the user to navigate the scene. That part was basically copy and paste from Andrew Davison’s code. The mystery, then, is why the program’s framerate drops below 1 FPS and its CPU Usage spikes to up to 90 percent, according to the Task Manager, when I tumble the scene. I’d appreciate anyone taking the time to look at the code and trying to identify the problem area. (I’ve undoubtedly missed something totally newbish. -.-) Thank you!
(Also, I had the worst possible time wrestling with the posting process. Is anyone else having trouble editing their posts before submitting them?)
import java.awt.*;
import javax.swing.*;
public class MAFrame
    public static final Dimension SCREEN_SIZE = Toolkit.getDefaultToolkit().getScreenSize();
    public MAFrame ()
        System.out.println("Initializing...");
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        catch (Exception e) {
            e.printStackTrace();
        JFrame frame = new JFrame ("Modeling and Animation");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        MAViewPanel panel = new MAViewPanel ();
        frame.getContentPane().add(panel);
        frame.pack();       
        frame.setLocation(((int)SCREEN_SIZE.getWidth() / 2) - (frame.getWidth() / 2),
                          ((int)SCREEN_SIZE.getHeight() / 2) - (frame.getHeight() / 2));     
        frame.setVisible(true);
import com.sun.j3d.utils.behaviors.vp.*;
import com.sun.j3d.utils.geometry.*;
import com.sun.j3d.utils.universe.*;
import java.awt.*;
import javax.media.j3d.*;
import javax.swing.*;
import javax.vecmath.*;
public class MAViewPanel extends JPanel
    public static final int GRID_SIZE = 12;
    public static final int GRID_SPACING = 4;
    public BoundingSphere bounds;
    public BranchGroup sceneBG;
    public SimpleUniverse su;
    public MAViewPanel ()
        GraphicsConfiguration config = SimpleUniverse.getPreferredConfiguration();
        Canvas3D canvas3D = new Canvas3D (config);               
        canvas3D.setSize(600, 600);
        add(canvas3D);
        canvas3D.setFocusable(true);
        canvas3D.requestFocus();
        su = new SimpleUniverse (canvas3D);
        createSceneGraph();
        initUserPosition();
        orbitControls(canvas3D);
        su.addBranchGraph(sceneBG);
    public void createSceneGraph ()
        sceneBG = new BranchGroup ();
        bounds = new BoundingSphere (new Point3d(0, 0, 0), 1000);
        // ambient light
        Color3f white = new Color3f (1.0f, 1.0f, 1.0f);
        AmbientLight ambientLight = new AmbientLight (white);
        ambientLight.setInfluencingBounds(bounds);
        sceneBG.addChild(ambientLight);
        // background
        Background background = new Background ();
        background.setColor(0.17f, 0.65f, 0.92f);
        background.setApplicationBounds(bounds);       
        sceneBG.addChild(background);
        // grid
        createGrid();
        sceneBG.compile();
    public void createGrid ()
        Shape3D grid = new Shape3D();
        LineArray lineArr = new LineArray (GRID_SIZE * 8 + 4, GeometryArray.COORDINATES);
        int offset = GRID_SIZE * GRID_SPACING;
        // both sides of the grid plus the middle, done for both directions at once (each line defined by two points)
        for (int count = 0, index = 0; count < GRID_SIZE * 2 + 1; count++) {
            // vertical, left to right
            lineArr.setCoordinate(index++, new Point3d (-offset + (count * GRID_SPACING), 0, offset));  // starts near
            lineArr.setCoordinate(index++, new Point3d (-offset + (count * GRID_SPACING), 0, -offset)); // ends far
            // horizontal, near to far
            lineArr.setCoordinate(index++, new Point3d (-offset, 0, offset - (count * GRID_SPACING))); // starts left
            lineArr.setCoordinate(index++, new Point3d (offset, 0, offset - (count * GRID_SPACING)));  // ends right
        grid.setGeometry(lineArr);
        sceneBG.addChild(grid);
    public void initUserPosition ()
        ViewingPlatform vp = su.getViewingPlatform();
        TransformGroup tg = vp.getViewPlatformTransform();
        Transform3D t3d = new Transform3D ();
        tg.getTransform(t3d);
        t3d.lookAt(new Point3d (0, 60, 80), new Point3d (0, 0, 0), new Vector3d(0, 1, 0));
        t3d.invert();
        tg.setTransform(t3d);
        su.getViewer().getView().setBackClipDistance(100);
    private void orbitControls (Canvas3D c)
        OrbitBehavior orbit = new OrbitBehavior (c, OrbitBehavior.REVERSE_ALL);
        orbit.setSchedulingBounds(bounds);
        ViewingPlatform vp = su.getViewingPlatform();
        vp.setViewPlatformBehavior(orbit);     
}

Huh. A simple call to View.setMinimumFrameCycleTime() fixed the problem. How odd that there effectively is no default maximum framerate. Of course simple programs like these, rendered as many times as possible every second, are going to consume all possible CPU usage...

Similar Messages

  • JDev 10.0.1.3 CPU Usage Spikes - Somewhat Serious!

    I have noticed that JdevW.exe process in task menager has annoying CPU usage spikes every 2-3 seconds. This does NOT happen if I use 10.0.1.2 version.
    I have fairly powerful Dell workstation. Any ideas? Configuration problem?
    BTW embedded OC4J is not running.

    Shay,
    I am actually not doing anything. As soon as I open JDev I can see (and feel) that performance problem. Every time the 'spike' occurs, mouse gets 'frozen' for a fraction of a second. It is anoying a bit.
    My coworker's installation do not have that problem and I wonder if add-ons that I have downloaded and installed would create this behavior. BTW, how do I figure out what add-ons (plugins) I got?
    I can see 'jucheck.exe' and 'jusched.exe' processes as well but even when I killed them the spikes occur.
    Any thought?

  • CPU Usage Spikes - Crashes ITunes

    I've been using Itunes for about a year, and over the past week, my CPU usage will spike at 100% while playing Itunes, causing the song quality to skip and play as if it was a scratched CD. I updated from 4.9 to 5.0 (erasing all existing Itunes programs first) and the problem still happens. I'm not running anything else other than Itunes, and the usage still spikes to 100% causing the problem.
    Please help!

    I'm having the same problem. I've isolated it in a number of ways trying to resolve it.
    It always happens 13 seconds into playing a track. This applies whether it plays from the beginning, 1 min into the track or if I make is jump to different places. Each time, once it has played 13 seconds (ie first 13 secs or if I jump to 1 min immediately it will be at 1:13 or if I play 6 secs then jump to 1:30 it will happen at 1:37). The CPU spikes to 100%, pausing everything and leaving a 3 or 4 sec silence.
    This happens regardless of track length. So a 1 hour dj set will have the CPU spike at 13 secs and then be fine for the next hour.
    It seems to me to be related to some sort of buffering or something similar in Itunes. I have worked out that once it has caused the CPU spike I can restart the same track and it will play through without a hiccup. If I play the next track and then come back to the first track, though, it will glitch at 13 secs again. I can also make it glitch on a replay of the first track without playing any others by changing the tracks that are to come after it in the playlist. This seems to suggest it is related to buffering the coming track(s).
    I can make the silent gaps go away by reducing the size of my music library considerably. It is over 45 gig now. If I reduce it to below 20 gig the CPU spiking occurs but not at 100% and so not causing the silences. The problems is still there, though, and itunes has played my 40 gig library fine for months without any such problems.
    Recent changes have included a few software installs. I have removed those that I could (eg Nero) but I do still have one photo editing programme that I need for a current job. I had removed quicktime from my startup but seeing a suggestion that this caused such a problem I have put it back. This has not fixed the problem for me.
    I have also bought a shuffle and would have probably run the software related to that. If you had a problem when you added a mini perhaps it's due to some sort of error arising from the software coming with new ipods when used with existing itunes installations? Just a guess.
    I'm running Itunes 4.7.1.30. I had thought about upgrading to 5 but it seems to be causing more problems and it seems it doesn't resolve this one.
    If anyone can help with this I would be most grateful as it is making Itunes unusable on my computer. I'm going to have to go back to playing cds!!!

  • CPU Usage Spikes

    My computer was not responding well when I tried to install a driver for my webcam. The error message said that I should try uninstalling some recently installed programs. So I did. There were some that were recently installed but I didn't really known what they were. Since they were recently installed, I didn't think they were necessary. Ever since last night, my computer has been spiking up and down in CPU usage and I don't know what to do. I am not sure if it has to do with the recently uninstalled programs. If so? I don't know which ones I uninstalled to fix the problem. What can I do? Please help!!!!

    Please give us some helpful information..
    Which model computer is this?
    Which Windows does it run?
    Which programs are you talking about?
    When you give us an error message, quote it precisely on a line all by itself. Paraphrasing doesn't help. We don't care what the message means. We want just the string of characters. Spelling counts.
    -Jerry

  • CPU usage spikes to 90%

    Dear all,
    I have 1 Pub, 2 Sub of version 8.0, when  I looked into RTMT, I found increase in the CPU usage to 90%
    Can any one guide how to solve and what is the reason for increase
    I have 2600 ip phones 

    thanks for your comment
    after entering the command 
    admin:show process using-most cpu
    PCPU PID CPU NICE STATE CPUTIME  ARGS
    %CPU   PID CPU  NI S     TIME COMMAND
     7.5 28399   -   0 S 7-15:34:03 /home/tomcat/tomcat /home/tomcat/tomcatJlauncher                                                                                                                     Config.xml -Djava.library.path=/usr/local/lib:/usr/local/thirdparty/java/j2sdk/j                                                                                                                     re/lib/i386:/usr/local/thirdparty/java/j2sdk/jre/lib/i386/server:/usr/lib/pgsql:                                                                                                                     /usr/lib:/usr/local/cm/lib::/usr/local/platform/lib -XX:ErrorFile=/usr/local/thi                                                                                                                     rdparty/jakarta-tomcat/logs/diagnostic-info.jvm-crash.<pid>.tomcat.txt -XX:OnOut                                                                                                                     OfMemoryError=/home/tomcat/tomcat_diagnostics.sh -XX:OnError=/home/tomcat/tomcat                                                                                                                     _diagnostics.sh -Djavax.net.ssl.trustStore=/usr/local/platform/.security/tomcat/                                                                                                                     trust-certs/tomcat-trust.keystore -Djavax.net.ssl.trustStorePassword=CFZLvtE9aAG                                                                                                                     PbFCD -Djavax.net.ssl.trustStoreType=PKCS12 -Djava.util.logging.manager=org.apac                                                                                                                     he.juli.ClassLoaderLogManager -Djava.util.logging.config.file=/usr/local/thirdpa                                                                                                                     rty/jakarta-tomcat/conf/logging.properties -Xmx640m -Xms256m -XX:MaxPermSize=256                                                                                                                     m -Djava.endorsed.dirs=/usr/local/thirdparty/jakarta-tomcat/endorsed -classpath                                                                                                                      :/usr/local/thirdparty/java/bcprov-jdk15-138.jar:/usr/local/platform/jar/xalan.j                                                                                                                     ar:/usr/local/platform/jar/certMgmt.jar:/usr/local/platform/jar/certMonitor.jar:                                                                                                                     /usr/local/platform/jar/Iproduct.jar:/usr/local/platform/jar/Ihardware.jar:/usr/                                                                                                                     local/platform/jar/CiscoIPSec.jar:/usr/local/platform/jar/ciscoCmd.jar:/usr/loca                                                                                                                     l/platform/jar/ciscoCommon.jar:/usr/local/platform/jar/platform-api.jar:/usr/loc                                                                                                                     al/platform/jar/maverick-all.jar:/common/download:/usr/local/platform/applicatio                                                                                                                     n_locale/platform-api:/usr/local/platform/application_locale/cmplatform:/usr/loc                                                                                                                     al/cm/jar/commons-logging.jar:/usr/local/platform/jar/xstream-1.1.2.jar:/usr/loc                                                                                                                     al/cm/jar/log4j-1.2.8.jar:/usr/local/cm/application_locale/cmservices:/usr/local                                                                                                                     /cm/application_locale/car:/usr/local/cm/application_locale/ccmadmin:/usr/local/                                                                                                                     cm/application_locale/ccmuser:/usr/local/cm/application_locale:/usr/local/thirdp                                                                                                                     arty/jakarta-tomcat/bin/bootstrap.jar -Djava.security.manager -Djava.security.po                                                                                                                     licy==/usr/local/thirdparty/jakarta-tomcat/conf/catalina.policy -Dcatalina.base=                                                                                                                     /usr/local/thirdparty/jakarta-tomcat -Dcatalina.home=/usr/local/thirdparty/jakar                                                                                                                     ta-tomcat -Djava.io.tmpdir=/usr/local/thirdparty/jakarta-tomcat/temp start
     7.0 16208   -  10 S 00:00:01 java -DConsoleRows=24 -DConsoleColumns=80 -DCommonFileSystem="disk_full=false,inode_full=false,no_write=false,internal_error=false" -DJvmStartTime=1407911931 sdMain name=ccmadmin priv=4 master
     1.2 18672   -   0 S 1-07:24:04 /usr/local/cm/bin/cmoninit -w
     1.1  1733   -   0 S 1-03:54:14 /usr/local/cm/bin/RisDC
     0.3  1755   -   0 S 09:12:08 /usr/local/cm/bin/amc /usr/local/cm/conf/amc/amcCfg.xml
    what does this mean

  • Help with regular cpu usage spike

    im running a VI thats reading data off a mouse through a VISA driver. i get these strange spikes in cpu usage which are regular at ~12-13 second intervals, which i haven't got a clue as to the cause.
    any ideas??
    Attachments:
    cpu spike.jpg ‏73 KB

    hi all,
       thanks for the suggestions. ive looked with sysinternals, and it appears to be a very minor increase in labview cpu usage - i closed all antivirus related processes, and the spike still continues, so it doesn't appear to be that...
    ive attached the vi, in case its some stupid coding issue..
    apologies for being so ignorant, but how would i go about checking if it's some issue caused by a windows update or whatnot..
    Attachments:
    mouse_reader_no_output.vi ‏44 KB

  • CPU usage spikes while viewing webpage with java script

    Can anyone tell me if it is normal for cpu use to spike up to 90% when I view a webpage that's using javascript? It is a scrolling news headline using java script 1.2 in the webpage.
    Thanks

    Fortunately, while my temps do go up and fan speed increases, mine does not become exceedingly loud. I apparently have a lot of good karma stored up because both the original midplane and its replacement - bad caps - have had quiet fans.

  • How to run the simple java card program in eclipse?

    I am trying to run a simple HelloWorld program in eclipse 3.5 having java card development kit 2.2 installed in it.
    Firstly,I go to the JCWDE tab and press start..then when trying to deploy that package its giving me error like " com.hw.HelloWorld: unsupported class file format of version 50.0." can any one help me in this what is this error???n how to resolve n run this program..

    Hi,
    It is because the converter works on byte code and it only supports a subset of the Java language (see the JC specifications). It is kind of like compiling you code on Java 6 and trying to run it on Java 5. The JCDK outlines the required compiler version.
    Cheers,
    Shane

  • Server CPU usage spikes from networked acoounts

    Hello all,
    I work for a school district and we have recently switched the majority of our users to log in via network accounts (rather than mobile). At random times, the CPU on the server will spike to 100% usage and sometimes stays there for an hour or more. Running 'fs_usage' on the server reveals that certain files and/or dirs are getting hung. The main culprits seem to be Firefox v15 profiles, the AddressBook folder under Application Support, and Microsoft Office 2011 files. I'm wondering if anyone has seen these issues before, or know of something that could be done to alleviate the issue. Most of our clients are running Mac OS X 10.7.4. Our servers run Leopard. It also may be worth noting that many of the people logging in are doing so on laptops (macbook airs).
    Thanks.

    Hello all,
    I work for a school district and we have recently switched the majority of our users to log in via network accounts (rather than mobile). At random times, the CPU on the server will spike to 100% usage and sometimes stays there for an hour or more. Running 'fs_usage' on the server reveals that certain files and/or dirs are getting hung. The main culprits seem to be Firefox v15 profiles, the AddressBook folder under Application Support, and Microsoft Office 2011 files. I'm wondering if anyone has seen these issues before, or know of something that could be done to alleviate the issue. Most of our clients are running Mac OS X 10.7.4. Our servers run Leopard. It also may be worth noting that many of the people logging in are doing so on laptops (macbook airs).
    Thanks.

  • Java thread with high CPU usage

    Hi,
    Running prstat -L -p pid on Solaris produces a list of lwp threads running in that process that are consuming the most CPU. Out of about 7 threads that were associated with kernel threads in pstack output, only 5 of them were mapped to a JVM thread dump. How is it possible to have a Java thread consuming CPU that doesn't show up in a thread dump?
    Thanks,
    J.S.

    And, any idea what this thread is doing?
    Here's pstack output for this missing thread 12:
    ----------------- lwp# 18 / thread# 12 --------------------
    fe0e48b4 __1cHCompileSflatten_alias_type6kMpknHTypePtr__3_ (b6001780, 100360, fe4c8000, b6001780, 100360, 0) + 4d8
    fe0f42ac __1cHCompilePget_alias_index6kMpknHTypePtr__I_ (b6001780, 100360, b6001264, 7e2bb8, 41f4, 7e2bb8) + 8
    fe11131c __1cJStoreNodeFIdeal6MpnIPhaseGVN_pnLPhaseDefUse__pnENode__ (0, 7dd5b4, 5035ec, 7e2bb8, b6001144, b6001264) + 128
    fe0c1224 __1cMPhaseIterGVNNtransform_old6MpnENode__2_ (0, b6001144, 7e2bb8, b6001264, 7e2bb8, b600116c) + 47c
    fe17349c __1cMPhaseIterGVNIoptimize6M_v_ (24, 0, a37700, b6001110, b6001100, 3442f0) + b4
    fe1943b0 __1cOPhaseIdealLoop2t6MrnMPhaseIterGVN_pk0_v_ (b6000ee8, a3772c, 1, 4ff37c, 2000, 269568) + 7cc
    fe1cc89c __1cHCompileIOptimize6M_v_ (b6001780, b60015b8, b6001780, b60015dc, 0, b60013dc) + a0
    fe1cb69c __1cHCompile2t6MpnFciEnv_pnHciScope_pnIciMethod_ill_v_ (91f504, b6001800, db8a24, fe5296b4, b60018a0, b60018b0) + 7bc
    fe1c73f8 __1cKC2CompilerOcompile_method6MpnFciEnv_pnHciScope_pnIciMethod_il_v_ (27b18, b6001af8, db8a24, db8938, ffffffff, 1) + 70
    fe1c79fc __1cNCompileBrokerZinvoke_compiler_on_method6FpnLCompileTask__v_ (db8938, db8a24, fe4eacec, 0, 0, 8d9) + 40c
    fe280964 __1cNCompileBrokerUcompiler_thread_loop6F_v_ (28758, 13a570, fe4c8000, b6001d10, fe4c8000, ffffffff) + 168
    fe216200 __1cKJavaThreadDrun6M_v_ (b5e02000, fe4d3e34, fe4c8000, 1ffd70, 13a570, 1ffd70) + 3d8
    fe213ec8 _start   (fe4c8000, ff325d10, 0, 5, 1, fe401000) + 20
    ff36b734 threadstart (13a570, 0, 0, 0, 0, 0) + 40

  • Simple Java Mail program

    Hi, i have written a simple code to send mail thru java... but it doesnt work... control never comes back after stepping in to the send function.. no exceptions.. no mails sent.. nothin.. cud someone hel me out??
    sometimes i get this exception after a long time:
    javax.mail.MessagingException: Exception reading response;
    nested exception is:
         java.net.SocketException: Connection reset
         at com.sun.mail.smtp.SMTPTransport.readServerResponse(Unknown Source)
         at com.sun.mail.smtp.SMTPTransport.openServer(Unknown Source)
         at com.sun.mail.smtp.SMTPTransport.protocolConnect(Unknown Source)
         at javax.mail.Service.connect(Unknown Source)
    here is the code snippet:
    public void mySend() throws Throwable
    Properties p = System.getProperties();
    p.put("mail.transport.protocol", "smtp");
    p.put("mail.smtp.host", "smtp.gmail.com");
    p.put("mail.smtp.port", "465");
    p.put("mail.smtp.starttls.enable", "true");
    p.put("mail.smtp.auth", "true");
    Authenticator authenticator = new Authenticator()
    protected PasswordAuthentication getPasswordAuthentication()
    return new PasswordAuthentication("vicky.bhandari", "password");
    Session session = Session.getInstance(p, authenticator);
    SMTPMessage message = new SMTPMessage(session);
    InternetAddress fromAddress = new InternetAddress("[email protected]");
    InternetAddress toAddress = new InternetAddress("[email protected]");
    message.setSubject("Test");
    message.addRecipient(Message.RecipientType.TO, toAddress);
    message.setFrom(fromAddress);
    SMTPTransport.send(message);
    Could someone please help me out??

    Hey,
    Im currently having problems with the code below:
    public class SendMail {
         private static final String SMTP_HOST_NAME = "smtp.gmail.com";
         private static final String SMTP_AUTH_USER = "[email protected]";
         private static final String SMTP_AUTH_PWD = "**************";
         public void sendMail(String recipients[ ], String subject, String message , String from) throws MessagingException{
         boolean debug = false;
              Properties props = System.getProperties();
              props.put("mail.transport.protocol", "smtp");
              props.put("mail.smtp.host", SMTP_HOST_NAME);
              props.put("mail.smtp.port", "465");
              props.put("mail.smtp.starttls.enable", "true");
              props.put("mail.smtp.auth", "true");
              Authenticator auth = new SMTPAuthenticator();               
              Session session = Session.getDefaultInstance(props, auth);
              session.setDebug(debug);
              Message msg = new MimeMessage(session);
              InternetAddress addressFrom = new InternetAddress(from);
              msg.setFrom(addressFrom);
              InternetAddress[] addressTo = new InternetAddress[recipients.length];
         for (int i = 0; i < recipients.length; i++)
         addressTo[i] = new InternetAddress(recipients);
         msg.setRecipients(Message.RecipientType.TO, addressTo);
         msg.setSubject(subject);
         msg.setContent(message, "text/plain");
         Transport tr = session.getTransport("smtp");
         tr.connect(SMTP_HOST_NAME, SMTP_AUTH_USER, SMTP_AUTH_PWD);
         msg.saveChanges(); // don't forget this
         //tr.sendMessage(msg, msg.getAllRecipients());
         tr.close();
         tr.send(msg);
         public class SMTPAuthenticator extends Authenticator
         public PasswordAuthentication getPasswordAuthentication()
         String username = SMTP_AUTH_USER;
         String password = SMTP_AUTH_PWD;
         return new PasswordAuthentication(username, password);
    the error i am receiving is:
    java.lang.NoClassDefFoundError: javax/mail/Authenticator
         java.lang.Class.getDeclaredConstructors0(Native Method)
         java.lang.Class.privateGetDeclaredConstructors(Unknown Source)
         java.lang.Class.getConstructor0(Unknown Source)
         java.lang.Class.newInstance0(Unknown Source)
         java.lang.Class.newInstance(Unknown Source)
         org.apache.struts.util.RequestUtils.applicationInstance(RequestUtils.java:143)
         org.apache.struts.action.RequestProcessor.processActionCreate(RequestProcessor.java:292)
         org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:230)
         org.apache.struts.action.ActionServlet.process(ActionServlet.java:1196)
         org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:710)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
    If anyone has any ideas it will be much appreciated
    Thanks in Advance
    Andy

  • Assistance needed with simple java vocabulary program

    I need to construct a java program that can read in text documents. The program must then display an image and prompt the user to input the word that best-describes the image. If the user is incorrect, however, the program must tell the user how many letters the word has and what the first letter is.

    * @(#)words.java
    * @author
    * @version 1.00 2010/6/8
    import javax.swing.*; //class necessary for GUI
    import java.awt.*; //class necessary for GUI
    import java.awt.event.*; //class necessary for GUI
    import java.util.ArrayList; //import ArrayList class
    public class Words implements ActionListener { //ActionListener is required for the button to function
    //initialize values that will be used in other methods
    int noLetters = 0; //number of letters
    String[] words; //words
    JTextField textNL; //inputs number of letters
    ArrayList<JLabel> list;
    public static void main (String[] args) {
         Word s = new Word(); //this is so you are not referencing non-static methods from a static context (main must be static, but the constructor is not)
         s.go();} //runs following method as a method of the object Words s
    public void go() {
         //build GUI
              JFrame frame = new JFrame(); //intializes frame, this is essentially the GUI
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //sets program to stop when frame is exited
              JTabbedPane pane = new JTabbedPane(); //creates a new tabbed panel
              JPanel panel1 = new JPanel(); //creates input panel
              JPanel panel2 = new JPanel(); //creates output panel
              textNL = new JTextField("", 15); //initializes the text field of the same name from the beginning of the program
              JButton button = new JButton("Enter"); //This button will input the data you have entered into the text fields
              button.addActionListener(this); //tells the button to do stuff when it is clicked (see actionPerformed())
              panel1.setLayout(new BoxLayout(panel1, BoxLayout.Y_AXIS)); //Sets frame to display labels and text fields arranged vertically
              panel1.add(new JLabel("Number of Letters")); //this label tells you what the text field is prompting for
              panel1.add(textND); //adds text field to input panel
              panel1.add(BorderLayout.SOUTH, button); //adds button to input panel
              pane.add("Enter Data", panel1); //adds input panel to tabbed panel
              pane.add("Words", panel2); //adds output panel to tabbed panel
              frame.getContentPane().add(pane); //adds tabbed panel to frame
              frame.setSize(400, 400); //sets GUI intial dimensions
              frame.setVisible(true); //displays GUI
              //end of GUI build
    }

  • Any Java API to check CPU usage

    Through java code, is it possible to calculate the System CPU usuage.

    Not unless you can find a native library to do it for you. You can check memory, but not CPU availabilty.

  • Simple Java Bank Program

    Can anyone please help?
    I am looking for a very simple client/server banking Java Application that performs basic function such as view account balance, and being able to deposit and withdraw money from the account.
    Any help would be much appreciated!

    You are asking for an application. I don't think anyone will ever start an open source banking system, because only banks will have an interest in them and they will develop their systems in-house.
    Sorry dude, but you'll have to switch on that brain of yours and do the work yourself.

  • USB Audio device - CPU usage spikes - w520

    I have a LENOVO W520 4276CTO
    Intel Core i7  @ 2.40GHz
    8.00 GB Dual-Channel DDR3 @ 664MHz
    Whenever a USB Audio device is enabled I am experiencing cpu spikes every 8 seconds approx.
    This activity happens with 2 different usb audio devices from 2 different vendors.
    I have used various tools to try and track the problem down such as latency checkers
    LatencyMon indicates a large amount of ISR and DPC activity on the
    usbport.sys driver
    i've been trying to resolve this problem for weeks now and would appreciate any help .
    Thanks
    Glenn

    What USB controller are you using? Not saying it will address your issue but there is a driver update for the Renesas controller (2.1.32.0). When I installed it I had to manually update the driver.
    For your USB devices, are you using their latest drivers?
    You may also want to review kb2529073 to check whether the kb is applicable to you.
    I have played around with a USB external audio device in a dynadock (Toshiba) and no DPC issues but an issue with not being able to run 'Smart Audio' in cpl. The message is 'Failed to initialize smart audio'. So I have to use the system utilities to control the Conexant audio. Have you noticed any issues with the onboard audio tools and your external audio device?
    You may also wish to check the Microsoft site for any Win 7 USB related hotfixes that may help.

Maybe you are looking for

  • A particular form hangs while saving in Oracle Apps 11.5.10.2

    Hi Friends, I am using Oracle Apps 11.5.10.2 on Linux. In a custom Responsibilty ,In a particular form after entering the valuses when i give confirm button the application forms hangs for a long time without saving the values. Please let me know the

  • Fiscal Year Week wise

    Hi SAP Guru, My client is UK base want fiscal year week wise as per below:- Fiscal year Oct to Sept. Month    Day    Period           Year Shift 10          28        1                 +1 11          28        2                 +1 12          35     

  • (Ethernet -- WiFi -- Printer) Problem, routing or bridging fails.

    Hello. I have 2 computers and a printer. computer[192.168.100.2] is running MacOSX and has an ethernet card computer[192.168.100.3] is running ArchLinux 2.6.31 and has 2 interfaces: eth0 - ethernet and wlan0 is wireless (Marvell 99w9335 Libertas, use

  • Mail via a Windows Server

    Any one know how to set up an email address that is generated via a Windows server?

  • WIP valuation with o value

    Dear Gurus, When I am calculating WIP,data has come but without any value (Rs.0) and no error messages come but one information message was come that RA version data was not changed. And also when I am going in details than Information messages was c