scrollpanelayout.java
来自「Mac OS X 10.4.9 for x86 Source Code gcc」· Java 代码 · 共 476 行 · 第 1/2 页
JAVA
476 行
/* ScrollPaneLayout.java -- Copyright (C) 2002, 2004 Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU Classpath is distributed in the hope that it will be useful, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING. If not, write to theFree Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA02111-1307 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library. Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule. An independent module is a module which is not derived fromor based on this library. If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so. If you do not wish to do so, delete thisexception statement from your version. */package javax.swing;import java.awt.Component;import java.awt.Container;import java.awt.Dimension;import java.awt.Insets;import java.awt.LayoutManager;import java.awt.Point;import java.awt.Rectangle;import java.io.Serializable;import javax.swing.border.Border;/** * ScrollPaneLayout * @author Andrew Selkirk * @version 1.0 */public class ScrollPaneLayout implements LayoutManager, ScrollPaneConstants, Serializable{ private static final long serialVersionUID = -4480022884523193743L; public static class UIResource extends ScrollPaneLayout implements javax.swing.plaf.UIResource { public UIResource() { } } protected JViewport viewport; protected JScrollBar vsb; protected JScrollBar hsb; protected JViewport rowHead; protected JViewport colHead; protected Component lowerLeft; protected Component lowerRight; protected Component upperLeft; protected Component upperRight; protected int vsbPolicy; protected int hsbPolicy; public ScrollPaneLayout() { } public void syncWithScrollPane(JScrollPane scrollPane) { viewport = scrollPane.getViewport(); rowHead = scrollPane.getRowHeader(); colHead = scrollPane.getColumnHeader(); vsb = scrollPane.getVerticalScrollBar(); hsb = scrollPane.getHorizontalScrollBar(); vsbPolicy = scrollPane.getVerticalScrollBarPolicy(); hsbPolicy = scrollPane.getHorizontalScrollBarPolicy(); lowerLeft = scrollPane.getCorner(LOWER_LEFT_CORNER); lowerRight = scrollPane.getCorner(LOWER_RIGHT_CORNER); upperLeft = scrollPane.getCorner(UPPER_LEFT_CORNER); upperRight = scrollPane.getCorner(UPPER_RIGHT_CORNER); } protected Component addSingletonComponent(Component oldComponent, Component newComponent) { return null; } public void addLayoutComponent(String key, Component component) { if (key == VIEWPORT) viewport = (JViewport) component; else if (key == VERTICAL_SCROLLBAR) vsb = (JScrollBar) component; else if (key == HORIZONTAL_SCROLLBAR) hsb = (JScrollBar) component; else if (key == ROW_HEADER) rowHead = (JViewport) component; else if (key == COLUMN_HEADER) colHead = (JViewport) component; else if (key == LOWER_RIGHT_CORNER) lowerRight = component; else if (key == UPPER_RIGHT_CORNER) upperRight = component; else if (key == LOWER_LEFT_CORNER) lowerLeft = component; else if (key == UPPER_LEFT_CORNER) upperLeft = component; } public void removeLayoutComponent(Component component) { if (component == viewport) viewport = null; else if (component == vsb) vsb = null; else if (component == hsb) hsb = null; else if (component == rowHead) rowHead = null; else if (component == colHead) colHead = null; else if (component == lowerRight) lowerRight = null; else if (component == upperRight) upperRight = null; else if (component == lowerLeft) lowerLeft = null; else if (component == upperLeft) upperLeft = null; } public int getVerticalScrollBarPolicy() { return vsbPolicy; } public void setVerticalScrollBarPolicy(int policy) { vsbPolicy = policy; } public int getHorizontalScrollBarPolicy() { return hsbPolicy; } public void setHorizontalScrollBarPolicy(int policy) { hsbPolicy = policy; } public JViewport getViewport() { return viewport; } public JScrollBar getHorizontalScrollBar() { return hsb; } public JScrollBar getVerticalScrollBar() { return vsb; } public JViewport getRowHeader() { return rowHead; } public JViewport getColumnHeader() { return colHead; } public Component getCorner(String key) { if (key == LOWER_RIGHT_CORNER) return lowerRight; else if (key == UPPER_RIGHT_CORNER) return upperRight; else if (key == LOWER_LEFT_CORNER) return lowerLeft; else if (key == UPPER_LEFT_CORNER) return upperLeft; return null; } private static void maybeSetPreferredSize(JComponent src, Dimension dim) { Dimension tmp = null; if (src != null) tmp = src.getPreferredSize(); if (tmp != null) dim.setSize(tmp); } private static void maybeSetMinimumSize(JComponent src, Dimension dim) { Dimension tmp = null; if (src != null) tmp = src.getMinimumSize(); if (tmp != null) dim.setSize(tmp); } public Dimension preferredLayoutSize(Container parent) { if (parent != null && parent instanceof JScrollPane) { JScrollPane sc = (JScrollPane) parent; synchronized (sc.getTreeLock ()) { Dimension insetsSize = new Dimension(0,0); Dimension viewportSize = new Dimension(0,0); Dimension viewportInsetsSize = new Dimension(0,0); Dimension columnHeaderSize = new Dimension(0,0); Dimension rowHeaderSize = new Dimension(0,0); Dimension verticalScrollBarSize = new Dimension(0,0); Dimension horizontalScrollBarSize = new Dimension(0,0); Insets insets = sc.getInsets(); Border viewportBorder = sc.getViewportBorder();
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?