本文整理匯總了Java中javax.swing.JDesktopPane.getAllFrames方法的典型用法代碼示例。如果您正苦於以下問題:Java JDesktopPane.getAllFrames方法的具體用法?Java JDesktopPane.getAllFrames怎麽用?Java JDesktopPane.getAllFrames使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.JDesktopPane
的用法示例。
在下文中一共展示了JDesktopPane.getAllFrames方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: showAndPositionInternalFrame
import javax.swing.JDesktopPane; //導入方法依賴的package包/類
/**
*
* @param desktopPane
* @param internalFrame
*/
public static void showAndPositionInternalFrame(JDesktopPane desktopPane, JInternalFrame internalFrame) {
int numberOfOpenFrames = desktopPane.getAllFrames().length;
try {
desktopPane.add(internalFrame, javax.swing.JLayeredPane.DEFAULT_LAYER);
} catch (java.lang.IllegalArgumentException iae) {
// frame already displayed
}
internalFrame.setVisible(true);
int posX = 0;
// Math.max(desktopPane.getWidth() / 2 - internalFrame.getWidth() / 2, 0);
posX = Math.min(posX + numberOfOpenFrames * X_OFFSET, desktopPane.getWidth() - X_OFFSET);
int posY = 0;
// Math.max(desktopPane.getHeight() / 2 - internalFrame.getHeight() / 2, 0);
posY = Math.min(posY + numberOfOpenFrames * Y_OFFSET, desktopPane.getHeight() - Y_OFFSET);
internalFrame.setLocation(posX, posY);
//CanRegClientApp.getApplication().getMainFrame();
internalFrame.setVisible(true);
internalFrame.toFront();
}
示例2: getDesktopProjectFrames
import javax.swing.JDesktopPane; //導入方法依賴的package包/類
/**
* Get all frames of the CURRENT desktop
*/
@Override
public final ProjectFrame[] getDesktopProjectFrames() {
List<ProjectFrame> projectFrameList = new ArrayList<ProjectFrame>();
JDesktopPane currentDesktop = this.getCurrentDesktop();
if (currentDesktop == null) {
return new ProjectFrame[0];
}
for (JInternalFrame frameGui : currentDesktop.getAllFrames()) {
ProjectFrame projectFrame = this.getProjectFrameFromGui(frameGui);
if (projectFrame != null) {
projectFrameList.add(projectFrame);
}
}
return projectFrameList.toArray(new ProjectFrame[0]);
}
示例3: getTopViewCacheController
import javax.swing.JDesktopPane; //導入方法依賴的package包/類
public static CacheListController getTopViewCacheController(JDesktopPane desktop)
{
if (desktop.getAllFrames().length == 0)
return null;
JInternalFrame jif = desktop.getAllFrames()[0];
return CacheListController.getCacheListController(jif);
}
示例4: tile
import javax.swing.JDesktopPane; //導入方法依賴的package包/類
/**
* From <a href=
* "https://www.java-tips.org/how-to-tile-all-internal-frames-when-requested.html">java-tips.org</a>
* <br>
* Modified to account for iconified windows.
*
* @param desk
* Desktop pane containing windows to be tiled.
*/
public static void tile(JDesktopPane desk) {
// How many frames do we have?
JInternalFrame[] frames = desk.getAllFrames();
List<JInternalFrame> tileableFrames = new ArrayList<>();
List<JInternalFrame> iconifiedFrames = new ArrayList<>();
boolean icons = false;
int count = 0;
for (JInternalFrame frame : frames) {
if (frame.isIcon()) {
iconifiedFrames.add(frame);
icons = true;
} else {
tileableFrames.add(frame);
count++;
}
}
if (count == 0) return;
// Determine the necessary grid size
int sqrt = (int) Math.sqrt(count);
int rows = sqrt;
int cols = sqrt;
if (rows * cols < count) {
cols++;
if (rows * cols < count) {
rows++;
}
}
// Define some initial values for size & location.
Dimension size = desk.getSize();
int hb = size.height;
if (icons && hb > 27) {
hb -= 27;
}
int w = size.width / cols;
int h = hb / rows;
int x = 0;
int y = 0;
// Iterate over the frames and relocating & resizing each.
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols && ((i * cols) + j < count); j++) {
JInternalFrame f = tileableFrames.get((i * cols) + j);
desk.getDesktopManager().resizeFrame(f, x, y, w, h);
x += w;
}
y += h; // start the next row
x = 0;
}
}
示例5: getTopView
import javax.swing.JDesktopPane; //導入方法依賴的package包/類
public static CacheListView getTopView(JDesktopPane desktop)
{
return (CacheListView)desktop.getAllFrames()[0];
}