0

コンポーネントをメイン モニターのあるフレームからセカンダリ モニターの別のフレームにドラッグしています。ガラス板に描かれたコンポーネントをドラッグしている間、メイン モニターの上にガラス板が見えますが、マウスがセカンダリ モニターに到達した後、ガラス板が消える?誰でもこれで私を助けることができますか? セカンダリ モニターの上にガラス板をペイントするにはどうすればよいですか?

これが私のコードの一部です:

public class Main_Frame extends JFrame

{

     public Main_Frame (){
        //adding  the content of main JFrame
        setGlassPane(new  ImageGlassPane());
        //detect other screens and making object of Second_Frame for each
     }
}

public class Second_Frame extends JDialog{
    public Second_Frame(){
       super(new Frame(MultiMonitor.getInstance().getNextDevice().getDefaultConfiguration()), 
          Title, false);
       setGlassPane(new  ImageGlassPane());
    }

}

    public class ImageGlassPane() extends JPanel{
public ImageGlassPane() {
           setOpaque(false);

     }

     protected void paintComponent(Graphics g) {
        if ( !isVisible()) {
            return;
        }
        Graphics2D g2 = (Graphics2D) g.create();
        g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, alpha));
        g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                            RenderingHints.VALUE_ANTIALIAS_ON);

        int x = (int) (location.getX() - (width * zoom / 2));
        int y = (int) (location.getY() - (height * zoom / 2));

        if (visibleRect != null) {
            g2.setClip(visibleRect);
        }

        if (visibleRect != null) {
            Area clip = new Area(visibleRect);
            g2.setClip(clip);
        }

        g2.drawImage(image, x, y, (int) (width * zoom), (int) (height * zoom), null);
    }

}
4

1 に答える 1

2

ただし、最初のフレームのガラス ペインでコンポーネントをペイントしているため、2 番目のフレームでも同様にペイントする必要があります。これは 2 つのモニターの問題ではなく、2 つのフレームの問題のようです。

于 2011-04-04T11:37:20.833 に答える