| DragResizeTest.java |
1 /*
2 * Copyright (c) 2004 imagero Andrei Kouznetsov. All Rights Reserved.
3 * http://jgui.imagero.com
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
8 * any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 package jguitest;
21
22 import com.imagero.gui.flowin.util.DefaultGridChecker;
23 import com.imagero.gui.flowin.util.GridDragHandler;
24 import com.imagero.gui.flowin.util.ResizeHandler;
25
26 import javax.swing.*;
27 import javax.swing.border.LineBorder;
28 import java.awt.*;
29
30 public class DragResizeTest {
31 public static void main(String[] args) {
32
33 JFrame frame = new JFrame();
34 frame.getContentPane().setLayout(null);
35 for (int j = 1; j < 7; j+=2) {
36 for (int i = 1; i < 7; i+=2) {
37 JPanel panel = new JPanel(new BorderLayout());
38 JPanel master = new JPanel();
39 panel.add(master, (i + j) % 3 == 0 ? BorderLayout.WEST : BorderLayout.NORTH);
40 final DefaultGridChecker gc = new DefaultGridChecker(50, 50, 10, 20);
41 ResizeHandler rh = new ResizeHandler(panel);
42 rh.setChecker(gc);
43 GridDragHandler dh = new GridDragHandler(master, panel, true);
44 dh.setChecker(gc);
45 frame.getContentPane().add(panel);
46 panel.setBounds(i * 100, j*100, 100, 100);
47 final Color bg = new Color((i + j + 1) * 33 & 0xFF, (i + 1) * 33 & 0xFF, (j + 1) * 33 & 0xFF);
48 panel.setBorder(new LineBorder(bg.brighter(), 2));
49 panel.setBackground(bg);
50 master.setBackground(bg.darker());
51 }
52 }
53 frame.setSize(700,700);
54 frame.show();
55 }
56 }
57