?? mdipane.java
字號:
/**
* Copyright 1999-2002 Matthew Robinson and Pavel Vorobiev.
* All Rights Reserved.
*
* ===================================================
* This program contains code from the book "Swing"
* 2nd Edition by Matthew Robinson and Pavel Vorobiev
* http://www.spindoczine.com/sbe
* ===================================================
*
* The above paragraph must be included in full, unmodified
* and completely intact in the beginning of any source code
* file that references, copies or uses (in any way, shape
* or form) code contained in this file.
*/
package mdi;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MDIPane
extends JLayeredPane
implements ComponentListener
{
public MDIPane() {
addComponentListener(this);
setOpaque(true);
// default background color
setBackground(new Color(244,232,152));
}
public void componentHidden(ComponentEvent e) {}
public void componentMoved(ComponentEvent e) {}
public void componentShown(ComponentEvent e) {}
public void componentResized(ComponentEvent e) { lineup(); }
public void lineup() {
int frameHeight, frameWidth, currentX, currentY, lheight, lwidth;
lwidth = getWidth();
lheight = getHeight();
currentX = 0;
currentY = lheight;
Component[] components = getComponents();
for (int i=components.length-1; i>-1; i--) {
if (components[i] instanceof InnerFrame) {
InnerFrame tempFrame = (InnerFrame) components[i];
frameHeight = tempFrame.getHeight();
frameWidth = tempFrame.getWidth();
if (tempFrame.isMaximized()) {
tempFrame.setBounds(0,0,getWidth(),getHeight());
tempFrame.validate();
tempFrame.repaint();
}
else if (tempFrame.isIconified()) {
if (currentX+frameWidth > lwidth) {
currentX = 0;
currentY -= frameHeight;
}
tempFrame.setLocation(currentX, currentY-frameHeight);
currentX += frameWidth;
}
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -