NetBeans Drag and Drop 위젯이 NetBeans Design View Window 또는 실행중인 응용 프로그램 내부에서 렌더링되는지 여부를 알 수 있도록하려면 어떻게해야합니까?
-
29-08-2019 - |
문제
NetBeans Drag and Drop 위젯이 NetBeans Design View Window 또는 실행중인 응용 프로그램 내부에서 렌더링되는지 여부를 알 수 있도록하려면 어떻게해야합니까?
맞춤 렌더링을하려고합니다. 루트 컨테이너와 관련이 있다고 생각합니다.
해결책
다른 팁
이것은 또 다른 방법입니다.
Component c = javax.swing.SwingUtilities.getRoot(this);
String className = c.getClass().getCanonicalName();
if (!"org.netbeans.core.windows.view.ui.MainWindow"
.equalsIgnoreCase(className)) {
나는 생각하지만
Beans.isDesignTime()
방법이 더 좋습니다
테스트
Beans.isDesignTime()
다음 예제로
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");
}
}
그것은 작동합니다 - 그것은 매우 믿어지지 않습니다.
제휴하지 않습니다 StackOverflow