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 9216977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:32:09+00:00 2026-06-18T02:32:09+00:00

When ever i try to run this in eclipse as a Java project, nothing

  • 0

When ever i try to run this in eclipse as a Java project, nothing happens but if i put it all in the “public static void main(String[] args)”, then it works but thats not how it’s done in the video i’m learning from

 package Indeed;


import static org.lwjgl.opengl.GL11.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import org.lwjgl.opengl.*;
import org.lwjgl.*;
import org.lwjgl.input.Mouse;
import org.lwjgl.input.Keyboard;    


public class InputDemo {


public static void main(String[] args) {

}

List<Box> shapes = new ArrayList<Box>(16);

public InputDemo() {

    try {
        Display.setDisplayMode(new DisplayMode(640, 480));
        Display.setTitle("Hello, LWJGL!");
        Display.create();
    } 
    catch (LWJGLException e) 
    {

        e.printStackTrace();
    }

    shapes.add(new Box(15, 15));
    shapes.add(new Box(100, 150));

    //Initialization code OpenGL
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glOrtho(0, 640, 480, 0, 1, -1);
    glMatrixMode(GL_MODELVIEW);

    while(!Display.isCloseRequested())
    {
        //Render
        glClear(GL_ACCUM_BUFFER_BIT);

        if(Keyboard.isKeyDown(Keyboard.KEY_ESCAPE))
        {
            Display.destroy();
            System.exit(0);
        }

        for(Box box : shapes)
        {
            box.draw();
        }




        Display.update();
        Display.sync(60);
    }

    Display.destroy();
}

private static class Box
{
    public int x, y;
    private float red, blue, green;
    public boolean selected = false;

    Box (int x, int y)
    {
        this.x = x;
        this.y = y;

        Random rand = new Random();
        red = rand.nextFloat(); 
        blue = rand.nextFloat();
        green = rand.nextFloat();
    }

    void update(int dx, int dy)
    {
        x += dx;
        y += dy;
    }

    boolean inBounds(int mouseX, int mouseY)
    {
        if(mouseX > x && mouseX < x + 50 && mouseY > y && mouseY < y + 50)
        {
            return true;
        }
        else
        {
            return false;
        }

    }

    void RandomColor()
    {
        Random rand = new Random();
        red = rand.nextFloat(); 
        blue = rand.nextFloat();
        green = rand.nextFloat();
    }

    void draw()
    {
        glColor3f(red, green, blue);

        glBegin(GL_QUADS);
        glVertex2f(x, y);
        glVertex2f(x + 50, y);
        glVertex2f(x+ 50, y+ 50);
        glVertex2f(x, y + 50);
        glEnd();
    }
}


}
  • 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-18T02:32:10+00:00Added an answer on June 18, 2026 at 2:32 am

    You dont need to put it ALL in the main function, but be aware that ONLY the code put within it will be run. If your video claims otherwise, it is lying to you.

    You have all your code being called from the constructor. Ideally, you would move that to the main function. If you choose to leave it as it is, you would need to create an instance of the class for it to be executed. So you can add InputDemo demo = new InputDemo(); to your main function and that might suffice..

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

Sidebar

Related Questions

Hi Is there any error in this TRIGGER Statement.When ever i try to run
i am getting this error when ever i try to click a button: public
When ever I try to launch my eclipse I am getting the following exception
when i try to start the rails server this error ever appears C:\Arthur\Ruby\Aplicações em
Ever since I created this Rails 3.2.3 project to use MiniTest, I have been
This is a far stretch but i am going to try an explain the
So when i try to run the following code i can never ever get
Has anyone ever run into this before? I have the crossdomain.xml set and I've
I am getting this error message when ever I try to update or save
Possible Duplicate: Can this ever be null in Java? I have thread with thic

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.