我正在将组件从主监视器中的一帧拖动到辅助监视器中的另一帧,当我将它拖动到玻璃窗格中绘制的组件时,我可以在主监视器上看到玻璃窗格,但是在鼠标到达辅助监视器后,玻璃窗消失了?任何人都可以帮助我吗?如何在辅助显示器上绘制玻璃板?
这是我的一些代码:
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);
}
}