下面列出了怎么用sun.awt.DisplayChangedListener的API类实例代码及写法,或者点击链接到github查看源代码。
@Override
public void notifyDisplayChanged(final int scaleFactor) {
if (scaleFactor != this.scaleFactor) {
if (!copyBufferEnabled) content.paintLock();
try {
if (bbImage != null) {
resizeBuffer(getWidth(), getHeight(), scaleFactor);
}
} finally {
if (!copyBufferEnabled) content.paintUnlock();
}
this.scaleFactor = scaleFactor;
}
if (getPeer() instanceof DisplayChangedListener) {
((DisplayChangedListener)getPeer()).displayChanged();
}
repaint();
}
static public void displayChanged() {
final Runnable runnable = () -> {
Object lge = GraphicsEnvironment.getLocalGraphicsEnvironment();
if (lge instanceof DisplayChangedListener) {
((DisplayChangedListener) lge).displayChanged();
}
};
if (AppContext.getAppContext() != null) {
// Common case, standalone application
EventQueue.invokeLater(runnable);
} else {
if (displayChangeExecutor == null) {
// No synchronization, called on the Toolkit thread only
displayChangeExecutor = Executors.newFixedThreadPool(1, r -> {
Thread t = Executors.defaultThreadFactory().newThread(r);
t.setDaemon(true);
return t;
});
}
displayChangeExecutor.submit(runnable);
}
}
@Override
public void notifyDisplayChanged(final int scaleFactor) {
if (scaleFactor != this.scaleFactor) {
if (!copyBufferEnabled) content.paintLock();
try {
if (bbImage != null) {
resizeBuffer(getWidth(), getHeight(), scaleFactor);
}
} finally {
if (!copyBufferEnabled) content.paintUnlock();
}
this.scaleFactor = scaleFactor;
}
if (getPeer() instanceof DisplayChangedListener) {
((DisplayChangedListener)getPeer()).displayChanged();
}
repaint();
}
static public void displayChanged() {
final Runnable runnable = () -> {
Object lge = GraphicsEnvironment.getLocalGraphicsEnvironment();
if (lge instanceof DisplayChangedListener) {
((DisplayChangedListener) lge).displayChanged();
}
};
if (AppContext.getAppContext() != null) {
// Common case, standalone application
EventQueue.invokeLater(runnable);
} else {
if (displayChangeExecutor == null) {
// No synchronization, called on the Toolkit thread only
displayChangeExecutor = Executors.newFixedThreadPool(1, r -> {
Thread t = Executors.defaultThreadFactory().newThread(r);
t.setDaemon(true);
return t;
});
}
displayChangeExecutor.submit(runnable);
}
}
@Override
public void notifyDisplayChanged(final int scaleFactor) {
if (scaleFactor != this.scaleFactor) {
if (!copyBufferEnabled) content.paintLock();
try {
if (bbImage != null) {
resizeBuffer(getWidth(), getHeight(), scaleFactor);
}
} finally {
if (!copyBufferEnabled) content.paintUnlock();
}
this.scaleFactor = scaleFactor;
}
if (getPeer() instanceof DisplayChangedListener) {
((DisplayChangedListener)getPeer()).displayChanged();
}
repaint();
}
@Override
public void notifyDisplayChanged(final int scaleFactor) {
if (scaleFactor != this.scaleFactor) {
if (!copyBufferEnabled) content.paintLock();
try {
if (bbImage != null) {
resizeBuffer(getWidth(), getHeight(), scaleFactor);
}
} finally {
if (!copyBufferEnabled) content.paintUnlock();
}
this.scaleFactor = scaleFactor;
}
if (getPeer() instanceof DisplayChangedListener) {
((DisplayChangedListener)getPeer()).displayChanged();
}
repaint();
}
static public void displayChanged() {
final Runnable runnable = () -> {
Object lge = GraphicsEnvironment.getLocalGraphicsEnvironment();
if (lge instanceof DisplayChangedListener) {
((DisplayChangedListener) lge).displayChanged();
}
};
if (AppContext.getAppContext() != null) {
// Common case, standalone application
EventQueue.invokeLater(runnable);
} else {
if (displayChangeExecutor == null) {
// No synchronization, called on the Toolkit thread only
displayChangeExecutor = Executors.newFixedThreadPool(1, r -> {
Thread t = Executors.defaultThreadFactory().newThread(r);
t.setDaemon(true);
return t;
});
}
displayChangeExecutor.submit(runnable);
}
}
@Override
public void notifyDisplayChanged(final int scaleFactor) {
if (scaleFactor != this.scaleFactor) {
if (!copyBufferEnabled) content.paintLock();
try {
if (bbImage != null) {
resizeBuffer(getWidth(), getHeight(), scaleFactor);
}
} finally {
if (!copyBufferEnabled) content.paintUnlock();
}
this.scaleFactor = scaleFactor;
}
if (getPeer() instanceof DisplayChangedListener) {
((DisplayChangedListener)getPeer()).displayChanged();
}
repaint();
}
@Override
public void notifyDisplayChanged(final int scaleFactor) {
if (scaleFactor != this.scaleFactor) {
if (!copyBufferEnabled) content.paintLock();
try {
if (bbImage != null) {
resizeBuffer(getWidth(), getHeight(), scaleFactor);
}
} finally {
if (!copyBufferEnabled) content.paintUnlock();
}
this.scaleFactor = scaleFactor;
}
if (getPeer() instanceof DisplayChangedListener) {
((DisplayChangedListener)getPeer()).displayChanged();
}
repaint();
}
@Override
public void notifyDisplayChanged(final int scaleFactor) {
if (scaleFactor != this.scaleFactor) {
if (!copyBufferEnabled) content.paintLock();
try {
if (bbImage != null) {
resizeBuffer(getWidth(), getHeight(), scaleFactor);
}
} finally {
if (!copyBufferEnabled) content.paintUnlock();
}
this.scaleFactor = scaleFactor;
}
if (getPeer() instanceof DisplayChangedListener) {
((DisplayChangedListener)getPeer()).displayChanged();
}
repaint();
}
@Override
public void notifyDisplayChanged(final int scaleFactor) {
if (scaleFactor != this.scaleFactor) {
if (!copyBufferEnabled) content.paintLock();
try {
if (bbImage != null) {
resizeBuffer(getWidth(), getHeight(), scaleFactor);
}
} finally {
if (!copyBufferEnabled) content.paintUnlock();
}
this.scaleFactor = scaleFactor;
}
if (getPeer() instanceof DisplayChangedListener) {
((DisplayChangedListener)getPeer()).displayChanged();
}
repaint();
}
static public void displayChanged() {
final Runnable runnable = () -> {
Object lge = GraphicsEnvironment.getLocalGraphicsEnvironment();
if (lge instanceof DisplayChangedListener) {
((DisplayChangedListener) lge).displayChanged();
}
};
if (AppContext.getAppContext() != null) {
// Common case, standalone application
EventQueue.invokeLater(runnable);
} else {
if (displayChangeExecutor == null) {
// No synchronization, called on the Toolkit thread only
displayChangeExecutor = Executors.newFixedThreadPool(1, r -> {
Thread t = Executors.defaultThreadFactory().newThread(r);
t.setDaemon(true);
return t;
});
}
displayChangeExecutor.submit(runnable);
}
}
@Override
public void notifyDisplayChanged(final int scaleFactor) {
if (scaleFactor != this.scaleFactor) {
if (!copyBufferEnabled) content.paintLock();
try {
if (bbImage != null) {
resizeBuffer(getWidth(), getHeight(), scaleFactor);
}
} finally {
if (!copyBufferEnabled) content.paintUnlock();
}
this.scaleFactor = scaleFactor;
}
if (getPeer() instanceof DisplayChangedListener) {
((DisplayChangedListener)getPeer()).displayChanged();
}
repaint();
}
@Override
public void notifyDisplayChanged(final int scaleFactor) {
if (scaleFactor != this.scaleFactor) {
if (!copyBufferEnabled) content.paintLock();
try {
if (bbImage != null) {
resizeBuffer(getWidth(), getHeight(), scaleFactor);
}
} finally {
if (!copyBufferEnabled) content.paintUnlock();
}
this.scaleFactor = scaleFactor;
}
if (getPeer() instanceof DisplayChangedListener) {
((DisplayChangedListener)getPeer()).displayChanged();
}
repaint();
}
/**
* From the DisplayChangedListener interface; called
* when the display mode has been changed.
*/
public void displayChanged() {
// notify screens in device array to do display update stuff
for (GraphicsDevice gd : getScreenDevices()) {
if (gd instanceof DisplayChangedListener) {
((DisplayChangedListener) gd).displayChanged();
}
}
// notify SunDisplayChanger list (e.g. VolatileSurfaceManagers and
// SurfaceDataProxies) about the display change event
displayChanger.notifyListeners();
}
@Override
public void addNotify() {
super.addNotify();
if (getPeer() instanceof DisplayChangedListener) {
((DisplayChangedListener)getPeer()).displayChanged();
}
}
private static void testGE() {
Object ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
if (!(ge instanceof DisplayChangedListener)) {
return;
}
((DisplayChangedListener) ge).displayChanged();
}
/**
* From the DisplayChangedListener interface; called
* when the display mode has been changed.
*/
public void displayChanged() {
// notify screens in device array to do display update stuff
for (GraphicsDevice gd : getScreenDevices()) {
if (gd instanceof DisplayChangedListener) {
((DisplayChangedListener) gd).displayChanged();
}
}
// notify SunDisplayChanger list (e.g. VolatileSurfaceManagers and
// SurfaceDataProxies) about the display change event
displayChanger.notifyListeners();
}
@Override
public void addNotify() {
super.addNotify();
if (getPeer() instanceof DisplayChangedListener) {
((DisplayChangedListener)getPeer()).displayChanged();
}
}
private static void testGE() {
Object ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
if (!(ge instanceof DisplayChangedListener)) {
return;
}
((DisplayChangedListener) ge).displayChanged();
}
/**
* From the DisplayChangedListener interface; called
* when the display mode has been changed.
*/
public void displayChanged() {
// notify screens in device array to do display update stuff
for (GraphicsDevice gd : getScreenDevices()) {
if (gd instanceof DisplayChangedListener) {
((DisplayChangedListener) gd).displayChanged();
}
}
// notify SunDisplayChanger list (e.g. VolatileSurfaceManagers and
// SurfaceDataProxies) about the display change event
displayChanger.notifyListeners();
}
@Override
public void addNotify() {
super.addNotify();
if (getPeer() instanceof DisplayChangedListener) {
((DisplayChangedListener)getPeer()).displayChanged();
}
}
/**
* From the DisplayChangedListener interface; called
* when the display mode has been changed.
*/
public void displayChanged() {
// notify screens in device array to do display update stuff
for (GraphicsDevice gd : getScreenDevices()) {
if (gd instanceof DisplayChangedListener) {
((DisplayChangedListener) gd).displayChanged();
}
}
// notify SunDisplayChanger list (e.g. VolatileSurfaceManagers and
// SurfaceDataProxies) about the display change event
displayChanger.notifyListeners();
}
@Override
public void addNotify() {
super.addNotify();
if (getPeer() instanceof DisplayChangedListener) {
((DisplayChangedListener)getPeer()).displayChanged();
}
}
private static void testGE() {
Object ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
if (!(ge instanceof DisplayChangedListener)) {
return;
}
((DisplayChangedListener) ge).displayChanged();
}
/**
* From the DisplayChangedListener interface; called
* when the display mode has been changed.
*/
public void displayChanged() {
// notify screens in device array to do display update stuff
for (GraphicsDevice gd : getScreenDevices()) {
if (gd instanceof DisplayChangedListener) {
((DisplayChangedListener) gd).displayChanged();
}
}
// notify SunDisplayChanger list (e.g. VolatileSurfaceManagers and
// SurfaceDataProxies) about the display change event
displayChanger.notifyListeners();
}
@Override
public void addNotify() {
super.addNotify();
if (getPeer() instanceof DisplayChangedListener) {
((DisplayChangedListener)getPeer()).displayChanged();
}
}
/**
* From the DisplayChangedListener interface; called
* when the display mode has been changed.
*/
public void displayChanged() {
// notify screens in device array to do display update stuff
for (GraphicsDevice gd : getScreenDevices()) {
if (gd instanceof DisplayChangedListener) {
((DisplayChangedListener) gd).displayChanged();
}
}
// notify SunDisplayChanger list (e.g. VolatileSurfaceManagers and
// SurfaceDataProxies) about the display change event
displayChanger.notifyListeners();
}
@Override
public void notifyDisplayChanged(final double scaleFactorX,
final double scaleFactorY) {
if (Double.compare(scaleFactorX, this.scaleFactorX) != 0 ||
Double.compare(scaleFactorY, this.scaleFactorY) != 0) {
if (!copyBufferEnabled) content.paintLock();
try {
if (bbImage != null) {
resizeBuffer(getWidth(), getHeight(), scaleFactorX,
scaleFactorY);
}
} finally {
if (!copyBufferEnabled) content.paintUnlock();
}
this.scaleFactorX = scaleFactorX;
this.scaleFactorY = scaleFactorY;
if(isVisible()) {
final Object peer =
AWTAccessor.getComponentAccessor().getPeer(this);
if (peer instanceof DisplayChangedListener) {
((DisplayChangedListener) peer).displayChanged();
}
repaint();
}
}
}
@Override
public void addNotify() {
super.addNotify();
final Object peer = AWTAccessor.getComponentAccessor().getPeer(this);
if (peer instanceof DisplayChangedListener) {
((DisplayChangedListener) peer).displayChanged();
}
}