Пример #1
0
 public void setBounds(int x, int y, int width, int height) {
   button.getParent().remove(button);
   button.setBounds(x, y, width, height);
   button.addToParent(button.getParent()); // will i have to do this for
   // every method?
   // why doesn't the component remain malleable after it's added?
 }
  void rebuildButtons() {
    stringToObjects = new Hashtable();
    stringToButtons = new Hashtable();
    buttonsPanel.removeAll();
    // buttonGroup = new ButtonGroup();
    int newSize = getSize();
    //  	for (int i = 0; i < getSize(); i ++) {
    for (int i = 0; i < newSize; i++) {

      Object item = getElementAt(i);
      String itemString = item.toString();
      // AbstractButton button = new JRadioButton(itemString);
      VirtualButton button = createButton(itemString);
      setColors(button);
      // VirtualButton button = createButton (itemString);
      button.setActionCommand(itemString);
      stringToObjects.put(itemString, item);
      stringToButtons.put(itemString, button);
      button.addActionListener(this);
      // buttonGroup.add(radioButton);
      buttonsPanel.add(button);

      doAdditionalProcessing(button);
    }
    // force the first item to be selected
    lastSelectedItem = null;

    // int numCols = getObjectAdapter().getUnboundButtonsRowSize();
    setLayout();
    // not sure we need this as color is set before this
    // 	setColors(buttonsPanel);
    /*
    buttonsPanel.setLayout(new GridLayout (0, numCols));
    oldSize = getSize();
    */
    oldSize = newSize;
  }
Пример #3
0
 public void pack() {
   button.pack();
 }
Пример #4
0
 public void setText(String text) {
   button.getParent().remove(button);
   button.setText(text);
   button.addToParent(button.getParent()); // maybe just emulate effects
   // found in addToParent()
 }