How to make smooth hardware accelerated JApplet?

Hi there ive made a game that extends JPanel and im using the paintComponent method to do my painting
as far as i know JPanel is hardware accelerated by default bufferStrategy(2)
ive put the JPanel in a JFrame and the game runs very smooth with ~62fps and cpu usage is <10%
then i tried putting the JPanel in JApplet and opened it in firefoxbrowser and the fps says ~59fps and cpu usage ~30% but its super skippy and looks like its drawing incorrectly like some of the objects are displaced very far from where they are supposed to be some frames and drawn perfectly some other frames. What's happening? Is there anyway to fix this?
Below is some code that for a JApplet and JFrame they both contain the JPanel and ive packed everything in a jar file that can be run as a desktopapp or japplet
I've also tried add the JApplet directly into the JFrame but it seems the performance might go down a little (though im not sure how much)
main extends JApplet
RobotValkyrieAttack extends JPanel
package RobotValkyrieAttack;
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
public class main extends JApplet{
     static LinkedList<Image> listImage;
     //no JApplet constructor is allowed to be overrriden
     public void init(){ //called by the japplet container
          this.loadImages();
          RobotValkyrieAttack r = new RobotValkyrieAttack(listImage);
          this.add(r);
          Thread t = new Thread(r);
          t.start();
          this.addKeyListener(r);
     public void loadImages(){
          //images
          listImage = new LinkedList<Image>();
          listImage.add( new ImageIcon(this.getClass().getResource("data/valkyrie0.png")).getImage() );
          listImage.add( new ImageIcon(this.getClass().getResource("data/astroid0.png")).getImage() );
          listImage.add( new ImageIcon(this.getClass().getResource("data/clouds0.jpg")).getImage() );
          listImage.add( new ImageIcon(this.getClass().getResource("data/cloud0.png")).getImage() );
          listImage.add( new ImageIcon(this.getClass().getResource("data/cloud1.png")).getImage() );
          listImage.add( new ImageIcon(this.getClass().getResource("data/cloud2.png")).getImage() );
          MediaTracker mt = new MediaTracker(this);
          for(int i=0; i<listImage.size(); i++){
               mt.addImage(listImage.get(i),0);
          try{
               mt.waitForAll();
          catch(Exception ex){
               ex.printStackTrace();
     public void update(Graphics g){
          this.paint(g);
     public static void main(String args[]){
          JFrame j = new JFrame();
          j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          j.setSize(1200,700);
          j.setLocationRelativeTo(null);
          main m = new main();
          m.loadImages();
          RobotValkyrieAttack r = new RobotValkyrieAttack(listImage);
          j.add(r);
          Thread t = new Thread(r);
          t.start();
          j.addKeyListener(r);
          main m = new main();
          m.init();
          j.add(m);
          j.setVisible(true);
}

Before we begin, note that performance of Java graphics has always been a bit 'hit and miss' in the sense that the same box with the same hardware and Java version can show radically different FPS rates if the video driver is updated.
For better help sooner, post an SSCCE.
Applet SSCCEs that involve images are a problem. Normally I would invite creators of image based SSCCEs to hot-link to [images available off my site|http://pscode.org/media/#image], but an applet cannot hot-link to images. It will be necessary to generate the images in code, if you want much chance of people running the code. Note that very few people will follow a link to anywhere, or download any 'build zip' or similar, to help out on a problem.
That code snippet as posted, had a number of things that seemed horrific.
- A class called 'main'. O_o Better would be AppletRenderTest which is not only more descriptive, but also uses the common nomenclature for a class name.
- Frame size 1200x700?! It pays to ensure any 'comparison' of applet and application is done at the same size and my screen size is 1024x768. Make it a lot smaller, like 800x600.
- A Swing based Timer is more typically used for Swing animation, than a Thread/Runnable.
- GUI construction should be done on the EDT.
- This..
//no JApplet constructor is allowed to be overrriden..is not only factually wrong, but also incorrectly spelt.
I am not confident you are up to writing:
- Test code (especially test code you intend others to help with)
- GUIs
- Animation code
- Applets
Or if you are capable of parts of that, of combining the 4.
Are you confident?

Similar Messages

  • How to make the shortcut (accelerator) a ContextMenu to be global?

    how to make the shortcut (accelerator) a ContextMenu to be global to the Stage?

    OK, I'm going the applescript route. When I run the script within automator, it works fine. However, when I run the script from a menu as a service, it has no effect at all on iTunes. I must be missing something.
    Here's my script:
    tell application "iTunes"
              if player state is stopped then return
              try
                        set player position to (get player position) + (-5)
              end try
    end tell

  • Where/how can I find hardware acceleration?

    Since I started using Firefox the text fonts are really, really thin and hard to read. So I went thru the questions & answers posted in the help forum. I found a very good answer - it says: Turn off hardware acceleration in Options. I cud not find it, so......
    I come to my question: Where or how can I find Hardware acceleration??

    That preference isn't available in Firefox 3.6.x versions, it is a new preference / feature in Firefox 4.0.

  • How do I enable hardware acceleration in an air exe?

    I have a Stage3d game compiled as a windows bundle (exe) using adt -target bundle. Users download it from Steam and have no idea it's even running Adobe AIR.
    The problem is that if the user has manually disabled hardware acceleration in Firefox, it will also be disabled in my game. In these cases, context3d.driverInfo will say "Hw_disabled=userDisabled". If they open Firefox, right-click on a flash animation, open the security settings box and check "enable hardware acceleration", it will start working on my Adobe AIR game too. (note this isn't on all systems - I can't recreate the problem myself)
    I would love to pop open the display tab of the security panel for them right in my game:
    Security.showSettings(Security.DISPLAY);
    But that command doesn't work in AIR, it only works in browser plugins.
    Explaining to users how to enable hardware acceleration in FF, IE, Safari etc seems like a terrible, confusing solution.
    Any better ideas?
    (also, I think this might be a bug? can anyone point me to documentation saying firefox & air should share settings like this? I went to report it but the bug tracker's down as usual: http://bugs.adobe.com/flex/)

    I found the correct/new link for the bugbase: https://bugbase.adobe.com
    and posted this issue as bug 3843535:
    https://bugbase.adobe.com/index.cfm?event=bug&id=3843535
    It seems to be an unfortunately common problem which I would love to find a workaround for if anyone has any ideas. This would be easier if I could recreate it myself...

  • How can I disable hardware acceleration in Safari 5.1 ?

    for performance testing purposes, I need to do so. Specifically, to disable 2D Canvas hardware acceleration.
    I can't figure out how. Is there any way? I am on Mac. I would like to know about how to do so both on Mac and Windows.

    You can switch acclelerated compositing and accelerated canvas drawing on and off from the Debug menu. To enable this menu run
    defaults write com.apple.safari IncludeInternalDebugMenu 1

  • How to make smooth line movement?

    Hello!
    I've been searching it everywhere, but couldn't find anything in the net. I want to make smooth line movement. I've tried to create motion, but line just moves, and I want it to move smoothly according to the path. What I want to achieve can be seen here:
    http://www.noartistname.com/demo/
    But that's what I did so far - made movement out of several broken lines - how can I make more smooth movement?
    Thanks,
    Aleks.

    the easiest for non-coders is to tween a mask of the full line.  you can also use the flash drawing methods but that takes some coding.  see:
    www.kglad.com , click snippets, function graphs.

  • How to make smooth slow-mo?

    I cannot for the life of me figure out how to slow down clips?
    Currently, I am working in iMovie, and when I slow down the clips, they are really jumpy, even though I shot them at 720p 60fps.
    I can't even find out how to slow clips down in Final Cut Pro X. Once I've done that, how to make them play in SMOOTH slow motion?
    Thanks!
    Jesse

    fox_m wrote:
    …  optical flow, it's really pretty gimmicky -- don't get me wrong, it's a cool effect... … It works really well when there is one thing moving against everything else being still in a shot. Otherwise, it's more like "morphing".
    I find Nearest Neighbor works well enough; …
    Hi fox_m,
    i'm a huge fan of your advices on Motion5 - learning everyday, appreciate your efforts here on the board!
    a) doing tons of sports-videos for my lil' football kickers, I'm for years desperately in search for the 'ESPN-like' super slowmo - on a shoestring budget, a Phantom-cam is no option
    what I noticed with OF in FCPX - it does a wonderful job, under certain circumstances (made a test, click here): this is 60p in a 25p project:
    it becomes obvious - rotation is poison (notice the ball in foreground) and too high angle-speed doesn't perform too (compare legs of player in foreground vs. players in background)
    recording from a tripod, 'far away' or action straight  in axis of cam plus short shutter speed gives good results - and are mostly the ones shown with Twixtor!
    Had the priviledge, playing around with it for 20min on a friends Mac (AE as host) - I was completely lost in its zillions of options - I do understand the concept to tell Twixtor 'background' and 'object', but the interface was way beyond my horizon ...
    b) Next Neighbor? Wot? Did I miss something? 'new' to me, will test today immediately! thanks for input!

  • How to make SMOOTH scrolling with Jtable in Swing automatically ?

    Hi All,
    I'm coding for a price board program, with all records I designed a table for them. So now I want to scroll automatically for all records on that table for customers viewing them. The problem that I can make it scroll smoothly ! Currently I use this block code :
    Thread scollTable;
    int scrollCount = 38;
    public void scrollTable(final int records) {
    if (scollTable == null) {
    scollTable = new Thread() {
    @Override
    public void run() {
    try {
    while (true) {
    if (scrollCount == 38) {
    jTable1.setRowSelectionInterval(scrollCount, scrollCount);
    scrollRowToVisible(scrollCount, jTable1);
    Thread.sleep(4000);
    jTable1.setRowSelectionInterval(scrollCount, scrollCount);
    scrollRowToVisible(scrollCount, jTable1);
    Thread.sleep(1000);
    scrollCount++;
    if (scrollCount == records) {
    scrollCount = 0;
    Thread.sleep(4000);
    jTable1.setRowSelectionInterval(scrollCount, scrollCount);
    scrollRowToVisible(scrollCount, jTable1);
    scrollCount = 38;
    continue;
    } catch(Exception ex) {
    if (!scollTable.isAlive()) {
    //scollTable.setPriority(7);
    scollTable.start();
    public void scrollRowToVisible(int row, JTable table) {
    Rectangle cellRect = table.getCellRect(row, 0, true);
    Rectangle visibleRect = table.getVisibleRect();
    cellRect.x = visibleRect.x;
    cellRect.width = visibleRect.width;
    table.scrollRectToVisible(cellRect);
    The problem I think the progam can not run smoothly with scroll :
    scrollRowToVisible(scrollCount, jTable1);
    Thread.sleep(1000);
    scrollCount++;
    Any helps,
    Thanks.
    Edited by: onlysang2004 on Aug 4, 2009 2:22 AM

    Could you please tell me more detail ? I studied about Swing recently ! I found a link for that javax.swing.Timer : http://forums.sun.com/thread.jspa?threadID=5366085&messageID=10603235#10603235 but how can I use ? In my price board screem doesn't have ActionListener object or button to listen to submit. Can I create an ActionListener object ? Please help me more, how to run smooth scrolling automatically !
    public class ViewElectricHaSTC extends JFrame {
    Thread scollTable;
    public ViewElectricHaSTC(Options options) throws Exception {
    scrollTable(options.getRecord());
    int scrollCount = 38;
    public void scrollTable(final int records) {
    if (scollTable == null) {
    scollTable = new Thread() {
    @Override
    public void run() {
    try {
    while (true) {
    if (scrollCount == 38) {
    //jTable1 created with initComponents method
    jTable1.setRowSelectionInterval(scrollCount, scrollCount);
    scrollRowToVisible(scrollCount, jTable1);
    Thread.sleep(4000);
    jTable1.setRowSelectionInterval(scrollCount, scrollCount);
    scrollRowToVisible(scrollCount, jTable1);
    Thread.sleep(1000);
    scrollCount++;
    if (scrollCount == records) {
    scrollCount = 0;
    Thread.sleep(4000);
    jTable1.setRowSelectionInterval(scrollCount, scrollCount);
    scrollRowToVisible(scrollCount, jTable1);
    scrollCount = 38;
    continue;
    } catch(Exception ex) {
    if (!scollTable.isAlive()) {
    //scollTable.setPriority(7);
    scollTable.start();
    public void scrollRowToVisible(int row, JTable table) {
    Rectangle cellRect = table.getCellRect(row, 0, true);
    Rectangle visibleRect = table.getVisibleRect();
    cellRect.x = visibleRect.x;
    cellRect.width = visibleRect.width;
    table.scrollRectToVisible(cellRect);
    Edited by: onlysang2004 on Aug 4, 2009 7:23 PM

  • How do I disable hardware acceleration? (This option from preferences menu not works on Linux)

    I want to disable hardware accelaration because it freezes my pc at startup.
    I am convinced that HA causes this problem.
    My OS is Crunchbang (http://crunchbang.org/about/) .
    My pc is a pentium 4, nvidia 5200 gpu, nouveau drivers.
    I ask for help at MozillaZIne Forum (http://forums.mozillazine.org/viewtopic.php?f=38&t=2767265) and at Crunchbang forum.
    I disable HA in firefox (preferences and about:config) without result.
    In FireFox General Options "Use hardware accelaration when available" is disabled.
    In about: config gfx.content.azure.enabled is false and gfx.direct2d.disabled (user set) is true.
    Also xorg.conf doesn't help me.
    In xorg.conf (configuration file of Nouveau GPU driver) hardware accelaration is disabled.
    The only solution is to disable nouveau hardware accelaration editing the boot menu (kernel boot parameter : nouveau.noaccel=1) and firefox works.
    But HA is necessary for other applications like OpenOffice.
    If HA is disabled menus, buttons and other UI components do not show properly

    Hello,
    Try disabling graphics hardware acceleration. Since this feature was added to Firefox, it has gradually improved, but there still are a few glitches.
    You might need to restart Firefox in order for this to take effect, so save all work first (e.g., mail you are composing, online documents you're editing, etc.).
    Then perform these steps:
    *Click the orange Firefox button at the top left, then select the "Options" button, or, if there is no Firefox button at the top, go to Tools > Options.
    *In the Firefox options window click the ''Advanced'' tab, then select "General".
    *In the settings list, you should find the ''Use hardware acceleration when available'' checkbox. Uncheck this checkbox.
    *Now, restart Firefox and see if the problems persist.
    Additionally, please check for updates for your graphics driver by following the steps mentioned in the following Knowledge base articles:
    * [[Troubleshoot extensions, themes and hardware acceleration issues to solve common Firefox problems]]
    * [[Upgrade your graphics drivers to use hardware acceleration and WebGL]]
    Did this fix your problems? Please report back to us!
    Thank you.

  • How can I open hardware acceleration for safari 5.1.1 in Windows 7?

    It is said that safari 5 for windows supports hardware acceleration now. But I cannot open this feature in my Windows 7 laptop. Is there any way to open this feature manually?

    I know Safari a little and 5.1 can come to its knees easily and repeatedly.
    At first I thought it lasted longer if:
    disble java, plugins, javascript
    run only in Private Browsing mode
    disable web cache
    I'd like to see it launch with cache disabled and like firefox always start in Private mode.
    Plus site specific preferences
    Still accepts ad and tracking cookies - must consider those to be "well you visited the site" so the site can set whatever it wants.
    I'll use Opera 11.50 instead.
    I tried Windows "trobleshoot compatibility" it wants to set to run it in XP SP3 mode and at the end "incompatible application".
    Settings applied:
    XP SP2 mode
    Disable Aero (iTunes will lose video/movie Window if the desktop is locked for UAC)
    I've lost all borders of windows and tabs, freezes or locks up but no sign of  not responding even though I can't do anything - but I could close Windows and tabs from the Task bar.
    Total PITA and waste of time as I investigate, remove and check for conflicts with Kaspersky and others.

  • How to make smooth line by brush tool using shift key?

    Heya, I have a short question. Is there a way to make smooth line by brush tool using shift key, without that characteristic dot on the begining? I'm using PS CS6 on Win7.
    http://i.imgur.com/orGsIwv.jpg
    Cheers

    The shift key constrains the brush to paint a straight line. Those dark spots you see are from two paint strokes overlapping each other. If the flow or opacity of the brush is not at 100% you can see the stroke below it.

  • How to make smooth text ?

    I have crated instance of textField Object and set property scaleX and Y in large and then I my textfiel  set into Sprite Object. I saw my text in ugly font . How can I have my text in smooth .

    enable advanced anti-aliasing if you're enlarging your textfield.  but the best results are obtained by changing the font size of the textfield rather than by scaling it.

  • How to make smooth motion questions

    Maybe this isn't the best way to achieve optimal results, but here's what I'm trying to do:
    Make a slideshow with many jpegs. Many pics are odd size, so I made a grid inside a 6000 x 720 comp. I've then taken that 6000 comp and placed it into a 1280 comp and animated the x position.
    Q1: I've tried a combination of exports, but nothing looks smooth on a final render to h.264 (the deliverable format). I've noticed that 60fps/ProRes provides nice results, but when I export to 29.97 h.264 it's all jerky.
    Q2: Render hit. It's takes a very long time to render. In general, is there a better way to do this from a render hit perspective?
    Any help greatly appreciated.

    Your description sounds like judder. It's an issue cinematographers have been dealing with in their pans since the beginning of cinema. For a recent example of a Hollywood blockbuster film that messed this up, see the opening shot of Cowboys & Aliens.
    For tips to avoid it in motion graphics, read this.

  • How to make smooth scroll in muse

    I want the smooth scroll effect in my site just like this http://nexgeninnovators.com

    You can try to use anchors on page and link them to fixed positions on page, that would create similar effect.
    But if you are looking for setting up jump scrolling on page then at current stage we cannot setup this with scroll effects.
    Thanks,
    Sanjit

  • How to enable hardware acceleration in desktop Adobe AIR app

    Hello,
    As the author of this post How do I enable hardware acceleration in an air exe? , I am trying to enable hardware acceleration inside my AIR application
    If the user has disabled hardware acceleration in his flash player's settings, context3d.driverInfo will say "Hw_disabled=userDisabled"
    His only way to re-enable it is to open Internet Explorer or Firefox and right click on a flash content, then check "Enable hardware acceleration"
    I (we) would like to be allowed to re-enable it directly inside the AIR app (via actionscript code) and not telling the user to open a browser and check some random checkboxes (cause you know it's not very user-friendly...)
    A bug has been opened here Bug#3843535 - Disabling Hardware Acceleration in IE flash plugin disables it in AIR EXEs and is marked as fixed but nothing is fixed : there's still no way to enable hardware acceleration in desktop AIR application
    Thanks

    Hello,
    I pushed to get this bug fixed and was under the impression that we addressed this back in v16.  Can you share a sample app so I can have our team take a look?
    Thanks,
    Chris

Maybe you are looking for

  • Remote Not Working With QuickTime 7.3.0

    Hi I just upgraded and realized my frontrow remote has stopped working with Quicktime. The remote works with VLC, iTunes etc but not QT. Forget about scanning forward or backward it cant even adjust the volume. I never had the problem before. I have

  • IMac G5 hangs when downloading and installing updates to 10.5

    My iMac G5 hangs when I try to download and install the recent large update to 10.5. Message says restart to complete the installation, but after restart the messages says it is configuring the software, but progress bar shows no progress after sever

  • Display Do u want save changes or not? message while closing the window

    Hi All, I have one requirement.I developed one form that contains 4 windows. I entered in the 3rd window and i have made some changes but not saved.when i close 3rd window it is not giving any message like 'Do u want save changes?'after closing the 3

  • LR5.5 Cannot rate individual images in grid view

    Here's the problem I'm having on LR5.5 on Mac 10.8.5: In grid view, I select a range of images and hit "N" to go into Survey mode. When I highlight a single image and type a 1-4 rating it assigns that rating to every image selected in the survey. Eve

  • FM PYXX_READ_PAYROLL_RESULT not reading wagetype

    Hi All, After customizing Total Compensation statement (TCS) form, PYXX_READ_PAYROLL_RESULT is not reading /4xx wage types in it. Its showing in all standard reports/forms. Please advice.. Thanks, Amit