How do I get the netbeans drag and drop widget to see if it is a render inside the netbeans design viewport or a running application?
3 answers
Testing
Beans.isDesignTime()
with the following example
package test;
import java.awt.Graphics;
import java.beans.Beans;
import javax.swing.JLabel;
public class TestLabel extends JLabel {
private static final long serialVersionUID = -2438507032083091628L;
public TestLabel() {
super();
}
public void paint(Graphics g) {
super.paint(g);
if (Beans.isDesignTime())
this.setText("Design Time");
else
this.setText("Production runtime");
}
}
It works - it's incredible.
0
source to share