NetBeans Drag and Drop 위젯이 NetBeans Design View Window 또는 실행중인 응용 프로그램 내부에서 렌더링되는지 여부를 알 수 있도록하려면 어떻게해야합니까?

StackOverflow https://stackoverflow.com/questions/399929

문제

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");
}
}

그것은 작동합니다 - 그것은 매우 믿어지지 않습니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top