001: /*
002: * @(#)ResizablePanel.java 2/14/2005
003: *
004: * Copyright 2002 - 2005 JIDE Software Inc. All rights reserved.
005: */
006: package com.jidesoft.swing;
007:
008: import com.jidesoft.plaf.UIDefaultsLookup;
009:
010: import javax.swing.*;
011: import java.awt.*;
012:
013: /**
014: * <code>ResizablePanel</code> is a panel that can be resized. You can resize
015: * it from any of the four corners or four sides.
016: */
017: public class ResizablePanel extends JPanel implements ResizableSupport {
018: private Resizable _resizable;
019:
020: /**
021: * Creates a new <code>ResizablePanel</code> with a double buffer
022: * and a flow layout.
023: */
024: public ResizablePanel() {
025: initComponents();
026: }
027:
028: /**
029: * Creates a new <code>ResizablePanel</code> with <code>FlowLayout</code>
030: * and the specified buffering strategy.
031: * If <code>isDoubleBuffered</code> is true, the <code>JPanel</code>
032: * will use a double buffer.
033: *
034: * @param isDoubleBuffered a boolean, true for double-buffering, which
035: * uses additional memory space to achieve fast, flicker-free
036: * updates
037: */
038: public ResizablePanel(boolean isDoubleBuffered) {
039: super (isDoubleBuffered);
040: initComponents();
041: }
042:
043: /**
044: * Create a new buffered <code>ResizablePanel</code> with the specified layout manager
045: *
046: * @param layout the LayoutManager to use
047: */
048: public ResizablePanel(LayoutManager layout) {
049: super (layout);
050: initComponents();
051: }
052:
053: /**
054: * Creates a new <code>ResizablePanel</code> with the specified layout manager and buffering
055: * strategy.
056: *
057: * @param layout the LayoutManager to use
058: * @param isDoubleBuffered a boolean, true for double-buffering, which
059: * uses additional memory space to achieve fast, flicker-free
060: * updates
061: */
062: public ResizablePanel(LayoutManager layout, boolean isDoubleBuffered) {
063: super (layout, isDoubleBuffered);
064: initComponents();
065: }
066:
067: /**
068: * Creates the Resizable class. It also set the panel's layout to BorderLayout.
069: */
070: protected void initComponents() {
071: _resizable = createResizable();
072: setLayout(new BorderLayout());
073: }
074:
075: /**
076: * Creates the Resizable. Subclass class can override this method to create its own Resizable
077: * and tweak some options.
078: *
079: * @return Resizable.
080: */
081: protected Resizable createResizable() {
082: return new Resizable(this );
083: }
084:
085: /**
086: * Gets the Resizable.
087: *
088: * @return the Resizable.
089: */
090: public Resizable getResizable() {
091: return _resizable;
092: }
093:
094: /**
095: * Overrides the updateUI method to set border to resizable border defined
096: * in UIManagerLookup.getBorder("Resizable.resizeBorder")).
097: */
098: @Override
099: public void updateUI() {
100: super .updateUI();
101: setBorder(UIDefaultsLookup.getBorder("Resizable.resizeBorder"));
102: }
103: }
|