aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes My weight isn't being applied in gridbag constraints Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "My weight isn Watch "My weight isn New topic
Author

My weight isn't being applied in gridbag constraints

Nicholas Turner
Ranch Hand

Joined: May 24, 2003
Posts: 126
I have the following code that should look like

-------/--------/--------
-....../````````/......./
/------/......../......./
/....../......../......./
/....../......../......./
/....../......../-------/
/....../......../......./
/------/--------/-------/
when doen. when i did the first 2 columns the weights were distributed great but when I add the far right column it is now equal. Here is the code if someone could paste it in and test it or just tell me what wrong.
I would greatly appreciate it
Application.java
public class Application extends JFrame {

/** Creates a new instance of Application */
public Application() {
super("Project Watcher");
setSize(400,300);
GridBagLayout gb = new GridBagLayout();
JPanel pane = new JPanel();
pane.setLayout(gb);
GridBagConstraints constraints = new GridBagConstraints();
// Logo area
constraints = new GridBagConstraints();
constraints.weightx = 33;
constraints.weighty = 34;
constraints.fill = GridBagConstraints.BOTH;
constraints.gridx = 0;
constraints.gridy = 0;
constraints.gridheight = 1;
constraints.gridwidth = 1;
JButton logoButton = new JButton("LOGO");
gb.setConstraints(logoButton, constraints);
pane.add(logoButton);

// Project area
constraints = new GridBagConstraints();
constraints.weightx = 33;
constraints.weighty = 66;
constraints.fill = GridBagConstraints.BOTH;
constraints.gridx = 0;
constraints.gridy = 1;
constraints.gridheight = 2;
constraints.gridwidth = 1;

JButton projectButton = new JButton("Project");
gb.setConstraints(projectButton, constraints);
pane.add(projectButton);

// clock area
constraints = new GridBagConstraints();
constraints.weightx = 34;
constraints.weighty = 100;
constraints.fill = GridBagConstraints.BOTH;
constraints.gridx = 1;
constraints.gridy = 0;
constraints.gridheight = 3;
constraints.gridwidth = 1;
JButton clockButton = new JButton("CLOCK");
gb.setConstraints(clockButton, constraints);
pane.add(clockButton);

constraints = new GridBagConstraints();
constraints.weightx = 33;
constraints.weighty = 66;
constraints.gridx = 2;
constraints.gridy = 0;
constraints.gridheight = 2;
constraints.gridwidth = 1;
constraints.fill = GridBagConstraints.BOTH;
JButton empButton = new JButton("Employee");
gb.setConstraints(empButton, constraints);
pane.add(empButton);

constraints = new GridBagConstraints();
constraints.weightx = 33;
constraints.weighty = 34;
constraints.gridx = 2;
constraints.gridy = 2;
constraints.gridheight = 1;
constraints.gridwidth = 1;
constraints.fill = GridBagConstraints.BOTH;
JButton dateButton = new JButton("Date Data");
gb.setConstraints(dateButton, constraints);
pane.add(dateButton);


setContentPane(pane);
}

public static void main(String[] args) {
Application app = new Application();
ExitWindow exit = new ExitWindow();

app.addWindowListener(exit);
app.show();
}

}
class ExitWindow extends WindowAdapter {
public void windowClosing(WindowEvent evt) {
System.exit(0);
}
}
[ May 28, 2003: Message edited by: Nicholas Turner ]
[ May 28, 2003: Message edited by: Nicholas Turner ]
 
wood burning stoves
 
subject: My weight isn't being applied in gridbag constraints