Exemplo n.º 1
0
  public static void addToGridBag(
      GridBagLayout grid,
      Container cont,
      Component comp,
      int x,
      int y,
      int gw,
      int gh,
      double wx,
      double wy,
      int fill,
      int anchor) {
    // now the constraints
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = x;
    gbc.gridy = y;
    gbc.weightx = wx;
    gbc.weighty = wy;
    gbc.fill = fill;
    gbc.gridwidth = gw;
    gbc.gridheight = gh;
    gbc.anchor = anchor;

    cont.add(comp);
    grid.setConstraints(comp, gbc);
  }
Exemplo n.º 2
0
  private void jbInit() throws Exception {
    JLabel loid, lvalue;

    loid = new JLabel("OID: ");
    lvalue = new JLabel("Value: ");
    lmessage = new JLabel("");
    lmessage.setOpaque(true);

    String oid = util.getOid(sysContact);
    toid = new JTextField(oid);
    tvalue = new JTextField();

    setButton = new JButton("Set");
    getButton = new JButton("Get");
    getNextButton = new JButton("GetNext");

    Vector sw = new Vector(2);
    sw.addElement(setButton);
    sw.addElement(getButton);

    GridBagLayout grid = new GridBagLayout();
    Container cont = this;
    cont.setLayout(grid);

    addToGridBag(grid, cont, loid, 0, 0, 0.33, 1.0);
    addToGridBag(grid, cont, toid, 1, 0, 2, 1, 0.33, 1.0);
    addToGridBag(grid, cont, lvalue, 0, 1, 0.33, 1.0);
    addToGridBag(grid, cont, tvalue, 1, 1, 2, 1, 0.33, 1.0);
    addToGridBag(grid, cont, setButton, 0, 2, 0.33, 1.0);
    addToGridBag(grid, cont, getButton, 1, 2, 0.33, 1.0);
    addToGridBag(grid, cont, getNextButton, 2, 2, 0.33, 1.0);
    addToGridBag(grid, cont, lmessage, 0, 3, 3, 1, 0.33, 1.0);

    lmessage.setBackground(Color.white);

    setButton.addActionListener(this);
    getButton.addActionListener(this);
    getNextButton.addActionListener(this);
    this.addMouseListener(this);
  }