Simple include problem (i think)

Here is my code:
import java.awt.*;
import java.awt.event.*;
import javax.media.j3d.*;
public class Example01 extends Frame
     public static void main(String args[])
          new Example01();
        public Example01()
               super("Java 3D Example01");
               setSize(400,300);
               Canvas3D myCanvas3D = new Canvas3D(null);
               add("Center",myCanvas3D);
               setVisible(true);
               addWindowListener(new WindowAdapter()
               public void windowClosing(WindowEvent e)
                    dispose();
                    System.exit(0);
               View myView = constructView(myCanvas3D);
               Locale myLocale = constructViewBranch(myView);
               constructContentBranch(myLocale);
     private View constructView(Canvas3D myCanvas3D)
               View myView = new View();
               myView.addCanvas3D(myCanvas3D);
               myView.setPhysicalBody(new PhysicalBody());
               myView.setPhysicalEnvironment(new PhysicalEnvironment());
          return(myView);
     private Locale constructViewBranch(View myView)
               VirtualUniverse myUniverse = new VirtualUniverse();
               Locale myLocale = new Locale(myUniverse);
               BranchGroup myBranchGroup = new BranchGroup();
               TransformGroup myTransformGroup = new TransformGroup();
               ViewPlatform myViewPlatform = new ViewPlatform();
               myTransformGroup.addChild(myViewPlatform);
               myBranchGroup.addChild(myTransformGroup);
               myLocale.addBranchGraph(myBranchGroup);
               myView.attachViewPlatform(myViewPlatform);
               return(myLocale);
     private void constructContentBranch(Locale myLocale)
}And this is the error I get when I run it:
Exception in thread "main" java.lang.NullPointerException: Canvas3D: null Graphi csConfiguration
at javax.media.j3d.Canvas3D.checkForValidGraphicsConfig(Canvas3D.java:96 3)
at javax.media.j3d.Canvas3D.<init>(Canvas3D.java:1006)
at Example01.<init>(Example01.java:17)
at Example01.main(Example01.java:9)
carsonj@newark:~/Project/ProjectCode$ java Example01.java
Exception in thread "main" java.lang.NoClassDefFoundError: Example01/java
Any help would be appreciated, thanks!
Edited by: tesla66 on Oct 12, 2007 5:12 AM

import java.awt.*;
import java.awt.event.*;
import javax.media.j3d.*;
public class Example01 extends Frame
public static void main(String args[])
new Example01();
public Example01()
super("Java 3D Example01");
setSize(400,300);
Canvas3D myCanvas3D = new Canvas3D(null);
add("Center",myCanvas3D);
setVisible(true);
addWindowListener(new WindowAdapter()
public void windowClosing(WindowEvent e)
dispose();
System.exit(0);
View myView = constructView(myCanvas3D);
Locale myLocale = constructViewBranch(myView);
constructContentBranch(myLocale);
private View constructView(Canvas3D myCanvas3D)
View myView = new View();
myView.addCanvas3D(myCanvas3D);
myView.setPhysicalBody(new PhysicalBody());
myView.setPhysicalEnvironment(new PhysicalEnvironment());
return(myView);
private Locale constructViewBranch(View myView)
VirtualUniverse myUniverse = new VirtualUniverse();
Locale myLocale = new Locale(myUniverse);
BranchGroup myBranchGroup = new BranchGroup();
TransformGroup myTransformGroup = new TransformGroup();
ViewPlatform myViewPlatform = new ViewPlatform();
myTransformGroup.addChild(myViewPlatform);
myBranchGroup.addChild(myTransformGroup);
myLocale.addBranchGraph(myBranchGroup);
myView.attachViewPlatform(myViewPlatform);
return(myLocale);
private void constructContentBranch(Locale myLocale)
}Like This

Similar Messages

  • JDeveloper IDE simple setting problem

    Hi,
    Recently we switched to JDeveloper from Visual Cafe .I have a simple setting problem.How can I set the options so that IDE gives, the core java classes and packages,and our application classes and packeges, prompts in imports as well as in code.Where to set the options.
    eg: when I write
    import java. it should prompt all the pakages.
    Thanks in advance.
    -Gopal
    null

    I am not sure I understand what you are requesting, but ...
    You can configure JDeveloper projects to include various libraries by default.
    This is done by selecting menu Tools | Default Project Properties.../ Libraries tab.
    You should define a library for your classes.
    You can import any of the packages / classes from all the libraries which your project includes.
    It would be incorrect for a tool to automatically add a bunch of import lines at the top of every file because each file should import what it needs and just as importantly, not import what it does not need depending on the component type (e.g. a servlet should not include javax.swing.* ).
    An easy way to import elements into JDeveloper is to type in something like:
    import java.
    // and then type in Ctrl Space
    and this launches the package browser, you can select packages or classes to import.
    You can also do this at the variable declaratiton point such as typing in:
    foo() {
    Frame x
    // Press Control Alt Space
    and this will correctly change the type (Frame) to the type you select in the package browser and add the import statement.
    -John
    null

  • Real simple xslt problem/question

    Hi, i have a real simple xslt problem but i just cant figure out how to do it by looking at various examples on the net. i have a xml document and in it are some elements with a "result" tag name. i want to use xslt to reproduce exactly the same xml document except with an attribute called "id" added to those elements with a "result" tag name. i'm sure that theres a simple solution to it but i just cant figure it out. any helps greatly appreciated, thanks

    Start with the XSLT identity transform (I don't have it handy and it's fairly long, but you should be able to google it up). Add this:<xsl:template match="result">
      <result id="">
        <xsl:apply-templates>
      </result>
    </xsl:template>

  • I have a problem with iPhone is that I can replace it at points of sale in the U.S. because I bought from Saudi Arabia because the problem I think in the hard ware software worked more than 3 times did not fix

    dears,
    I have a problem with iPhone is that I can replace it at points of sale in the U.S. because I bought from Saudi Arabia because the problem I think in the hard ware I do resoftware more than 3 times did not fix.
    Network also always missing.
    I am living in KS Wichita. I hope you help me pleas.
    Regards.

    iPhone warranty is not international. You will have to return your
    iPhone to Saudi Arabia for repair/replacement. Either take it back
    yourself or send to friend/relative for them to take to Apple. Apple
    will not accept international shipments for repair nor will Apple
    ship repaired/replaced iPhones out of the country where the repair
    was done.

  • I have a question my iphone4s has a problem when updated iOS8 there will be freeze problem i think iOS8 is not supported in 4s!!!!!!!!!

    i have a question my iphone4s has a problem when updated iOS8 there will be freeze problem i think iOS8 is not supported in 4s!!!!!!!!!.
    one more question when i phone5 update with iOS 8.1.2 this iOS supported iphone5???

    Hi Ios 8.1.2 Should work on iPhone 4s / 5 You may have a bug Backup to  cloud over WiFi Then Restore back to Factory  Settings This will make iPhone as new. Use same Apple ID & you will get your Apps & Data back Do Restore over your WiFi. Cheers Brian

  • I am having the same problem I think.  With mobileme you simply copy documents to the idisk folder and then synch.  I cannot seem to sink that folder anymore.  Any idea as to how I can simply copy folders to icloud and then access the MS Word and PDF file

    I am having the same problem I think.  With mobileme you simply copy documents to the idisk folder and then synch.  I cannot seem to sink that folder anymore.  Any idea as to how I can simply copy folders to icloud and then access the MS Word and PDF files on my iphone?

    Apple never bopthered to explain that this would happen
    Your iDisk is still accessible after moving to iCloud in exactly the same way as before. Nothing is deleted until June 30th 2012.
    , so I could easily have lost ALL of the files I kept on iDisk.
    No, you couldn't. Firstly, nothing was deleted from your iDisk. Secondly, any files stored on your iDisk should never be your only copy. Even if your iDisk spontaneously combusted, you should keep local backups elsewhere.
    Does Apple WANT people to move their storage elsewhere and stop paying Apple for it?
    Yes. Apple doesn't provide such a service anymore, nor are you paying them for it.
    Apple has made no effort to suggest remedies for the problem it has given iDisk users
    They've provided instructions on how to download your files from your iDisk. What you do with them after that is your choice.

  • Simple OOP Problem. Help!

    This is just a simple OOP problem that i cant decide on a best
    implementation for.
    im passing an object to an instance of, 'TabbedFrame', which is just
    a frame with a Tabbed Pane in it that is holding custom panels.
    however, these custom panels need access to the object being
    passed to 'TabbedFrame' and to some methods in it.
    i cant make them static however so how do i gain access to them?
    is my only option to pass the 'TabbedFrame' to each panel?
    like - jtabbedpane.add( "Panel 1", new mypanel1(this));
    here is code:
    new TabbedFrame( DataObject );
    public class TabbedFrame{
    public TabbedFrame(DataObject do){
    this.do = do;
    jtabbedpane.add( "Panel 1", new mypanel1() );
    DataObject do;
    public class mypanel1{
    public mypanel1(){
    // need access to DataObject of the 'TabbedFrame' object that instantiated
    // this 'mypanel1' and to some of its methods
    }i would just pass the DataObject to evey panel (there are 12) but
    i also need to be able to call methods in the 'TabbedFrame'.
    Any help would be appreciated!

    Modify mypanel1's constructor:
    public class mypanel1{
    TabbedFrame tf;
    public mypanel1(TabbedFrame tf){
    this.tf = tf;
    // need access to DataObject of the 'TabbedFrame' object that instantiated
    // this 'mypanel1' and to some of its methods
    DataObject theDo = tf.getDataObject();
    tf.someMethod(); // Call method on the TabbedFrame
    }In TabbedFrame:
    public TabbedFrame(DataObject do){
    this.do = do;
    // Modify call to constructor to pass "this" TabbedFrame.
    jtabbedpane.add( "Panel 1", new mypanel1(this) );
    }

  • Simple Problem i think

    My problem is that i dont know how to call a function in the DrawSquare class from another class. I want to call the function from at the * any ideas?? Any help is really appreciated.(I know this is probably a really stupid question)
    frame.getContentPane().add(new *,BorderLayout.CENTER);

    From the looks of your line of code, you want to add a Component to a JFrame. "... call a function" implies calling a method of a class, but I think you are asking how to add an instance of the class to the frame.
    First, to DrawSquare needs to be a Component, perhaps a JPanel? So in the source code you need to have "public class DrawSquare extends JPanel" for example. Then you can just use frame.getContentPane().add(new DrawSquare(),BorderLayout.CENTER); assuming you have a no-argument constructor in DrawSquare.

  • SimpleButton, simple problem I think

    I've been modifying a slideshow class I've found on the web
    and need a little direction. Everything is working fine except the
    button I'm trying to add.
    I want a button that covers part of the stage and I've
    created that. I just cant seem to figure out how to add
    addEventListener to it.
    I'd like to add an event listener like:
    stageButton.addEventListener(MouseEvent.CLICK, onClick);
    Any suggestions?
    Thanks

    btn.addEventListener(MouseEvent.CLICK, onClick);
    throws this error:
    TypeError: Error #1009: Cannot access a property or method of
    a null object reference.
    at
    XMLSlideshow/showLoadResult()[C:\WWW\Src\flash\XMLSlideshow.as:270]
    Line 270 is - btn.addEventListener(MouseEvent.CLICK,
    onClick);
    I've included the entire class below for review. If I add the
    event to the stageBtn function(commented out in example) then call
    the function(also commented out in example) it works but the
    navigation(stop, play, forward, reverse) then follows the links
    even though its not under the button.
    Thanks for looking

  • Adding a new class with Creator (really simple problem i think..)

    I added a new class to my project with creator...
    class name is "CambiaNote" and there's a method called Cambia
    tabellaselezionabile is my project(package)
    I tried to run everything but It gave me an error:
    Exception Details:  org.apache.jasper.JasperException
      Error getting property 'cambia' from bean of type tabellaselezionabile.Page1I don't know, but the word cambia don't exists at all in my code... or it is not case sensitive..?
    please help, thanks

    typo: correct Paint() to paint()

  • Logo/picture to menubar? simple css problem?

    Hi, I'm having a problem getting a logo to appear correctly in a horizontal menu bar. It appears to be fine in IE 8, Safari 5, Chrome, and Firefox. However in IE 7 and lower it does not seem to display correctly. The only conditional notes I have for IE 7 and lower deals with the slideshow on the page which shouldn't be affecting the menubar as it is in a different div.
    Here is the url: www.elementcentral.com
    Any advice? I could really use some help- I've tried quite a few things but to no avail...
    Thanks for any help you can offer and I'm more than happy to clarify or anything else!
    Sincerely,
    Matt

    Anyone? I'm thinking its just something simple but I can't figure it out for the life of me heh.

  • Z-index problem ( I think )

    Hi all,
    I have a simple image swap (6 x images) on click. I have 3 columns, the left and centre with image swap and they work just fine but the right hand column I can't get it to work. I suspect it might be the z-index?
    Would appreciate someones help please.
    HTML
    <div id="imageContainer-right"><img class="active" src="templates/horme2/images/andrew_balemi_1.jpg" alt="01" width="388" height="306" /><img class="active" src="templates/horme2/images/andrew_balemi_2.jpg" alt="01" width="388" height="306" /><img class="active" src="templates/horme2/images/bruce_fergusson_1.jpg" alt="01" width="388" height="306" /><img class="active" src="templates/horme2/images/bruce_fergusson_2.jpg" alt="01" width="388" height="306" /><img class="active" src="templates/horme2/images/lindsay_hooke_2.jpg" alt="01" width="388" height="306" /><img class="active" src="templates/horme2/images/peter_hargreaves_3.jpg" alt="01" width="388" height="306" /></div>
    </div>
    CSS
    #imageContainer-right {
        width: 100%;
        height: 306px;
        position: relative;
        overflow: hidden;
    #imageContainer-right img {
        position: absolute;
        top: 0;
        left: 0;
        z-index: 6;
        cursor:pointer;cursor:hand
    #imageContainer-right img.active {
        z-index: 1;
    jQuery
    <script type="text/javascript">
    var imageObject = {
        clickSwap : function(obj) {
            obj.click(function() {
                var activeImage = $(this).children('img.active');
                activeImage.removeClass('active');
                if (activeImage.next().length > 0) {
                    activeImage.next().addClass('active');
                } else {
                    $(this).children('img:first-child').addClass('active');
                return false;
    $(function() {
        imageObject.clickSwap($('#imageContainer-right'));
         </script>   

    Thanks for the reply Nancy O,
    I may have solved the problem, I was applying the class "active" to all images when it should only be included on the first image.
    The site is now on a test server, would appreciate your thoughts, please go here: Home
    Cheers

  • Jsp forward problem, I think.....

    I have a default.htm page that takes in a feild, EMP_NUM. Once the user
              hits the Submit button, I run a select statement(select.jsp) to see if that
              number exists. If it does then I forward the contents to correct.jsp, if the
              number doesn't exist then I forward to failed.jsp.
              Today is Tuesday, and last Friday I was working on this and everything
              worked fine, in fact perfect. I came in this morning to do some more
              testing, specifically catching errors in my try and catch, example - to make
              sure they enter in a number, and after I type in a number and hit the submit
              button, it trys to go to the next page, but displays nothing, the page is
              blank. Where has before, when everything was working fine on Friday, my
              correct.jsp page or my failed.jsp page would be displayed.
              From Friday to Tuesday I had not made any changes to my files. The only
              thing different, that I can think of, would be that on Friday I would have
              stoppped weblogic and this morning I started weblogic again. This is why I
              think this is a weblogic issue or syntax on my part. I have tried to restart
              my computer, restart weblogic, and I even deleted the .java files that
              weblogic creates and places in the weblogic/myserver/classfiles/jsp_servlets
              folder.
              Below is my source code.
              Please help!
              Thanks, jl.
              <% try {
              <%@ include file = "db_conn.jsp"%>
              <%
              // A Statement object is what sends your SQL statement to the db
              Statement stmt = conn.createStatement();
              // Retrieve the user id number from the previous form.
              int EMP_NUM = Integer.parseInt(request.getParameter("EMP_NUM"));
              //SQL prepared statement
              String selectEMP_NUM = "SELECT NAME, COMPANY_KEY FROM WTS_PROFILE WHERE
              EMP_NUM=?";
              PreparedStatement psEMP_NUM = conn.prepareStatement(selectEMP_NUM);
              psEMP_NUM.setInt(1, EMP_NUM);
              ResultSet rsEMP_NUM = psEMP_NUM.executeQuery();
              String NAME = "";
              int CompanyKey = 0;
              while (rsEMP_NUM.next()) {
              NAME = rsEMP_NUM.getString("NAME");
              CompanyKey = rsEMP_NUM.getInt("COMPANY_KEY");
              }// end of while
              psEMP_NUM.clearParameters();
              psEMP_NUM.close();
              conn.close();
              String sEMP_NUM = Integer.toString(EMP_NUM);
              String sCompanyKey = Integer.toString(CompanyKey);
              if (NAME.equals("")) {
              request.setAttribute("EMP_NUM", sEMP_NUM);%>
              <jsp:forward page="failed.jsp">
              <% }// end of if
              else {
              request.setAttribute("NAME", NAME);
              request.setAttribute("EMP_NUM", sEMP_NUM);
              request.setAttribute("CompanyKey", sCompanyKey);%>
              <jsp:forward page="creditcard.jsp">
              <% }// end of else
              }// end of try1
              catch(Exception e) {
              <% if(e.toString().equals("java.lang.NumberFormatException: ")) { %>
              <font face="Arial" size="2" color="red"><center><strong>Please enter in a
              EMPLOYEE ID NUMBER.<br><br></strong></font></CENTER>
              <%}// end of if
              %>
              </TD></TR></TABLE></DIV>
              <font color="red">"<%=e.toString()%>"</font>
              <%
              }// end of catch1
              %>
              

              Sounds like you have some debugging to do. If you didn't reinstall WLS and it worked fine before,
              then I doubt it is a WLS problem.
              Is your page really blank? Try show source in your browser? I think you have some mismatched
              <table> </table>. Try it in both IE and Netscape - one of them forgives you for mismatched table
              tags.
              Add some System.out.println() in your code to see what is being executed.
              "james lorenzen" <[email protected]> wrote:
              > I have a default.htm page that takes in a feild, EMP_NUM. Once the user
              >hits the Submit button, I run a select statement(select.jsp) to see if that
              >number exists. If it does then I forward the contents to correct.jsp, if the
              >number doesn't exist then I forward to failed.jsp.
              > Today is Tuesday, and last Friday I was working on this and everything
              >worked fine, in fact perfect. I came in this morning to do some more
              >testing, specifically catching errors in my try and catch, example - to make
              >sure they enter in a number, and after I type in a number and hit the submit
              >button, it trys to go to the next page, but displays nothing, the page is
              >blank. Where has before, when everything was working fine on Friday, my
              >correct.jsp page or my failed.jsp page would be displayed.
              > From Friday to Tuesday I had not made any changes to my files. The only
              >thing different, that I can think of, would be that on Friday I would have
              >stoppped weblogic and this morning I started weblogic again. This is why I
              >think this is a weblogic issue or syntax on my part. I have tried to restart
              >my computer, restart weblogic, and I even deleted the .java files that
              >weblogic creates and places in the weblogic/myserver/classfiles/jsp_servlets
              >folder.
              >
              >Below is my source code.
              >Please help!
              >Thanks, jl.
              >
              ><% try {
              > <%@ include file = "db_conn.jsp"%>
              ><%
              > // A Statement object is what sends your SQL statement to the db
              > Statement stmt = conn.createStatement();
              >
              > // Retrieve the user id number from the previous form.
              > int EMP_NUM = Integer.parseInt(request.getParameter("EMP_NUM"));
              >
              > //SQL prepared statement
              > String selectEMP_NUM = "SELECT NAME, COMPANY_KEY FROM WTS_PROFILE WHERE
              >EMP_NUM=?";
              > PreparedStatement psEMP_NUM = conn.prepareStatement(selectEMP_NUM);
              > psEMP_NUM.setInt(1, EMP_NUM);
              >
              > ResultSet rsEMP_NUM = psEMP_NUM.executeQuery();
              >
              > String NAME = "";
              > int CompanyKey = 0;
              > while (rsEMP_NUM.next()) {
              > NAME = rsEMP_NUM.getString("NAME");
              > CompanyKey = rsEMP_NUM.getInt("COMPANY_KEY");
              > }// end of while
              >
              > psEMP_NUM.clearParameters();
              > psEMP_NUM.close();
              > conn.close();
              >
              > String sEMP_NUM = Integer.toString(EMP_NUM);
              > String sCompanyKey = Integer.toString(CompanyKey);
              > if (NAME.equals("")) {
              > request.setAttribute("EMP_NUM", sEMP_NUM);%>
              > <jsp:forward page="failed.jsp">
              ><% }// end of if
              > else {
              > request.setAttribute("NAME", NAME);
              > request.setAttribute("EMP_NUM", sEMP_NUM);
              > request.setAttribute("CompanyKey", sCompanyKey);%>
              > <jsp:forward page="creditcard.jsp">
              ><% }// end of else
              >}// end of try1
              >catch(Exception e) {
              ><% if(e.toString().equals("java.lang.NumberFormatException: ")) { %>
              > <font face="Arial" size="2" color="red"><center><strong>Please enter in a
              >EMPLOYEE ID NUMBER.<br><br></strong></font></CENTER>
              ><%}// end of if
              >%>
              > </TD></TR></TABLE></DIV>
              > <font color="red">"<%=e.toString()%>"</font>
              ><%
              >}// end of catch1
              >%>
              >
              >
              

  • Simple DLL problem

    I'm dabbling with DLL writing and can't figure out how to pass a string to a
    DLL. As far as I can see, it should be simple.
    My DLL function, in the DLL "test.dll", is simply
    TEST_API int test(LPCTSTR WinName)
    return 0;
    Instead of LPCTSTR I've also tried the more conventional "char *WinName",
    and a few others. All give the same error; "The exception Priviledged
    Instruction occurred in the application at location (blah)." The error
    message doesn't seem too specific; exactly the same thing happens if I
    deliberately copy some text to an uninitialised pointer.
    I'm calling the function using a "Call Library Node", passing a
    pre-generated string in the form of a C string pointer. The calling
    convention is set to "winapi" but doesn't seem too relevant.
    If I remove the string argument and change the function definition to take
    (void) then it works, in that I can put integers in the return code and pass
    them back to Labview, so it's the passing of the string that's the problem.
    However, if I have more code in there and I use the Visual C++ debugger, the
    error message is only generated on hitting the "return" line, and I can see
    the string that has been passed in when I look at "WinName" in the debugger.
    Can anyone shed some light on this?
    Craig Graham
    Physicist/Labview Programmer
    Lancaster University, UK

    Craig;
    I am going to throw some random thoughts that may help you in your situation:
    - I avoid to use VC's wizard. It gives (and gave me) a lot of headaches. All it does it to add a lot of garbage to your project that nobody understand.
    - If your source file is a .cpp, wrap your function prototypes inside the extern "C" declaration.
    - Always initialize every variable in LabVIEW side. For example, for your function you should wire an empty string in the input side of the "Call Library Node" for the "WinName" variable.
    - I claim ignorance in this one, but seems to simplify my projects. Exclude rarely-used Windows header files by adding the following statement before your headers "include":
    #define VC_EXTRALEAN
    I hope this can be of help. If I co
    me up with some more suggestion, I'll let you know.
    Best regards;
    Enrique
    www.vartortech.com

  • JPanel Multipe Images are cutoff (layout problem I think)

    I am adding images (custom JPanel: Entity class) to a JPanel but the images are getting cut off. I was originally trying BorderLayout but that only worked for one image and adding others added image cut-off the first or completely removed the original image all together. So I switched to other layouts and the closest I could get was BoxLayout however that adds a very large cut-off which is not acceptable either.
    So basically; How can I add images (from a custom JComponent) to a custom JPanel without bad effects such as the one present in the code.
    How do I go about adding images from Entity class to a JPanel without them getting cutoff or not showing at all?
    Note: the images need to animate.
    Entity Class:
    import java.awt.Dimension;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.image.BufferedImage;
    import javax.imageio.ImageIO;
    import javax.swing.JComponent;
    public class Entity extends JComponent implements Runnable {
    private BufferedImage bImg;
    private int x = 20;
    private int y = 20;
    private int entityWidth, entityHeight;
    public void run() {
    bImg = loadBImage("test.png", bImg);
    entityWidth = bImg.getWidth();
    entityHeight = bImg.getHeight();
    setPreferredSize(new Dimension(entityWidth, entityHeight));
    @Override
    public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graphics2D g2d = (Graphics2D) g.create();
    g2d.drawImage(bImg, x, y, null);
    g2d.dispose();
    public BufferedImage loadBImage(String filename, BufferedImage tmpBI) {
    try {
    tmpBI = ImageIO.read(getClass().getResource(filename));
    } catch (Exception e) { }
    return tmpBI;
    public int getEntityWidth() { return entityWidth; }
    public int getEntityHeight() { return entityHeight; }
    public int getX() { return x; }
    public int getY() { return y; }
    public void setX(int x) { this.x = x; }
    public void setY(int y) { this.y = y; }
    }Main:
    import java.awt.EventQueue;
    import javax.swing.JFrame;
    public class MainWindow
    public static void main(String[] args) {
    new MainWindow();
    private JFrame frame;
    private GraphicsPanel gp = new GraphicsPanel();
    MainWindow() {
    EventQueue.invokeLater(new Runnable() {
    public void run() {
    frame = new JFrame("Graphics Practice");
    frame.setSize(680, 420);
    frame.setVisible(true);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.add(gp);
    }Graphics Panel: This is where the problem arrises.
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Graphics;
    import java.awt.Graphics2D;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import java.awt.event.MouseEvent;
    import java.awt.event.MouseListener;
    import javax.swing.JPanel;
    import javax.swing.Timer;
    public class GraphicsPanel extends JPanel implements MouseListener {
    private Entity entity;
    private Entity ent2;
    private Timer timer;
    private long startTime = 0;
    private int numFrames = 0;
    private float fps = 0.0f;
    GraphicsPanel() {
    entity = new Entity();
    entity.setOpaque(false);
    Thread t1 =  new Thread(entity);
    t1.start();
    ent2 = new Entity();
    entity.setOpaque(false);
    Thread t2 = new Thread(ent2);
    ent2.setX(100);
    ent2.setY(100);
    t2.start();
    //ESSENTIAL
    setLayout(new BorderLayout());
    //COMMENT OUT add(ent2) to see the problem. Any image will do.
    add(entity);
    add(ent2);
    //GAMELOOP
    timer = new Timer(30, new Gameloop(this));
    timer.start();
    addMouseListener(this);
    @Override
    public void paintComponent(Graphics g)
    super.paintComponent(g);
    Graphics2D g2 = (Graphics2D) g.create();
    g2.setClip(0, 0, getWidth(), getHeight());
    g2.setColor(Color.BLACK);
    g2.drawString("FPS: " + fps, 1, 15);
    public void getFPS()
    ++numFrames;
    if (startTime == 0) {
    startTime = System.currentTimeMillis();
    } else {
    long currentTime = System.currentTimeMillis();
    long delta = (currentTime - startTime);
    if (delta > 1000) {
    fps = (numFrames * 1000) / delta;
    numFrames = 0;
    startTime = currentTime;             
    public void mouseClicked(MouseEvent e) {}
    public void mousePressed(MouseEvent e) {}
    public void mouseReleased(MouseEvent e) {}
    public void mouseEntered(MouseEvent e) { }
    public void mouseExited(MouseEvent e) { }
    class Gameloop implements ActionListener
    private GraphicsPanel gp;
    Gameloop(GraphicsPanel gp) {
    this.gp = gp;
    public void actionPerformed(ActionEvent e) {
    try {
    gp.getFPS();
    gp.repaint();
    } catch (Exception ez) { }

    You got a bit of a concurrency time bomb on your hands with those Entity threads of yours. Your Entity class also inadvertently overrides Component#getX() and Component#getY() to return where the image is painted within the component. That can't be good. I'm also not sure how your Entity class is functionally different from a simple JLabel with an ImageIcon and a (20,20,20,20) empty border.
    But as for your immediate problem: 1) Use FlowLayout for your Graphics panel, 2) Include a revalidate() call after you set the preferred size in the run() method of your Entity class 3) Don't override Component#getX() and Component#getY() in your Entity class and 4) Add the GraphicsPanel to the frame before, not after, you make the frame visible.

Maybe you are looking for

  • Events are automatically being split

    When importing a set of photos, iphoto is splitting up my photos and placing my set into two events. To be clear, I want the chosen imported photos to go into one event, but iphoto is splitting them up. What am I doing wrong?? Also, should I reunite

  • Itunes failure to open

    my itunes and quicktime do the same thing when I open them the screen flashes for a second and disappears I uninstalled the program I got for the Internet and installed the disk I got when I got my ipod and it still isn't working if anyone knows what

  • Swing component for awt.canvas

    Hi, Can anyone tell me the equivalent SWING component for awt CANVAS. I need it because i need to display only Images (nothing else) on it. If anyone can tell how I can do it.

  • HT2476 FAVORITES menu ... How do I remove/delete from the menu?

    I accidentally dragged a folder into my FAVORITES menu ... How do I remove/delete from the menu?

  • CrystalReportsViewer under SSL using IE

    I have run into a particulary strange issue regarding cache-control and IE6/7 under SSL.  Unfortunately it is affecting me using the CrystalReportViewer control within my ASP.Net application.  I have an SSL Website and the CrystalReportsViewer contro