All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jidesoft.swing.ResizablePanel Maven / Gradle / Ivy

There is a newer version: 3.6.18
Show newest version
/*
 * @(#)ResizablePanel.java 2/14/2005
 *
 * Copyright 2002 - 2005 JIDE Software Inc. All rights reserved.
 */
package com.jidesoft.swing;

import com.jidesoft.plaf.UIDefaultsLookup;

import javax.swing.*;
import java.awt.*;

/**
 * ResizablePanel is a panel that can be resized. You can resize it from any of the four corners or four
 * sides.
 */
public class ResizablePanel extends JPanel implements ResizableSupport {
    private Resizable _resizable;

    /**
     * Creates a new ResizablePanel with a double buffer and a flow layout.
     */
    public ResizablePanel() {
        initComponents();
    }

    /**
     * Creates a new ResizablePanel with FlowLayout and the specified buffering strategy. If
     * isDoubleBuffered is true, the JPanel will use a double buffer.
     *
     * @param isDoubleBuffered a boolean, true for double-buffering, which uses additional memory space to achieve fast,
     *                         flicker-free updates
     */
    public ResizablePanel(boolean isDoubleBuffered) {
        super(isDoubleBuffered);
        initComponents();
    }

    /**
     * Create a new buffered ResizablePanel with the specified layout manager
     *
     * @param layout the LayoutManager to use
     */
    public ResizablePanel(LayoutManager layout) {
        super(layout);
        initComponents();
    }

    /**
     * Creates a new ResizablePanel with the specified layout manager and buffering strategy.
     *
     * @param layout           the LayoutManager to use
     * @param isDoubleBuffered a boolean, true for double-buffering, which uses additional memory space to achieve fast,
     *                         flicker-free updates
     */
    public ResizablePanel(LayoutManager layout, boolean isDoubleBuffered) {
        super(layout, isDoubleBuffered);
        initComponents();
    }

    /**
     * Creates the Resizable class. It also set the panel's layout to BorderLayout.
     */
    protected void initComponents() {
        _resizable = createResizable();
        setLayout(new BorderLayout());
    }

    /**
     * Creates the Resizable. Subclass class can override this method to create its own Resizable and tweak some
     * options.
     *
     * @return Resizable.
     */
    protected Resizable createResizable() {
        return new Resizable(this);
    }

    /**
     * Gets the Resizable.
     *
     * @return the Resizable.
     */
    public Resizable getResizable() {
        return _resizable;
    }

    /**
     * Overrides the updateUI method to set border to resizable border defined in UIManagerLookup.getBorder("Resizable.resizeBorder")).
     */
    @Override
    public void updateUI() {
        super.updateUI();
        setBorder(UIDefaultsLookup.getBorder("Resizable.resizeBorder"));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy