Blame view

JPAINT/jpaint/JPaintLayoutManager.java 2.4 KB
933d00ad   rlentieu   add JPaint
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
  import java.awt.GridBagLayout;

  import java.awt.GridBagConstraints;

  import java.awt.Component;

  

  /**

   * JPaintLayoutManager is an extension of GridBagLayout, this class is a helper

   * class for the GridBagLayout. It makes using this layout easier.

   **/

  public class JPaintLayoutManager extends GridBagLayout

  {

  	private GridBagConstraints gbc;

  	private Component comp;

  	

  	/** Creates a default JPaintLayoutManager. **/

  	public JPaintLayoutManager()

  	{

  		gbc = new GridBagConstraints();

  	}

  	

  	/** Sets the components necessary to get the layout started. **/

  	public void setComponent(Component compo, int gridx, int gridy, int gridwidth, int gridHeight,

  								int ipadx, int ipady, int weightx, int weighty, int fill)

  	{

  			comp = compo;

  			gbc.gridx = gridx;

  			gbc.gridy = gridy;

  			gbc.gridwidth = gridwidth;

  			gbc.gridheight = gridHeight;

  			gbc.ipadx = ipadx;

  			gbc.ipady = ipady;

  			gbc.weightx = weightx;

  			gbc.weighty = weighty;

  			gbc.fill = fill;

  			setConstraints(compo, gbc); 						

  	}

  	

  	/** Sets the gridX. **/

  	public void setgridx(int gridx)

  	{

  		gbc.gridx = gridx;

  		setConstraints(comp, gbc);

  	}

  	

  	/** Sets the gridY. **/

  	public void setGridY(int gridy)

  	{

  		gbc.gridy = gridy;

  		setConstraints(comp, gbc);

  	}

  	

  	/** Sets the gridWidth. **/

  	public void setGridWidth(int gridwidth)

  	{

  		gbc.gridwidth = gridwidth;

  		setConstraints(comp, gbc);

  	}

  	

  	/** Sets the gridHeight. **/

  	public void setGridHeight(int gridheight)

  	{

  		gbc.gridheight = gridheight;

  		setConstraints(comp, gbc);

  	}

  	

  	/** Sets the ipadX. **/

  	public void setIpadx(int ipadx)

  	{

  		gbc.ipadx = ipadx;

  		setConstraints(comp, gbc);

  	}

  

  	/** Sets the ipadY. **/

  	public void setIpady(int ipady)

  	{

  		gbc.ipady = ipady;

  		setConstraints(comp, gbc);

  	}

  	

  	/** Sets the xWeight. **/

  	public void setWeightx(int weightx)

  	{

  		gbc.weightx = weightx;

  		setConstraints(comp, gbc);

  	}

  	

  	/** Sets the yWeight. **/

  	public void setWeighty(int weighty)

  	{

  		gbc.weighty = weighty;

  		setConstraints(comp, gbc);

  	}

  	

  	/** Sets the anchor. **/

  	public void setAnchor(int anchor)

  	{

  		gbc.anchor = anchor;

  		setConstraints(comp, gbc);		

  	}

  	

  	/** Resets all the variables to its default settings. **/

  	public void reset()

  	{

  		gbc.gridx = 0;

  		gbc.gridy = 0;

  		gbc.gridwidth = 0;

  		gbc.gridheight = 0;

  		gbc.ipadx = 0;

  		gbc.ipady = 0;

  		gbc.weightx = 0;

  		gbc.weighty= 0;

  	}

  }