Click here to Skip to main content
15,893,814 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Greetings,

So say you are designing an ApplicationWindow in WindowsBuilder and you create your own JPanel by extending your class to a JPanel. How do you get the Design tab in Eclipse/JavaEE/WindowsBuilder to show that custom component you just created?

By default, on my machine, at least, its hidden. I can't see it.

Is there a setting somewhere to see it?

Thanks,
Posted
Comments
Shaareable 16-Sep-14 14:16pm    
Any takers?

1 solution

It appears that if you declare your custom component (JPanel here) OUTSIDE of the main class for your gui, like so:

Java
package views;

import java.awt.EventQueue;
...

//---------------------------------------------------------------------------//
//This is my subclassed jpanel for drawing declared OUTSIDE the main gui class.

class MyJPanel extends JPanel
{
    @Override
    public void paintComponent(Graphics g) 
    {
       super.paintComponent(g);
    }	
}

//---------------------------------------------------------------------------//



//This is the main class for the gui
public class SandboxToo 
{
	private JFrame frame;
	private JPanel panel;
	private MyJPanel myPanel;
	...


Then your custom component will show up properly in the UI.



However, if you declare your custom class INSIDE the main class of your gui...
Java
package views;

import java.awt.EventQueue;

public class SandboxToo //This is the main class for the gui
{
        // Now my custom JPanel is declared INSIDE the main gui class
	class MyJPanel extends JPanel
	{
	    @Override
	    public void paintComponent(Graphics g) 
	    {
	       super.paintComponent(g);
	    }	
	}	
	private JFrame frame;
	private JPanel panel;
	private MyJPanel myPanel;


...then your custom component show up in the designer.


Moreover, changing the location of your subclass from inside to outside the main class will actually require you to save and close the tab and reopen the tab for WindowsBuilder to reset itself and display properly. This is sort of a bug.

This entails limitations in your code, obviously, so there you go, good luck! :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900