Hi All
I am trying to resize the button which is placed in a cell of GridBagLayout but FAILED...:(
Like I want same size of every button (Please see the attached file for what I am getting as Output of my Program which is as follow -
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.awt.*;
public class Main {
public static void main(String[] args) {
Frame f = new Frame("Demonstrates the use of weightx, weighty constraints");
Panel p = new Panel();
p.setLayout(new GridBagLayout());
GridBagConstraints c = new GridBagConstraints();
p.setLayout(new GridBagLayout());
c = new GridBagConstraints();
c.insets = new Insets(20, 2, 20, 2);
c.weighty = 10.0;
c.weightx = 10.0;
c.gridx = 0;
c.gridy = 0;
p.add(new Button("Java"), c);
c.gridx = 1;
p.add(new Button("Source"), c);
c.gridx = 0;
c.gridy = 1;
p.add(new Button("and"), c);
c.gridx = 1;
p.add(new Button("Support."), c);
WindowListener wndCloser = new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
};
f.addWindowListener(wndCloser);
f.add(p);
f.setSize(600, 200);
f.setVisible(true);
}
}