Static Public Methods | |
| void | addGridComp (JComponent parent, JComponent child, int gridX, int gridY, int gridWidth, int gridHeight, int fill, double weightX, double weightY, int insetWidth, int insetHeight) |
| Add a component child to the parent container. More... | |
| Color | stringToColor (String input) |
| Convert a String to a Color. More... | |
| String | colorToString (Color c) |
| Convert a String to a Color. More... | |
|
||||||||||||||||||||||||||||||||||||||||||||||||
|
Add a component child to the parent container. The parent is taken to have a GridBagLayout.
00032 {
00033 GridBagLayout gridbag = (GridBagLayout) parent.getLayout();
00034 GridBagConstraints constr = new GridBagConstraints();
00035 constr.gridx = gridX;
00036 constr.gridy = gridY;
00037 constr.gridwidth = gridWidth;
00038 constr.gridheight = gridHeight;
00039 constr.fill = fill;
00040 constr.weightx = weightX;
00041 constr.weighty = weightY;
00042 constr.insets = new Insets(insetHeight, insetWidth,
00043 insetHeight, insetWidth);
00044 gridbag.setConstraints(child, constr);
00045 parent.add(child);
00046 }
|
|
|
Convert a String to a Color. The format of the string is expected to be: (r, g, b) where r, g, and b are integer values is the range 0 - 255.
00054 {
00055 int r = 0, g = 0, b = 0;
00056 try {
00057 StringTokenizer st = new StringTokenizer(input.substring(1), ",)");
00058 r = Integer.valueOf(st.nextToken().trim()).intValue();
00059 g = Integer.valueOf(st.nextToken().trim()).intValue();
00060 b = Integer.valueOf(st.nextToken().trim()).intValue();
00061 } catch (NumberFormatException nfe) {
00062 System.out.println("NumberFormatException");
00063 } catch (NoSuchElementException nsee) {
00064 System.out.println("NoSuchElementException");
00065 }
00066 return new Color(r, g, b);
00067 }
|
|
|
Convert a String to a Color. The format of the string is expected to be: (r, g, b) where r, g, and b are integer values is the range 0 - 255.
00075 {
00076 return new String("(" + c.getRed() + ", "
00077 + c.getGreen() + ", "
00078 + c.getBlue() + ")");
00079 }
|
1.2.12 written by Dimitri van Heesch,
© 1997-2001