Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9143865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T10:07:44+00:00 2026-06-17T10:07:44+00:00

i’m making an xlet app with java, in a scene i now have an

  • 0

i’m making an xlet app with java, in a scene i now have an image that mouse when i enter the right keys. but now i want it to move on a timer, what i have now is a timer and on the ticks it prints the location of my image, and it does that correct zo x and y change. but the image isn’t drawn, can someone help me? here are the 3 files i have:

this is the hellotvxlet class (the main thing):

package hellotvxlet;

import javax.tv.xlet.*;
import org.havi.ui.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import org.bluray.ui.event.HRcEvent;
import org.dvb.event.EventManager;
import org.dvb.event.UserEventListener;
import org.dvb.event.UserEventRepository;
import org.dvb.ui.*;
import java.util.Timer;
//import org.dvb.ui.*;
//import java.awt.event.ActionEvent;
//import org.havi.ui.event.HActionListener;

public class HelloTVXlet implements Xlet, UserEventListener{
    private XletContext actueleXletContext;
    public HScene scene;
    int waardex = 20;
    int waardey = 20;
    // x; y; 
    MijnComponent mc = new MijnComponent("bitmap1.jpg",waardex,waardey);
    // debuggen of niet ?
    private boolean debug=true;

    public HelloTVXlet(){

    }


    public void initXlet(XletContext context) throws XletStateChangeException {
      if(debug) System.out.println("Xlet initialiseren");
      this.actueleXletContext = context;

      HSceneTemplate sceneTemplate = new HSceneTemplate();

      sceneTemplate.setPreference(HSceneTemplate.SCENE_SCREEN_DIMENSION, new HScreenDimension(1.0f, 1.0f), HSceneTemplate.REQUIRED);

      sceneTemplate.setPreference(HSceneTemplate.SCENE_SCREEN_LOCATION, new HScreenPoint(0.0f,0.0f), HSceneTemplate.REQUIRED);

      scene = HSceneFactory.getInstance().getBestScene(sceneTemplate);


      scene.add(mc);



    }


    public void startXlet () throws XletStateChangeException {

    MijnTimerTask objMijnTimerTask=new MijnTimerTask ( );
    Timer timer = new Timer();
    timer.scheduleAtFixedRate(objMijnTimerTask ,0, 100); 
    //star t na 0ms, elke 100ms 



    if(debug) System.out.println("Xlet starten");

    EventManager manager = EventManager.getInstance();
    UserEventRepository repository = new UserEventRepository("voorbeeld");
    repository.addKey( org.havi.ui.event.HRcEvent.VK_UP);
    repository.addKey( org.havi.ui.event.HRcEvent.VK_DOWN);
    repository.addKey( org.havi.ui.event.HRcEvent.VK_RIGHT);
    repository.addKey( org.havi.ui.event.HRcEvent.VK_LEFT);

    manager.addUserEventListener(this, repository);


    scene.validate();
    scene.setVisible(true);
    }

    public void pauseXlet() {

    }

    public void destroyXlet(boolean unconditional)throws XletStateChangeException {

    }

    public void userEventReceived(org.dvb.event.UserEvent e){

        if(e.getType() == KeyEvent.KEY_PRESSED){
        System.out.println("pushed button");
        switch (e.getCode()){
            case HRcEvent.VK_UP:
                System.out.println("vk up");
                waardey --;
                mc.setLocation(waardex, waardey);
                break;
            case HRcEvent.VK_DOWN:
                System.out.println("vk down");
                waardey ++;
                mc.setLocation(waardex, waardey);
                break;

            case HRcEvent.VK_RIGHT:
                System.out.println("vk right");
                mc.setLocation(waardex, waardey);
                waardex ++;
                break;

            case HRcEvent.VK_LEFT:
                System.out.println("vk left");
                mc.setLocation(waardex, waardey);
                waardex --;
                break;


        }
        }

    }


}

This is MijnComponent:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hellotvxlet;

import org.havi.ui.*;
import java.awt.*;
import org.dvb.ui.*;

/**
 *
 * @author student
 */
public class MijnComponent extends HComponent{

    private Image bmap;
    private MediaTracker mtrack;


    public MijnComponent(String bitmapnaam, int x, int y){

    bmap = this.getToolkit().getImage(bitmapnaam);
    mtrack = new MediaTracker(this);
    mtrack.addImage(bmap,0);
    try{

    mtrack.waitForAll();
    }
    catch(Exception e){
    System.out.println(e.toString());
    }
    this.setBounds(x,y,bmap.getWidth(null),bmap.getWidth(null));
}




    public void paint (Graphics g){
    java.awt.Image imgjpg = this.getToolkit().getImage("bitmap1.jpg");
      g.drawImage(bmap, 0,0,null); 
    }

   /* public void MoveLeft(){

    }
    public void MoveRight(){

    }
    public void MoveUp(){

    }
    public void MoveDown(){

    }
    */

}

and this is the timer class:

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package hellotvxlet;
import java.util.TimerTask;
/**
 *
 * @author student
 */




public class MijnTimerTask extends TimerTask {
    HelloTVXlet xlet = new HelloTVXlet();
     int waardex = 20;
     int waardey = 20;
    // x; y; 

public void run ( )
{
System.out.println(xlet.mc.getLocation());
xlet.waardex ++;
xlet.mc.setLocation(xlet.waardex, xlet.waardey);
//int appelsap = (int) xlet.mc.getAlignmentX();
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T10:07:46+00:00Added an answer on June 17, 2026 at 10:07 am

    I don’t see anything that causes the refresh of the display. I think you need to call “repaint()” from the timer run method so that the display is refreshed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into
I have a jquery bug and I've been looking for hours now, I can't
I have a small JavaScript validation script that validates inputs based on Regex. I
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have been unable to fix a problem with Java Unicode and encoding. The
I have thousands of HTML files to process using Groovy/Java and I need to
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.