So I'm maing a 3D game editor in Java using LWJGL (Lightweight Java Game Library), I have the editor set up so that the user can create new levels, load up saved levels, save and quick save current levels, import textured models etc.. the basics.

I am now trying to implement a system that when a new model(s) is imported into the editor, a button (JButton) will appear on the bottom taskbar, therefore enabling the user to switch between different models.

I am however, having a little trouble. Here is the code which defines the JPanel where I want the buttons to go:

/* ----- */

/**
 * The componentsPanel will contain buttons that will set the current acvite model to be placed
*  within the editor.
*/

// This JPanel contains the list of models and textures for the current project.
componentPanel = new JPanel(new GridLayout(0, 5));

// Gives the south (bottom) panel a black border.
componentPanel.setBorder(BorderFactory.createLineBorder(Color.BLACK));

//componentPanel.add(new JButton("This is a test"));

/* ----- */

And here is the code I am trying to use to add a new button to the panel:

Main.getEditorGui().getComponentPanel().add(new JButton(this.modelName));

Put simply, it dosent work. Any and all help would be amazing!

Does it throw any errors when you compile? Or simply doesn't display?

Not it dosent throw any errors, it simply does nothing. I know that the line of code is being executed too as I have written a simple 'system.out.println("test");' and checked the console, and sure enough 'test' is written.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.