Netbeans: JPanel in designer mode with code behind.

I wanted to add a JPanel to my palette so I could easily include it into a JFrame, in designer mode that is.

This was the constructor of my JPanel:

/** Creates new form SetupPanel */
public SetupPanel()
{
	super();
	this.initComponents();

	this.jTextFieldDataDirectory.setText(Main.getProperties().getProperty(Settings.DATADIRECTORY));
	this.jTextFieldOpenSSLLocation.setText(Main.getProperties().getProperty(Settings.OPENSSLLOCATION));
}

This gave me a nice error when I added it to the panel:

The component cannot be instantiated. Please make sure it is a JavaBeans component.

This is because when you add it to the palette Netbeans compiles the class, and at that point it cannot find ‘Main’, so it throws a NullPointer.

Surrounding those statements with Beans.isDesignTime() solves the problem:

/** Creates new form SetupPanel */
public SetupPanel()
{
	super();
	this.initComponents();

	if (!Beans.isDesignTime())
	{
		this.jTextFieldDataDirectory.setText(Main.getProperties().getProperty(Settings.DATADIRECTORY));
		this.jTextFieldOpenSSLLocation.setText(Main.getProperties().getProperty(Settings.OPENSSLLOCATION));
	}
}

Now you can add it to the palette without problems.

USA: Going to the doctor’s

So I’ve been feeling very bad lately, sore neck, sore throat, sneezing, swollen lymph nodes, painful ears. Jees what a list.

Anyways: I go to the doctor’s here, which is free at campus. Little talk, little examination, appears I have strep throat, and a fluid drainage problems in my nose. So at night the fluids flow to the back of my throat which makes it feel sore. So the doctor prescribes something.

But that’s not interesting. Getting your medicine it pretty interesting for an European.

You go to Dillons, with your prescription, the doctor asks some questions. I needed to show ID, then they give you the medicine and then you need to sign.

Apparently law in the US is very strict to avoid misuse. And it’s not bad :)

I now have this very cool orange –like in the movies- medicine can/tupe/whatever you call it:

dscf4050

Most people will find this probably stupid, me posting this, but hey, it’s an all new experience for me.

.NET: Entity Framework: re-add a deleted table resolved!

First of all: for those who think that there is an easy solution. I’m sorry, there is not.

The problem is located in the .edmx file, and not in the designer.cs file as I suspected first.

When you add an .edmx and take a look at it with notepad you’ll see this:



	
	
		
		
			
				
				
			
		
		
		
			
				
				
			
		
		
		
			
				
				
			
		
	
	
	
		
			
				
			
		
		
			
				
			
		
		
		
			
			
		
	

Now you add a table:



	
	
		
		
			
				
					
				
				
					
						
					
					
					
					
				
			
		
		
		
			
				
					
				
				
					
						
					
					
					
					
				
			
		
		
		
			
				
					
						
							
								
								
								
							
						
					
				
			
		
	
	
	
		
			
				
			
		
		
			
				
			
		
		
		
			
				
			
		
	

As you can see I’ve added a table ‘Users’ with ‘UserID’, ‘Name’ and ‘Birthday’.

You can also see the difference between the 2.

Now when you delete the table again from the design surface this is what ‘junk’ that stays behind:



	
	
		
		
			
				
					
				
				
					
						
					
					
					
					
				
			
		
		
		
			
				
				
			
		
		
		
			
				
				
			
		
	
	
	
		
			
				
			
		
		
			
				
			
		
		
		
			
			
		
	

As you can see lines 9 and 12-17 weren’t there in the original -empty- model. You’ll need to clean those up manually.

diff

Removing those lines will give you the possibility to re-add your previously deleted table.