sampledesktopmgr.java
来自「数据仓库工具」· Java 代码 · 共 41 行
JAVA
41 行
package org.webdocwf.util.loader.wizard;
import javax.swing.*;
import java.awt.*;
public class SampleDesktopMgr extends DefaultDesktopManager {
// This is called anytime a frame is moved. This
// implementation keeps the frame from leaving the desktop.
public void dragFrame(JComponent f, int x, int y) {
if (f instanceof JInternalFrame) { // Deal only w/internal frames
JInternalFrame frame = (JInternalFrame)f;
JDesktopPane desk = frame.getDesktopPane();
Dimension d = desk.getSize();
// Nothing all that fancy below, just figuring out how to adjust
// to keep the frame on the desktop.
if (x < 0) { // too far left?
x = 0; // flush against the left side
}
else {
if (x + frame.getWidth() > d.width) { // too far right?
x = d.width - frame.getWidth(); // flush against right side
}
}
if (y < 0) { // too high?
y=0; // flush against the top
}
else {
if (y + frame.getHeight() > d.height) { // too low?
y = d.height - frame.getHeight(); // flush against the bottom
}
}
}
// Pass along the (possibly cropped) values to the normal drag handler.
super.dragFrame(f, x, y);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?