This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
ipadx and ipady are not irrelevant. To see this on the simulator you cite, try setting them to large values like 100. Only answer A is correct.
"I'm not back." - Bill Harding, Twister
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
I'm sorry but I'm still confused. If ipadx and ipady are NOT irrelevant than how can the answer be A only? The GridBagLayout simulator i mentioned, how accurately does it represent the way GridBagLayout actually works? Can weightx and weighty be greater than 1? It appears that fill and anchor don't have much effect unless the weight values are greater than zero. [This message has been edited by Joe Java (edited February 14, 2000).]
Jim Yingst
Wanderer
Sheriff
Joined: Jan 30, 2000
Posts: 18670
posted
0
Gotta read the question - it asks which of the following ARE irrelevant, so if I say that ipadx and ipady AREN'T irrelevant, then that means they're not part of the answer. Anchor (and only anchor) IS irrelevant if fill = BOTH, so it's the only answer. The simulator is pretty accurate, I think, since it seems to use an actual GridBagLayout to generate what you see. You do get some strange effects if weight is 0, and so it would probably be good if the simulator defaulted all weights to 1 instead. Oh well, you can do that yourself I guess. Weights certainly can be greater than 1 - they are compared to each other, so all weights are relative to whatever is the largest number used for a weight in that GridBagLayout. Often people arbitrarily limit that maximum to 1, but that's not required.
Elena Balland
Greenhorn
Joined: Dec 21, 2000
Posts: 8
posted
0
This my 2 cents. I made the following code to test this question: import java.awt.*; public class BagConst1 extends java.applet.Applet { void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) { gbc.gridx = gx; gbc.gridy = gy; gbc.gridwidth = gw; gbc.gridheight = gh; gbc.ipadx = wx; gbc.ipady = wy; } public void init() { GridBagLayout gridbag = new GridBagLayout(); GridBagConstraints constraints = new GridBagConstraints(); setLayout(gridbag); constraints.fill = GridBagConstraints.BOTH; constraints.weightx =5; // 1stButton buildConstraints(constraints, 0, 0, 1, 1, 0, 0); Button but1 = new Button("Button1"); gridbag.setConstraints(but1, constraints); add(but1);
// 2nd Button Button but2 = new Button("Button2 with ipadx"); buildConstraints(constraints, 0, 1, 1, 1, 80, 0); gridbag.setConstraints(but2, constraints); add(but2);
buildConstraints(constraints, 0, 2, 1, 1, 0, 80);
Button but3 = new Button("Button3 with ipady"); gridbag.setConstraints(but3, constraints); add(but3);
buildConstraints(constraints, 0, 3, 1, 1, 0, 0); constraints.insets = new Insets(20,60,40,40); Button but4 = new Button("Button4 with Insets"); gridbag.setConstraints(but4, constraints); add(but4);
buildConstraints(constraints, 0, 4, 1, 1, 0, 0); constraints.insets = new Insets(0,0,0,0); constraints.fill = GridBagConstraints.NONE; Button but5 = new Button("Button5 without BOTH"); gridbag.setConstraints(but5, constraints); add(but5);
} } When I compiled I received something strange: ipadx doesn't effect, but ipady effects. Insets for sure effect. It is pretty much fair that anchor is irrelevant for it is affects only when the component is smaller than its display area.
natarajan meghanathan
Ranch Hand
Joined: Feb 01, 2001
Posts: 130
posted
0
I think the correct answer is A, C, F. Still this post is not completely answered!!