File: ResizablePanel.java

package info (click to toggle)
libjide-oss-java 3.7.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 13,264 kB
  • sloc: java: 89,463; xml: 268; makefile: 35
file content (96 lines) | stat: -rw-r--r-- 2,984 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*
 * @(#)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.*;

/**
 * <code>ResizablePanel</code> 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 <code>ResizablePanel</code> with a double buffer and a flow layout.
     */
    public ResizablePanel() {
        initComponents();
    }

    /**
     * Creates a new <code>ResizablePanel</code> with <code>FlowLayout</code> and the specified buffering strategy. If
     * <code>isDoubleBuffered</code> is true, the <code>JPanel</code> 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 <code>ResizablePanel</code> with the specified layout manager
     *
     * @param layout the LayoutManager to use
     */
    public ResizablePanel(LayoutManager layout) {
        super(layout);
        initComponents();
    }

    /**
     * Creates a new <code>ResizablePanel</code> 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"));
    }
}