Font and AWT setEnabled problem

Michael Gherrity kaffe@rufus.w3.org
Mon, 08 May 2000 23:24:12 -0700


Hi,
        I am using kaffe-1.0.5 on a PC running FreeBSD 4.0-Release.  The
following program works using Sun's JDK1.1.8 and JDK1.2.2, but not using
Kaffe.  There are two problems; if "SanSerif" font is specified instead
of "Monospaced" the window does not resize at all, and even when
"Monospaced" font is used the setEnabled component method does not seem
to work.

        mike

--
Michael Gherrity
mike@gherrity.org
http://www.gherrity.org/


import java.awt.*;
import java.awt.event.*;


public class Resize extends Frame implements ActionListener
{
  private Button         biggerButton;
  private Button         smallerButton;
  private Font           font;
  private int            index;
  private int[]          goodSize = {8, 10, 12, 14, 18, 24, 36};





  public Resize()
  {
    index = 0;
    font = new Font("Monospaced", Font.BOLD, goodSize[index]);
    setFont(font);
    biggerButton = new Button("bigger");
    smallerButton = new Button("smaller");
    biggerButton.addActionListener(this);
    smallerButton.addActionListener(this);
    biggerButton.setFont(font);
    smallerButton.setFont(font);
    setLayout(new FlowLayout());
    add(biggerButton);
    add(smallerButton);
    smallerButton.setEnabled(false);
    biggerButton.setEnabled(true);
  }





  public void actionPerformed(ActionEvent evt)
  {
    System.err.println("Currently: " + font.getName() + ", "
                       + font.getStyle() + ", " + font.getSize());
    if (evt.getActionCommand() == "bigger")
    {
       index++;
       if (index == 6)
          biggerButton.setEnabled(false);
       else
          biggerButton.setEnabled(true);
       smallerButton.setEnabled(true);
    }
    else if (evt.getActionCommand() == "smaller")
    {
       index--;
       if (index == 0)
          smallerButton.setEnabled(false);
       else
          smallerButton.setEnabled(true);
       biggerButton.setEnabled(true);
    }
    font = new Font(font.getName(), font.getStyle(), goodSize[index]);
    biggerButton.setFont(font);
    biggerButton.invalidate();
    smallerButton.setFont(font);
    smallerButton.invalidate();
    setFont(font);
    System.err.println("  Now: " + font.getName() + ", "
                       + font.getStyle() + ", " + font.getSize());
    validate();
    pack();
    show();
  }





  public static void main(String[] args)
  {
    Resize f = new Resize();
    f.pack();
    f.show();
  }
}